Example #1
0
 // general idea is Plain Old Data before objects.
 protected Session(SerializationInfo info, StreamingContext context)
 {
     info.read(ref m_Scoring, "Scoring");
     info.read(ref m_Event_Raids, "Event_Raids");
     GameMode = (GameMode)info.GetSByte("GameMode");
     ScriptStage_PoliceStationPrisoner = (int)info.GetSByte("ScriptStage_PoliceStationPrisoner");
     ScriptStage_PoliceCHARrelations   = (int)info.GetSByte("ScriptStage_PoliceCHARrelations");
     ScriptStage_HospitalPowerup       = (int)info.GetSByte("ScriptStage_HospitalPowerup");
     s_seed = info.GetInt32("Seed");
     LastTurnPlayerActed = info.GetInt32("LastTurnPlayerActed");
     PlayerKnows_CHARUndergroundFacilityLocation = info.GetBoolean("PlayerKnows_CHARUndergroundFacilityLocation");
     info.read_nullsafe(ref m_CommandLineOptions, "CommandLineOptions");
     ActorModel.Load(info, context);
     Actor.Load(info, context);
     Rules.Get.Load(info, context);
     PlayerController.Load(info, context);
     World = (World)info.GetValue("World", typeof(World));
     RogueGame.Load(info, context);
     UniqueActors = (UniqueActors)info.GetValue("UniqueActors", typeof(UniqueActors));
     UniqueItems  = (UniqueItems)info.GetValue("UniqueItems", typeof(UniqueItems));
     UniqueMaps   = (UniqueMaps)info.GetValue("UniqueMaps", typeof(UniqueMaps));
     info.read(ref m_PoliceItemMemory, "m_PoliceItemMemory");
     info.read(ref m_PoliceThreatTracking, "m_PoliceThreatTracking");
     info.read(ref m_PoliceInvestigate, "m_PoliceInvestigate");
 }
        public void SerializationInfo_AddGet()
        {
            var value = new Serializable();
            var si    = new SerializationInfo(typeof(Serializable), new FormatterConverter());
            var sc    = new StreamingContext();

            value.GetObjectData(si, sc);

            Assert.AreEqual(typeof(Serializable), si.ObjectType);
            Assert.AreEqual(typeof(Serializable).FullName, si.FullTypeName);
            // TODO: Implement AssemblyName property
            // Assert.AreEqual(typeof(Serializable).Assembly.FullName, si.AssemblyName);

            Assert.AreEqual(15, si.MemberCount);

            Assert.AreEqual(true, si.GetBoolean("bool"));
            Assert.AreEqual("hello", si.GetString("string"));
            Assert.AreEqual('a', si.GetChar("char"));

            Assert.AreEqual(byte.MaxValue, si.GetByte("byte"));

            Assert.AreEqual(decimal.MaxValue, si.GetDecimal("decimal"));
            Assert.AreEqual(double.MaxValue, si.GetDouble("double"));
            Assert.AreEqual(short.MaxValue, si.GetInt16("short"));
            Assert.AreEqual(int.MaxValue, si.GetInt32("int"));
            Assert.AreEqual(long.MaxValue, si.GetInt64("long"));
            Assert.AreEqual(sbyte.MaxValue, si.GetSByte("sbyte"));
            Assert.AreEqual(float.MaxValue, si.GetSingle("float"));
            Assert.AreEqual(ushort.MaxValue, si.GetUInt16("ushort"));
            Assert.AreEqual(uint.MaxValue, si.GetUInt32("uint"));
            Assert.AreEqual(ulong.MaxValue, si.GetUInt64("ulong"));
            Assert.AreEqual(DateTime.MaxValue, si.GetDateTime("datetime"));
        }
Example #3
0
        public FollowedStatTypes(SerializationInfo info, StreamingContext context)
        {
            try
            {
                this.statTypes = (StatTypes)(info.GetValue("statTypes", typeof(StatTypes)));
            }
            catch
            {
                this.statTypes = StatTypes.None;
            }

            try
            {
                this.follows = info.GetString("follows");
            }
            catch
            {
                this.follows = "";
            }
            try
            {
                this._DecimalSpace = info.GetSByte("_DecimalSpace");
            }
            catch
            {
                this._DecimalSpace = -1;
            }
        }
Example #4
0
        protected ISerializableTestObject(SerializationInfo info, StreamingContext context)
        {
            _stringValue         = info.GetString("stringValue");
            _intValue            = info.GetInt32("intValue");
            _dateTimeOffsetValue = (DateTimeOffset)info.GetValue(
                "dateTimeOffsetValue",
                typeof(DateTimeOffset)
                );
            _personValue     = (Person)info.GetValue("personValue", typeof(Person));
            _nullPersonValue = (Person)info.GetValue("nullPersonValue", typeof(Person));
            _nullableInt     = (int?)info.GetValue("nullableInt", typeof(int?));

            _booleanValue  = info.GetBoolean("booleanValue");
            _byteValue     = info.GetByte("byteValue");
            _charValue     = info.GetChar("charValue");
            _dateTimeValue = info.GetDateTime("dateTimeValue");
            _decimalValue  = info.GetDecimal("decimalValue");
            _shortValue    = info.GetInt16("shortValue");
            _longValue     = info.GetInt64("longValue");
            _sbyteValue    = info.GetSByte("sbyteValue");
            _floatValue    = info.GetSingle("floatValue");
            _ushortValue   = info.GetUInt16("ushortValue");
            _uintValue     = info.GetUInt32("uintValue");
            _ulongValue    = info.GetUInt64("ulongValue");
        }
        protected NativeTypes(SerializationInfo info, StreamingContext context)
        {
            if (info == null)
            {
                throw new ArgumentNullException(nameof(info));
            }

            Bool     = info.GetBoolean(nameof(Bool));
            Byte     = info.GetByte(nameof(Byte));
            Sbyte    = info.GetSByte(nameof(Sbyte));
            Char     = info.GetChar(nameof(Char));
            Decimal  = info.GetDecimal(nameof(Decimal));
            Double   = info.GetDouble(nameof(Double));
            Float    = info.GetSingle(nameof(Float));
            Int      = info.GetInt32(nameof(Int));
            Uint     = info.GetUInt32(nameof(Uint));
            Long     = info.GetInt64(nameof(Long));
            Ulong    = info.GetUInt64(nameof(Ulong));
            Short    = info.GetInt16(nameof(Short));
            Ushort   = info.GetUInt16(nameof(Ushort));
            String   = info.GetString(nameof(String));
            DateTime = info.GetDateTime(nameof(DateTime));
            Guid     = Guid.Parse(info.GetString(nameof(Guid)));
            Null     = info.GetValue(nameof(Null), typeof(object));
        }
Example #6
0
        private UnitType(SerializationInfo info, StreamingContext c)
        {
            // Retrieve data from serialization:
            int maxindex = 0;
            int count    = info.GetInt32("count");

            int[]   tstoreind = new int[count];
            sbyte[] tstoreexp = new sbyte[count];
            for (int i = 0; i < count; i++)
            {
                int index = UnitType.GetBaseUnitIndex(info.GetString("name" + i.ToString()));
                tstoreind[i] = index;
                tstoreexp[i] = info.GetSByte("exp" + i.ToString());
                if (index > maxindex)
                {
                    maxindex = index;
                }
            }

            // Construct instance:
            this.baseUnitIndices = new sbyte[maxindex + 1];
            for (int i = 0; i < count; i++)
            {
                this.baseUnitIndices[tstoreind[i]] = tstoreexp[i];
            }
        }
Example #7
0
 public TestClassSerializable(SerializationInfo info, StreamingContext context)
 {
     m_Integer       = info.GetInt32("Integer");
     m_String        = info.GetString("String");
     m_Sbyte         = info.GetSByte("Sbyte");
     m_Bool          = info.GetBoolean("Bool");
     m_StringBuilder = info.GetValue("StringBuilder", typeof(StringBuilder)) as StringBuilder;
 }
Example #8
0
            protected Primitives(SerializationInfo info, StreamingContext context)
            {
                SerializationCtorCalled = true;

                Byte  = info.GetByte("byte");
                Bytes = (byte[])info.GetValue("bytes", typeof(byte[]));

                Sbyte  = info.GetSByte("sbyte");
                Sbytes = (sbyte[])info.GetValue("sbytes", typeof(sbyte[]));

                Bool  = info.GetBoolean("bool");
                Bools = (bool[])info.GetValue("bools", typeof(bool[]));

                Char  = info.GetChar("char");
                Chars = (char[])info.GetValue("chars", typeof(char[]));

                Short  = info.GetInt16("short");
                Shorts = (short[])info.GetValue("shorts", typeof(short[]));

                Ushort  = info.GetUInt16("ushort");
                Ushorts = (ushort[])info.GetValue("ushorts", typeof(ushort[]));

                Int  = info.GetInt32("int");
                Ints = (int[])info.GetValue("ints", typeof(int[]));

                Uint  = info.GetUInt32("uint");
                Uints = (uint[])info.GetValue("uints", typeof(uint[]));

                Long  = info.GetInt64("long");
                Longs = (long[])info.GetValue("longs", typeof(long[]));

                Ulong  = info.GetUInt64("ulong");
                Ulongs = (ulong[])info.GetValue("ulongs", typeof(ulong[]));

                Float  = info.GetSingle("float");
                Floats = (float[])info.GetValue("floats", typeof(float[]));

                Double  = info.GetDouble("double");
                Doubles = (double[])info.GetValue("doubles", typeof(double[]));

                Decimal  = info.GetDecimal("decimal");
                Decimals = (decimal[])info.GetValue("decimals", typeof(decimal[]));

                Guid  = (Guid)info.GetValue("guid", typeof(Guid));
                Guids = (Guid[])info.GetValue("guids", typeof(Guid[]));

                DateTime  = info.GetDateTime("datetime");
                DateTimes = (DateTime[])info.GetValue("datetimes", typeof(DateTime[]));

                String  = info.GetString("string");
                Strings = (string[])info.GetValue("strings", typeof(string[]));

                IntPtr  = (IntPtr)info.GetInt64("intptr");
                IntPtrs = (IntPtr[])info.GetValue("intptrs", typeof(IntPtr[]));

                UIntPtr  = (UIntPtr)info.GetInt64("uintptr");
                UIntPtrs = (UIntPtr[])info.GetValue("uintptrs", typeof(UIntPtr[]));
            }
Example #9
0
        private ComparisonRule(SerializationInfo info, StreamingContext context)
        {
            if (info == null)
            {
                throw new ArgumentNullException(nameof(info));
            }
            Direction = (Direction)info.GetSByte(nameof(Direction));
            var cultureId = info.GetInt32(nameof(Culture));

            Culture = (cultureId != int.MinValue) ? CultureInfo.GetCultureInfo(cultureId) : null;
        }
Example #10
0
    public bool runTest()
    {
        Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver : " + s_strDtTmVer);
        int               iCountErrors    = 0;
        int               iCountTestcases = 0;
        String            strLoc          = "Loc_000oo";
        SerializationInfo serinfo1        = null;
        Boolean           fValue;
        Char              chValue;
        SByte             sbtValue;
        Byte              btValue;
        Int16             i16Value;
        Int32             i32Value;
        Int64             i64Value;
        UInt16            ui16Value;
        UInt32            ui32Value;
        UInt64            ui64Value;
        Double            dblValue;
        Single            sglValue;
        DateTime          dtValue;
        Decimal           dcmValue;
        StringBuilder     sbldr1;
        String            strValue;
        Random            rnd1;

        try {
            do
            {
                strLoc   = "Loc_6573cd";
                serinfo1 = new SerializationInfo(typeof(Int32), new FormatterConverter());
                iCountTestcases++;
                if (serinfo1.MemberCount != 0)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0246sd! Wrong number of members, " + serinfo1.MemberCount.ToString());
                }
                strLoc = "Loc_6853vd";
                fValue = false;
                serinfo1.AddValue("Boolean_1", fValue);
                iCountTestcases++;
                if (serinfo1.GetBoolean("Boolean_1") != fValue)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0945csd! wrong value returned, " + serinfo1.GetBoolean("Boolean_1"));
                }
                fValue = true;
                serinfo1.AddValue("Boolean_2", fValue);
                iCountTestcases++;
                if (serinfo1.GetBoolean("Boolean_2") != fValue)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_6753vd! wrong value returned, " + serinfo1.GetBoolean("Boolean_2"));
                }
                try {
                    iCountTestcases++;
                    serinfo1.AddValue("Boolean_2", fValue);
                    iCountErrors++;
                    Console.WriteLine("Err_1065753cd! Exception not thrown");
                }catch (SerializationException) {
                }catch (Exception ex) {
                    iCountErrors++;
                    Console.WriteLine("Err_5739cd! Wrong exception thrown, " + ex);
                }
                Console.WriteLine("Large String, ticks, " + Environment.TickCount);
                sbldr1 = new StringBuilder("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
                fValue = false;
                serinfo1.AddValue(sbldr1.ToString(), fValue);
                iCountTestcases++;
                if (serinfo1.GetBoolean(sbldr1.ToString()) != fValue)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_6538fvd! wrong value returned, " + serinfo1.GetBoolean(sbldr1.ToString()));
                }
                try {
                    iCountTestcases++;
                    serinfo1.AddValue(null, fValue);
                    iCountErrors++;
                    Console.WriteLine("Err_0156ds! Exception not thrown");
                }catch (ArgumentNullException) {
                }catch (Exception ex) {
                    iCountErrors++;
                    Console.WriteLine("Err_57834fd! Wrong exception thrown, " + ex);
                }
                Console.WriteLine("Char ticks, " + Environment.TickCount);
                rnd1 = new Random();
                for (int i = 0; i < 50; i++)
                {
                    strLoc   = "Loc_6753cd_" + i;
                    chValue  = (Char)(65536 * rnd1.NextDouble());
                    strValue = "Char_" + i;
                    serinfo1.AddValue(strValue, chValue);
                    iCountTestcases++;
                    if (serinfo1.GetChar(strValue) != chValue)
                    {
                        iCountErrors++;
                        Console.WriteLine("Err_65730dsw_" + i + "! Wrong Char returned, " + serinfo1.GetChar(strValue));
                    }
                }
                try {
                    iCountTestcases++;
                    serinfo1.AddValue("Char_1", 'a');
                    iCountErrors++;
                    Console.WriteLine("Err_643cd! Exception not thrown");
                }catch (SerializationException) {
                }catch (Exception ex) {
                    iCountErrors++;
                    Console.WriteLine("Err_02457fd! Wrong exception thrown, " + ex);
                }
                try {
                    iCountTestcases++;
                    serinfo1.AddValue("Boolean_1", 'a');
                    iCountErrors++;
                    Console.WriteLine("Err_5732fcd! Exception not thrown");
                }catch (SerializationException) {
                }catch (Exception ex) {
                    iCountErrors++;
                    Console.WriteLine("Err_024568fd! Wrong exception thrown, " + ex);
                }
                Console.WriteLine("SByte ticks, " + Environment.TickCount);
                for (int i = (int)SByte.MinValue; i < (int)SByte.MaxValue; i++)
                {
                    strLoc   = "Loc_56473vd_" + i;
                    sbtValue = (SByte)i;;
                    strValue = "SByte_" + i;
                    serinfo1.AddValue(strValue, sbtValue);
                    iCountTestcases++;
                    if (serinfo1.GetSByte(strValue) != sbtValue)
                    {
                        iCountErrors++;
                        Console.WriteLine("Err_4627fds_" + i + "! Wrong Sbyte returned, " + serinfo1.GetSByte(strValue));
                    }
                }
                Console.WriteLine("Byte ticks, " + Environment.TickCount);
                for (int i = (int)Byte.MinValue; i < (int)Byte.MaxValue; i++)
                {
                    strLoc   = "Loc_01192ds_" + i;
                    btValue  = (Byte)i;;
                    strValue = "Byte_" + i;
                    serinfo1.AddValue(strValue, btValue);
                    iCountTestcases++;
                    if (serinfo1.GetByte(strValue) != btValue)
                    {
                        iCountErrors++;
                        Console.WriteLine("Err_0267fe_" + i + "! Wrong byte returned, " + serinfo1.GetByte(strValue));
                    }
                }
                Console.WriteLine("Int16 ticks, " + Environment.TickCount);
                for (int i = 0; i < 50; i++)
                {
                    strLoc   = "Loc_012965565ds_" + i;
                    i16Value = (short)((int)Int16.MaxValue * rnd1.NextDouble());
                    if (rnd1.NextDouble() < 0.5)
                    {
                        i16Value = (short)(-1 * i16Value);
                    }
                    strValue = "Int16_" + i;
                    serinfo1.AddValue(strValue, i16Value);
                    iCountTestcases++;
                    if (serinfo1.GetInt16(strValue) != i16Value)
                    {
                        iCountErrors++;
                        Console.WriteLine("Err_0267fe_" + i + "! Wrong value returned, " + serinfo1.GetInt16(strValue));
                    }
                }
                Console.WriteLine("Int32 ticks, " + Environment.TickCount);
                for (int i = 0; i < 50; i++)
                {
                    strLoc   = "Loc_015643ds_" + i;
                    i32Value = (int)(Int32.MaxValue * rnd1.NextDouble());
                    if (rnd1.NextDouble() < 0.5)
                    {
                        i32Value = (-1 * i32Value);
                    }
                    strValue = "Int32_" + i;
                    serinfo1.AddValue(strValue, i32Value);
                    iCountTestcases++;
                    if (serinfo1.GetInt32(strValue) != i32Value)
                    {
                        iCountErrors++;
                        Console.WriteLine("Err_5427ds_" + i + "! Wrong value returned, " + serinfo1.GetInt32(strValue));
                    }
                }
                Console.WriteLine("Int64 ticks, " + Environment.TickCount);
                for (int i = 0; i < 50; i++)
                {
                    strLoc   = "Loc_625bfg_" + i;
                    i64Value = (long)((long)Int64.MaxValue * rnd1.NextDouble());
                    if (rnd1.NextDouble() < 0.5)
                    {
                        i64Value = (long)(-1 * i64Value);
                    }
                    strValue = "Int64_" + i;
                    serinfo1.AddValue(strValue, i64Value);
                    iCountTestcases++;
                    if (serinfo1.GetInt64(strValue) != i64Value)
                    {
                        iCountErrors++;
                        Console.WriteLine("Err_6427dc_" + i + "! Wrong value returned, " + serinfo1.GetInt64(strValue));
                    }
                }
                Console.WriteLine("UInt16 ticks, " + Environment.TickCount);
                for (int i = 0; i < 50; i++)
                {
                    strLoc    = "Loc_6473cd_" + i;
                    ui16Value = (ushort)((int)UInt16.MaxValue * rnd1.NextDouble());
                    strValue  = "UInt16_" + i;
                    serinfo1.AddValue(strValue, ui16Value);
                    iCountTestcases++;
                    if (serinfo1.GetUInt16(strValue) != ui16Value)
                    {
                        iCountErrors++;
                        Console.WriteLine("Err_748vd_" + i + "! Wrong value returned, " + serinfo1.GetUInt16(strValue));
                    }
                }
                Console.WriteLine("UInt32 ticks, " + Environment.TickCount);
                for (int i = 0; i < 50; i++)
                {
                    strLoc    = "Loc_7573cd_" + i;
                    ui32Value = (uint)(UInt32.MaxValue * rnd1.NextDouble());
                    strValue  = "UInt32_" + i;
                    serinfo1.AddValue(strValue, ui32Value);
                    iCountTestcases++;
                    if (serinfo1.GetUInt32(strValue) != ui32Value)
                    {
                        iCountErrors++;
                        Console.WriteLine("Err_4738cd_" + i + "! Wrong value returned, " + serinfo1.GetUInt32(strValue));
                    }
                }
                Console.WriteLine("UInt64 ticks, " + Environment.TickCount);
                for (int i = 0; i < 50; i++)
                {
                    strLoc    = "Loc_63dc_" + i;
                    ui64Value = (ulong)(UInt64.MaxValue * rnd1.NextDouble());
                    strValue  = "UInt64_" + i;
                    serinfo1.AddValue(strValue, ui64Value);
                    iCountTestcases++;
                    if (serinfo1.GetUInt64(strValue) != ui64Value)
                    {
                        iCountErrors++;
                        Console.WriteLine("Err_6583fd_" + i + "! Wrong value returned, " + serinfo1.GetUInt64(strValue));
                    }
                }
                Console.WriteLine("Double ticks, " + Environment.TickCount);
                for (int i = 0; i < 50; i++)
                {
                    strLoc   = "Loc_7539cd_" + i;
                    dblValue = Double.MaxValue * rnd1.NextDouble();
                    if (rnd1.NextDouble() < 0.5)
                    {
                        dblValue = (-1 * dblValue);
                    }
                    strValue = "Double_" + i;
                    serinfo1.AddValue(strValue, dblValue);
                    iCountTestcases++;
                    if (serinfo1.GetDouble(strValue) != dblValue)
                    {
                        iCountErrors++;
                        Console.WriteLine("Err_653cfd_" + i + "! Wrong value returned, " + serinfo1.GetDouble(strValue));
                    }
                }
                Console.WriteLine("Single ticks, " + Environment.TickCount);
                for (int i = 0; i < 50; i++)
                {
                    strLoc   = "Loc_0247fd_" + i;
                    sglValue = (float)(Single.MaxValue * rnd1.NextDouble());
                    if (rnd1.NextDouble() < 0.5)
                    {
                        sglValue = (-1 * sglValue);
                    }
                    strValue = "Single_" + i;
                    serinfo1.AddValue(strValue, sglValue);
                    iCountTestcases++;
                    if (serinfo1.GetSingle(strValue) != sglValue)
                    {
                        iCountErrors++;
                        Console.WriteLine("Err_0468fd_" + i + "! Wrong value returned, " + serinfo1.GetSingle(strValue));
                    }
                }
                strValue = "This is a String";
                serinfo1.AddValue("String_1", strValue);
                iCountTestcases++;
                if (!serinfo1.GetString("String_1").Equals(strValue))
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0945csd! wrong value returned, " + serinfo1.GetString("String_1"));
                }
                strValue = "";
                serinfo1.AddValue("String_2", strValue);
                iCountTestcases++;
                if (!serinfo1.GetString("String_2").Equals(String.Empty))
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0945csd! wrong value returned, " + serinfo1.GetString("String_2"));
                }
                strValue = null;
                serinfo1.AddValue("String_3", strValue);
                iCountTestcases++;
                if (serinfo1.GetString("String_3") != null)
                {
                    iCountErrors++;
                    Console.WriteLine("Err_0945csd! wrong value returned, " + serinfo1.GetString("String_3"));
                }
                try {
                    iCountTestcases++;
                    serinfo1.AddValue("String_2", fValue);
                    iCountErrors++;
                    Console.WriteLine("Err_1065753cd! Exception not thrown");
                }catch (SerializationException) {
                }catch (Exception ex) {
                    iCountErrors++;
                    Console.WriteLine("Err_5739cd! Wrong exception thrown, " + ex);
                }
                Console.WriteLine("Single ticks, " + Environment.TickCount);
                for (int i = 0; i < 50; i++)
                {
                    strLoc   = "Loc_0247fd_" + i;
                    dblValue = (double)(DateTime.MaxValue.ToOADate() * rnd1.NextDouble());
                    strValue = "DateTime_" + i;
                    dtValue  = DateTime.FromOADate(dblValue);
                    serinfo1.AddValue(strValue, dtValue);
                    iCountTestcases++;
                    if (serinfo1.GetDateTime(strValue) != dtValue)
                    {
                        iCountErrors++;
                        Console.WriteLine("Err_0468fd_" + i + "! Wrong value returned, " + serinfo1.GetDateTime(strValue));
                    }
                }
                for (int i = 0; i < 50; i++)
                {
                    strLoc   = "Loc_0247fd_" + i;
                    dcmValue = (Decimal)((double)Decimal.MaxValue * rnd1.NextDouble());
                    if (rnd1.NextDouble() < 0.5)
                    {
                        dcmValue = (Decimal)(-1 * dcmValue);
                    }
                    strValue = "Decimal_" + i;
                    serinfo1.AddValue(strValue, dcmValue);
                    iCountTestcases++;
                    if (serinfo1.GetDecimal(strValue) != dcmValue)
                    {
                        iCountErrors++;
                        Console.WriteLine("Err_2342fdsg_" + i + "! Wrong value returned, " + serinfo1.GetDecimal(strValue));
                    }
                }
            } while (false);
        } catch (Exception exc_general) {
            ++iCountErrors;
            Console.WriteLine(s_strTFAbbrev + " : Error Err_8888yyy!  strLoc==" + strLoc + ", exc_general==\n" + exc_general.StackTrace);
        }
        if (iCountErrors == 0)
        {
            Console.WriteLine("paSs.   " + s_strTFPath + " " + s_strTFName + " ,iCountTestcases==" + iCountTestcases.ToString());
            return(true);
        }
        else
        {
            Console.WriteLine("FAiL!   " + s_strTFPath + " " + s_strTFName + " ,iCountErrors==" + iCountErrors.ToString() + " , BugNums?: " + s_strActiveBugNums);
            return(false);
        }
    }
Example #11
0
	public bool runTest()
	{
		Console.WriteLine(s_strTFPath + " " + s_strTFName + " , for " + s_strClassMethod + " , Source ver : " + s_strDtTmVer);
		int iCountErrors = 0;
		int iCountTestcases = 0;
		String strLoc = "Loc_000oo";
		SerializationInfo serinfo1 = null;
		Boolean fValue;
		Char chValue;
		SByte sbtValue;
		Byte btValue;
		Int16 i16Value;
		Int32 i32Value;
		Int64 i64Value;
		UInt16 ui16Value;
		UInt32 ui32Value;
		UInt64 ui64Value;
		Double dblValue;
		Single sglValue;
		DateTime dtValue;
		Decimal dcmValue;
		StringBuilder sbldr1;
		String strValue;
		Random rnd1;
		try {
			do
			{
				strLoc="Loc_6573cd";
				serinfo1 = new SerializationInfo(typeof(Int32), new FormatterConverter());
				iCountTestcases++;
				if(serinfo1.MemberCount != 0)
				{
					iCountErrors++;
					Console.WriteLine("Err_0246sd! Wrong number of members, " + serinfo1.MemberCount.ToString());
				}
				strLoc="Loc_6853vd";
				fValue = false;
				serinfo1.AddValue("Boolean_1", fValue);
				iCountTestcases++;
				if(serinfo1.GetBoolean("Boolean_1") != fValue)
				{
					iCountErrors++;
					Console.WriteLine("Err_0945csd! wrong value returned, " + serinfo1.GetBoolean("Boolean_1"));
				}
				fValue = true;
				serinfo1.AddValue("Boolean_2", fValue);
				iCountTestcases++;
				if(serinfo1.GetBoolean("Boolean_2") != fValue)
				{
					iCountErrors++;
					Console.WriteLine("Err_6753vd! wrong value returned, " + serinfo1.GetBoolean("Boolean_2"));
				}
				try {
					iCountTestcases++;
					serinfo1.AddValue("Boolean_2", fValue);
					iCountErrors++;
					Console.WriteLine("Err_1065753cd! Exception not thrown");
					}catch(SerializationException){
					}catch(Exception ex){
					iCountErrors++;
					Console.WriteLine("Err_5739cd! Wrong exception thrown, " + ex);
				}
				Console.WriteLine("Large String, ticks, " + Environment.TickCount);
				sbldr1 = new StringBuilder("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
				fValue = false;
				serinfo1.AddValue(sbldr1.ToString(), fValue);
				iCountTestcases++;
				if(serinfo1.GetBoolean(sbldr1.ToString()) != fValue)
				{
					iCountErrors++;
					Console.WriteLine("Err_6538fvd! wrong value returned, " + serinfo1.GetBoolean(sbldr1.ToString()));
				}
				try {
					iCountTestcases++;
					serinfo1.AddValue(null, fValue);
					iCountErrors++;
					Console.WriteLine("Err_0156ds! Exception not thrown");
					}catch(ArgumentNullException){
					}catch(Exception ex){
					iCountErrors++;
					Console.WriteLine("Err_57834fd! Wrong exception thrown, " + ex);
				}
				Console.WriteLine("Char ticks, " + Environment.TickCount);
				rnd1 = new Random();
				for(int i=0; i<50; i++) {
					strLoc="Loc_6753cd_" + i;
					chValue = (Char)(65536 * rnd1.NextDouble());
					strValue = "Char_" + i;
					serinfo1.AddValue(strValue, chValue);
					iCountTestcases++;
					if(serinfo1.GetChar(strValue)!= chValue)
					{
						iCountErrors++;
						Console.WriteLine("Err_65730dsw_" + i + "! Wrong Char returned, " + serinfo1.GetChar(strValue));
					}
				}
				try {
					iCountTestcases++;
					serinfo1.AddValue("Char_1", 'a');
					iCountErrors++;
					Console.WriteLine("Err_643cd! Exception not thrown");
					}catch(SerializationException){
					}catch(Exception ex){
					iCountErrors++;
					Console.WriteLine("Err_02457fd! Wrong exception thrown, " + ex);
				}
				try {
					iCountTestcases++;
					serinfo1.AddValue("Boolean_1", 'a');
					iCountErrors++;
					Console.WriteLine("Err_5732fcd! Exception not thrown");
					}catch(SerializationException){
					}catch(Exception ex){
					iCountErrors++;
					Console.WriteLine("Err_024568fd! Wrong exception thrown, " + ex);
				}
				Console.WriteLine("SByte ticks, " + Environment.TickCount);
				for(int i=(int)SByte.MinValue; i<(int)SByte.MaxValue; i++) {
					strLoc="Loc_56473vd_" + i;
					sbtValue = (SByte)i;;
					strValue = "SByte_" + i;
					serinfo1.AddValue(strValue, sbtValue);
					iCountTestcases++;
					if(serinfo1.GetSByte(strValue)!= sbtValue)
					{
						iCountErrors++;
						Console.WriteLine("Err_4627fds_" + i + "! Wrong Sbyte returned, " + serinfo1.GetSByte(strValue));
					}
				}
				Console.WriteLine("Byte ticks, " + Environment.TickCount);
				for(int i=(int)Byte.MinValue; i<(int)Byte.MaxValue; i++) {
					strLoc="Loc_01192ds_" + i;
					btValue = (Byte)i;;
					strValue = "Byte_" + i;
					serinfo1.AddValue(strValue, btValue);
					iCountTestcases++;
					if(serinfo1.GetByte(strValue)!= btValue)
					{
						iCountErrors++;
						Console.WriteLine("Err_0267fe_" + i + "! Wrong byte returned, " + serinfo1.GetByte(strValue));
					}
				}
				Console.WriteLine("Int16 ticks, " + Environment.TickCount);
				for(int i=0; i<50; i++) {
					strLoc="Loc_012965565ds_" + i;
					i16Value = (short)((int)Int16.MaxValue * rnd1.NextDouble());
					if(rnd1.NextDouble()<0.5)
					i16Value = (short)(-1 * i16Value);
					strValue = "Int16_" + i;
					serinfo1.AddValue(strValue, i16Value);
					iCountTestcases++;
					if(serinfo1.GetInt16(strValue)!= i16Value)
					{
						iCountErrors++;
						Console.WriteLine("Err_0267fe_" + i + "! Wrong value returned, " + serinfo1.GetInt16(strValue));
					}
				}
				Console.WriteLine("Int32 ticks, " + Environment.TickCount);
				for(int i=0; i<50; i++) {
					strLoc="Loc_015643ds_" + i;
					i32Value = (int)(Int32.MaxValue * rnd1.NextDouble());
					if(rnd1.NextDouble()<0.5)
					i32Value = (-1 * i32Value);
					strValue = "Int32_" + i;
					serinfo1.AddValue(strValue, i32Value);
					iCountTestcases++;
					if(serinfo1.GetInt32(strValue)!= i32Value)
					{
						iCountErrors++;
						Console.WriteLine("Err_5427ds_" + i + "! Wrong value returned, " + serinfo1.GetInt32(strValue));
					}
				}
				Console.WriteLine("Int64 ticks, " + Environment.TickCount);
				for(int i=0; i<50; i++) {
					strLoc="Loc_625bfg_" + i;
					i64Value = (long)((long)Int64.MaxValue * rnd1.NextDouble());
					if(rnd1.NextDouble()<0.5)
					i64Value = (long)(-1 * i64Value);
					strValue = "Int64_" + i;
					serinfo1.AddValue(strValue, i64Value);
					iCountTestcases++;
					if(serinfo1.GetInt64(strValue)!= i64Value)
					{
						iCountErrors++;
						Console.WriteLine("Err_6427dc_" + i + "! Wrong value returned, " + serinfo1.GetInt64(strValue));
					}
				}
				Console.WriteLine("UInt16 ticks, " + Environment.TickCount);
				for(int i=0; i<50; i++) {
					strLoc="Loc_6473cd_" + i;
					ui16Value = (ushort)((int)UInt16.MaxValue * rnd1.NextDouble());
					strValue = "UInt16_" + i;
					serinfo1.AddValue(strValue, ui16Value);
					iCountTestcases++;
					if(serinfo1.GetUInt16(strValue)!= ui16Value)
					{
						iCountErrors++;
						Console.WriteLine("Err_748vd_" + i + "! Wrong value returned, " + serinfo1.GetUInt16(strValue));
					}
				}
				Console.WriteLine("UInt32 ticks, " + Environment.TickCount);
				for(int i=0; i<50; i++) {
					strLoc="Loc_7573cd_" + i;
					ui32Value = (uint)(UInt32.MaxValue * rnd1.NextDouble());
					strValue = "UInt32_" + i;
					serinfo1.AddValue(strValue, ui32Value);
					iCountTestcases++;
					if(serinfo1.GetUInt32(strValue)!= ui32Value)
					{
						iCountErrors++;
						Console.WriteLine("Err_4738cd_" + i + "! Wrong value returned, " + serinfo1.GetUInt32(strValue));
					}
				}
				Console.WriteLine("UInt64 ticks, " + Environment.TickCount);
				for(int i=0; i<50; i++) {
					strLoc="Loc_63dc_" + i;
					ui64Value = (ulong)(UInt64.MaxValue * rnd1.NextDouble());
					strValue = "UInt64_" + i;
					serinfo1.AddValue(strValue, ui64Value);
					iCountTestcases++;
					if(serinfo1.GetUInt64(strValue)!= ui64Value)
					{
						iCountErrors++;
						Console.WriteLine("Err_6583fd_" + i + "! Wrong value returned, " + serinfo1.GetUInt64(strValue));
					}
				}
				Console.WriteLine("Double ticks, " + Environment.TickCount);
				for(int i=0; i<50; i++) {
					strLoc="Loc_7539cd_" + i;
					dblValue = Double.MaxValue * rnd1.NextDouble();
					if(rnd1.NextDouble()<0.5)
					dblValue = (-1 * dblValue);
					strValue = "Double_" + i;
					serinfo1.AddValue(strValue, dblValue);
					iCountTestcases++;
					if(serinfo1.GetDouble(strValue)!= dblValue)
					{
						iCountErrors++;
						Console.WriteLine("Err_653cfd_" + i + "! Wrong value returned, " + serinfo1.GetDouble(strValue));
					}
				}
				Console.WriteLine("Single ticks, " + Environment.TickCount);
				for(int i=0; i<50; i++) {
					strLoc="Loc_0247fd_" + i;
					sglValue = (float)(Single.MaxValue * rnd1.NextDouble());
					if(rnd1.NextDouble()<0.5)
					sglValue = (-1 * sglValue);
					strValue = "Single_" + i;
					serinfo1.AddValue(strValue, sglValue);
					iCountTestcases++;
					if(serinfo1.GetSingle(strValue)!= sglValue)
					{
						iCountErrors++;
						Console.WriteLine("Err_0468fd_" + i + "! Wrong value returned, " + serinfo1.GetSingle(strValue));
					}
				}
				strValue = "This is a String";
				serinfo1.AddValue("String_1", strValue);
				iCountTestcases++;
				if(!serinfo1.GetString("String_1").Equals(strValue))
				{
					iCountErrors++;
					Console.WriteLine("Err_0945csd! wrong value returned, " + serinfo1.GetString("String_1"));
				}
				strValue = "";
				serinfo1.AddValue("String_2", strValue);
				iCountTestcases++;
				if(!serinfo1.GetString("String_2").Equals(String.Empty))
				{
					iCountErrors++;
					Console.WriteLine("Err_0945csd! wrong value returned, " + serinfo1.GetString("String_2"));
				}
				strValue = null;
				serinfo1.AddValue("String_3", strValue);
				iCountTestcases++;
				if(serinfo1.GetString("String_3") != null)
				{
					iCountErrors++;
					Console.WriteLine("Err_0945csd! wrong value returned, " + serinfo1.GetString("String_3"));
				}
				try {
					iCountTestcases++;
					serinfo1.AddValue("String_2", fValue);
					iCountErrors++;
					Console.WriteLine("Err_1065753cd! Exception not thrown");
					}catch(SerializationException){
					}catch(Exception ex){
					iCountErrors++;
					Console.WriteLine("Err_5739cd! Wrong exception thrown, " + ex);
				}
				Console.WriteLine("Single ticks, " + Environment.TickCount);
				for(int i=0; i<50; i++) {
					strLoc="Loc_0247fd_" + i;
					dblValue = (double)(DateTime.MaxValue.ToOADate() * rnd1.NextDouble());
					strValue = "DateTime_" + i;
					dtValue = DateTime.FromOADate(dblValue);
					serinfo1.AddValue(strValue, dtValue);
					iCountTestcases++;
					if(serinfo1.GetDateTime(strValue)!= dtValue)
					{
						iCountErrors++;
						Console.WriteLine("Err_0468fd_" + i + "! Wrong value returned, " + serinfo1.GetDateTime(strValue));
					}
				}
				for(int i=0; i<50; i++) {
					strLoc="Loc_0247fd_" + i;
					dcmValue = (Decimal)((double)Decimal.MaxValue * rnd1.NextDouble());
					if(rnd1.NextDouble()<0.5)
						dcmValue = (Decimal)(-1 * dcmValue);
					strValue = "Decimal_" + i;
					serinfo1.AddValue(strValue, dcmValue);
					iCountTestcases++;
					if(serinfo1.GetDecimal(strValue)!= dcmValue)
					{
						iCountErrors++;
						Console.WriteLine("Err_2342fdsg_" + i + "! Wrong value returned, " + serinfo1.GetDecimal(strValue));
					}
				}
			} while (false);
			} catch (Exception exc_general ) {
			++iCountErrors;
			Console.WriteLine (s_strTFAbbrev + " : Error Err_8888yyy!  strLoc=="+ strLoc +", exc_general==\n"+exc_general.StackTrace);
		}
		if ( iCountErrors == 0 )
		{
			Console.WriteLine( "paSs.   "+s_strTFPath +" "+s_strTFName+" ,iCountTestcases=="+iCountTestcases.ToString());
			return true;
		}
		else
		{
			Console.WriteLine("FAiL!   "+s_strTFPath+" "+s_strTFName+" ,iCountErrors=="+iCountErrors.ToString()+" , BugNums?: "+s_strActiveBugNums );
			return false;
		}
	}
Example #12
0
 /// <summary>
 /// Initializes a new instance of this Exception Class with serialized data. Needed for Remoting and general serialization.
 /// </summary>
 /// <remarks>
 /// Only to be used by the .NET Serialization system (eg within .NET Remoting).
 /// </remarks>
 /// <param name="AInfo">The <see cref="SerializationInfo" /> that holds the serialized object data about the <see cref="Exception" /> being thrown.</param>
 /// <param name="AContext">The <see cref="StreamingContext" /> that contains contextual information about the source or destination.</param>
 public ESmtpSenderInitializeException(SerializationInfo AInfo, StreamingContext AContext) : base(AInfo, AContext)
 {
     //FErrorClass = (TSmtpErrorClassEnum)AInfo.GetValue("ErrorClass", typeof(TSmtpErrorClassEnum));
     ErrorClass = (TSmtpErrorClassEnum)AInfo.GetSByte("ErrorClass");
 }
Example #13
0
 /// <summary>
 /// This constructor is used for serialization
 /// </summary>
 /// <param name="info"></param>
 /// <param name="text"></param>
 public ThreeState(SerializationInfo info, StreamingContext context)
     : this()
 {
     Value = info.GetSByte("Value");
 }