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); }
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); }
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"); }
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); }
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)); } }
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)); } }
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); }