コード例 #1
0
        public void BenchmarkSetup()
        {
            this.InitializeSerializer(this.Serializer);

            this.complexClass                  = OuterClass.GetPrivateClassInstance();
            this.complexClass.Int              = 89;
            this.complexClass.String           = Guid.NewGuid().ToString();
            this.complexClass.NonSerializedInt = 39;
            var classes = new List <SomeAbstractClass>
            {
                this.complexClass,
                new AnotherConcreteClass
                {
                    AnotherString = "hi",
                    Interfaces    = new List <ISomeInterface>
                    {
                        this.complexClass
                    }
                },
                new AnotherConcreteClass(),
                OuterClass.GetPrivateClassInstance()
            };

            this.complexClass.Classes = classes.ToArray();
            this.complexClass.Enum    = SomeAbstractClass.SomeEnum.Something;
            this.complexClass.SetObsoleteInt(38);

            this.complexClass.Struct = new SomeStruct(10)
            {
                Id                     = Guid.NewGuid(),
                PublicValue            = 6,
                ValueWithPrivateGetter = 7
            };
            this.complexClass.Struct.SetValueWithPrivateSetter(8);
            this.complexClass.Struct.SetPrivateValue(9);


            this.largeTestData = new LargeTestData
            {
                Description = "This is a test. This is only a test. In the event of a real execution, this would contain actual data.",
                EnumValue   = TestEnum.First
            };
            this.largeTestData.SetBit(13);
            this.largeTestData.SetEnemy(17, CampaignEnemyTestType.Enemy1);

            this.serializedBytes = this.serializationManager.SerializeToByteArray(this.largeTestData);
        }
コード例 #2
0
ファイル: SerializationTests.cs プロジェクト: jdom/orleans
        public void Serialization_LargeTestData()
        {
            var data = new LargeTestData
                           {
                               Description =
                                   "This is a test. This is only a test. In the event of a real execution, this would contain actual data.",
                               EnumValue = TestEnum.First
                           };
            data.SetBit(13);
            data.SetEnemy(17, CampaignEnemyTestType.Enemy1);

            object obj = SerializationManager.DeepCopy(data);
            Assert.IsAssignableFrom<LargeTestData>(obj);

            object copy = SerializationManager.RoundTripSerializationForTesting(obj);
            Assert.IsAssignableFrom<LargeTestData>(copy);
        }
コード例 #3
0
        public void Serialization_LargeTestData()
        {
            var data = new LargeTestData
                           {
                               Description =
                                   "This is a test. This is only a test. In the event of a real execution, this would contain actual data.",
                               EnumValue = TestEnum.First
                           };
            data.SetBit(13);
            data.SetEnemy(17, CampaignEnemyTestType.Enemy1);

            object obj = SerializationManager.DeepCopy(data);
            Assert.IsInstanceOfType(obj, typeof(LargeTestData), "Copied result is of wrong type");

            object copy = SerializationManager.RoundTripSerializationForTesting(obj);
            Assert.IsInstanceOfType(copy, typeof(LargeTestData), "Deserialized result is of wrong type");
        }
コード例 #4
0
        public void Serialization_LargeTestData()
        {
            var data = new LargeTestData
            {
                Description =
                    "This is a test. This is only a test. In the event of a real execution, this would contain actual data.",
                EnumValue = TestEnum.First
            };

            data.SetBit(13);
            data.SetEnemy(17, CampaignEnemyTestType.Enemy1);

            object obj = SerializationManager.DeepCopy(data);

            Assert.IsInstanceOfType(obj, typeof(LargeTestData), "Copied result is of wrong type");

            object copy = SerializationManager.RoundTripSerializationForTesting(obj);

            Assert.IsInstanceOfType(copy, typeof(LargeTestData), "Deserialized result is of wrong type");
        }
コード例 #5
0
        public void Serialization_LargeTestData()
        {
            var data = new LargeTestData
            {
                Description =
                    "This is a test. This is only a test. In the event of a real execution, this would contain actual data.",
                EnumValue = TestEnum.First
            };

            data.SetBit(13);
            data.SetEnemy(17, CampaignEnemyTestType.Enemy1);

            object obj = SerializationManager.DeepCopy(data);

            Assert.IsAssignableFrom <LargeTestData>(obj);

            object copy = SerializationManager.RoundTripSerializationForTesting(obj);

            Assert.IsAssignableFrom <LargeTestData>(copy);
        }
コード例 #6
0
 public void DeepCopyTests_UserDefinedType()
 {
     {
         var original = new LargeTestData();
         original.SetNumber("a", 1);
         original.SetNumber("b", 2);
         original.SetEnemy(0, CampaignEnemyTestType.Enemy3);
         original.SetBit(19);
         var copy = (LargeTestData)this.fixture.SerializationManager.DeepCopy(original);
         Assert.Equal(1, copy.GetNumber("a"));
         Assert.Equal(2, copy.GetNumber("b"));
         Assert.Equal(CampaignEnemyTestType.Enemy3, copy.GetEnemy(0));
         Assert.True(copy.GetBit(19));
         // change copy
         copy.SetNumber("b", 0);
         copy.SetEnemy(0, CampaignEnemyTestType.Brute);
         copy.SetBit(19, false);
         // original must be unchanged
         Assert.Equal(2, original.GetNumber("b"));
         Assert.Equal(CampaignEnemyTestType.Enemy3, original.GetEnemy(0));
         Assert.True(original.GetBit(19));
     }
 }
コード例 #7
0
ファイル: DeepCopyTests.cs プロジェクト: MikeHardman/orleans
 public void DeepCopyTests_UserDefinedType()
 {
     {
         var original = new LargeTestData();
         original.SetNumber("a", 1);
         original.SetNumber("b", 2);
         original.SetEnemy(0, CampaignEnemyTestType.Enemy3);
         original.SetBit(19);
         var copy = (LargeTestData)SerializationManager.DeepCopy(original);
         Assert.Equal(1, copy.GetNumber("a"));
         Assert.Equal(2, copy.GetNumber("b"));
         Assert.Equal(CampaignEnemyTestType.Enemy3, copy.GetEnemy(0));
         Assert.Equal(true, copy.GetBit(19));
         // change copy
         copy.SetNumber("b", 0);
         copy.SetEnemy(0, CampaignEnemyTestType.Brute);
         copy.SetBit(19, false);
         // original must be unchanged
         Assert.Equal(2, original.GetNumber("b"));
         Assert.Equal(CampaignEnemyTestType.Enemy3, original.GetEnemy(0));
         Assert.Equal(true, original.GetBit(19));
     }
 }
コード例 #8
0
        public void BenchmarkSetup()
        {
            this.InitializeSerializer(this.Serializer);

            this.complexClass = OuterClass.GetPrivateClassInstance();
            this.complexClass.Int = 89;
            this.complexClass.String = Guid.NewGuid().ToString();
            this.complexClass.NonSerializedInt = 39;
            var classes = new List<SomeAbstractClass>
            {
                this.complexClass,
                new AnotherConcreteClass
                {
                    AnotherString = "hi",
                    Interfaces = new List<ISomeInterface>
                    {
                        this.complexClass
                    }
                },
                new AnotherConcreteClass(),
                OuterClass.GetPrivateClassInstance()
            };
            
            this.complexClass.Classes = classes.ToArray();
            this.complexClass.Enum = SomeAbstractClass.SomeEnum.Something;
            this.complexClass.SetObsoleteInt(38);

            this.complexClass.Struct = new SomeStruct(10)
            {
                Id = Guid.NewGuid(),
                PublicValue = 6,
                ValueWithPrivateGetter = 7
            };
            this.complexClass.Struct.SetValueWithPrivateSetter(8);
            this.complexClass.Struct.SetPrivateValue(9);


            this.largeTestData = new LargeTestData
            {
                Description = "This is a test. This is only a test. In the event of a real execution, this would contain actual data.",
                EnumValue = TestEnum.First
            };
            largeTestData.SetBit(13);
            largeTestData.SetEnemy(17, CampaignEnemyTestType.Enemy1);

            this.serializedBytes = SerializationManager.SerializeToByteArray(this.largeTestData);
        }