public void ConfigurePropertyAsAttribute() { var configuration = Configure(cfg => { cfg.ConfigureType <SimpleTestSubject>().Member(p => p.BasicProperty).Attribute(); }); var member = configuration.GetTypeConfiguration(typeof(SimpleTestSubject)) .Member(nameof(SimpleTestSubject.BasicProperty)); Assert.True(configuration.Root.With <MemberFormatExtension>().Registered.Contains(((ISource <MemberInfo>)member).Get())); var instance = new SimpleTestSubject { BasicProperty = "Hello World as Attribute!" }; new SerializationSupport(configuration).Assert(instance, @"<?xml version=""1.0"" encoding=""utf-8""?><ConfigurationContainerTests-SimpleTestSubject BasicProperty=""Hello World as Attribute!"" xmlns=""clr-namespace:ExtendedXmlSerializer.Tests.Configuration;assembly=ExtendedXmlSerializer.Tests"" />"); }
public void ConfigureNameForProperty() { var configuration = Configure(cfg => cfg.ConfigureType <SimpleTestSubject>().Member(p => p.BasicProperty).Name(MemberName)); var member = configuration.GetTypeConfiguration(typeof(SimpleTestSubject)).Member(nameof(SimpleTestSubject.BasicProperty)); Assert.Equal(configuration.Root.Find <MemberPropertiesExtension>().Names[((ISource <MemberInfo>)member).Get()], MemberName); var support = new SerializationSupport(configuration); var instance = new SimpleTestSubject { BasicProperty = "Hello World! Testing Member." }; support.Assert(instance, @"<?xml version=""1.0"" encoding=""utf-8""?><ConfigurationContainerTests-SimpleTestSubject xmlns=""clr-namespace:ExtendedXmlSerializer.Tests.Configuration;assembly=ExtendedXmlSerializer.Tests""><UpdatedMemberName>Hello World! Testing Member.</UpdatedMemberName></ConfigurationContainerTests-SimpleTestSubject>"); }
public void ConfigureNameForType() { var configuration = new ConfigurationContainer(); configuration.Type <SimpleTestSubject>().Name(Testclass); var names = configuration.Root.Find <TypeNamesExtension>() .Names; Assert.Equal(names[typeof(SimpleTestSubject).GetTypeInfo()], Testclass); Assert.False(names.ContainsKey(typeof(TestClassPrimitiveTypesNullable).GetTypeInfo())); var support = new SerializationSupport(configuration); var expected = new SimpleTestSubject { BasicProperty = "Hello World!" }; var actual = support.Assert(expected, @"<?xml version=""1.0"" encoding=""utf-8""?><UpdatedTestClassName xmlns=""clr-namespace:ExtendedXmlSerializer.Tests.Configuration;assembly=ExtendedXmlSerializer.Tests""><BasicProperty>Hello World!</BasicProperty></UpdatedTestClassName>"); Assert.Equal(expected.BasicProperty, actual.BasicProperty); }