System.Xml.Tests.TCFullEndElement.TCWriteValue.writeValue_27 C# (CSharp) Method

writeValue_27() public method

public writeValue_27 ( ) : int
return int
            public int writeValue_27()
            {
                if (CurVariation.Desc.Equals("elem.WriteValue(new DateTimeOffset)"))
                {
                    Console.WriteLine("elem.WriteValue(new DateTimeOffset)");
                }

                int param = (int)CurVariation.Params[0];
                string sourceStr = (string)CurVariation.Params[1];
                string destStr = (string)CurVariation.Params[2];
                Type source = typeMapper[sourceStr];
                Type dest = typeMapper[destStr];
                bool isValid = (bool)CurVariation.Params[3];
                object expVal = (object)CurVariation.Params[4];

                if (expVal == null && destStr.Contains("DateTime"))
                    expVal = value[destStr];
                else if (expVal != null && sourceStr.Contains("DateTime"))
                    expVal = _dates[(int)expVal];
                else if (sourceStr.Equals("XmlQualifiedName") && (WriterType == WriterType.CustomWriter) && param == 1)
                    expVal = "{}a";
                else if (expVal == null)
                    expVal = value[sourceStr];

                using (XmlWriter w = CreateWriter())
                {
                    w.WriteStartElement("Root");
                    if (param == 1)
                        w.WriteValue(value[sourceStr]);
                    else
                        w.WriteAttributeString("a", value[sourceStr].ToString());
                    w.WriteEndElement();
                }
                try
                {
                    VerifyValue(dest, expVal, param);
                }
                catch (XmlException)
                {
                    if (!isValid || (WriterType == WriterType.CustomWriter) && sourceStr.Contains("XmlQualifiedName")) return TEST_PASS;
                    CError.Compare(false, "XmlException");
                }
                catch (OverflowException)
                {
                    if (!isValid) return TEST_PASS;
                    CError.Compare(false, "OverflowException");
                }
                catch (FormatException)
                {
                    if (!isValid) return TEST_PASS;
                    CError.Compare(false, "FormatException");
                }
                catch (ArgumentOutOfRangeException)
                {
                    if (!isValid) return TEST_PASS;
                    CError.Compare(false, "ArgumentOutOfRangeException");
                }
                catch (InvalidCastException)
                {
                    if (!isValid) return TEST_PASS;
                    CError.Compare(false, "ArgumentException");
                }
                return (isValid) ? TEST_PASS : TEST_FAIL;
            }