public void PartsWithTheSameLevelAndPositionShouldRemainInTheOriginalAddedOrder()
        {

            var mappingTester = new MappingTester<MappedObject>().ForMapping(mappedObject =>
            {
                mappedObject.Id(x => x.Id);//First
                mappedObject.Map(x => x.NullableColor);//Anywhere
                mappedObject.Map(x => x.Version);//Anywhere
                mappedObject.Map(x => x.Id);//Anywhere
                mappedObject.Map(x => x.NickName);//Anywhere
                mappedObject.Map(x => x.Name);//Anywhere
                mappedObject.Map(x => x.Color);//Anywhere
                mappedObject.DiscriminateSubClassesOnColumn<string>("Type").SubClass<SecondMappedObject>(sc => sc.Map(x => x.Name)); //Last
            });

            mappingTester
                //Element 0 is id
                //Element 1 is discriminator
                .Element("class/property[@name='NullableColor']").ShouldBeInParentAtPosition(2)
                .Element("class/property[@name='Version']").ShouldBeInParentAtPosition(3)
                .Element("class/property[@name='Id']").ShouldBeInParentAtPosition(4)
                .Element("class/property[@name='NickName']").ShouldBeInParentAtPosition(5)
                .Element("class/property[@name='Name']").ShouldBeInParentAtPosition(6)
                .Element("class/property[@name='Color']").ShouldBeInParentAtPosition(7);
                //Element 8 is subclass
        }
 public void Applying_a_generic_child_filter_to_a_many_to_many()
 {
     MappingTester<ManyToManyTarget> mapping = new MappingTester<ManyToManyTarget>()
         .ForMapping(m => m.HasManyToMany(x => x.BagOfChildren)
             .ApplyChildFilter<TestFilter>("Name = :name"));
     mapping
         .Element("class/bag/many-to-many/filter")
         .HasAttribute("name", "test")
         .HasAttribute("condition", "Name = :name");
 }
        public void PartsAreOrderedByPositionAndLevelRegardlessOfDeclaredOrder()
        {
            var mappingTester = new MappingTester<MappedObject>().ForMapping(mappedObject =>
            {
                mappedObject.HasMany(x => x.Children).AsBag();
                mappedObject.Version(x => x.Version);
                mappedObject.Id(x => x.Id);
            });

            mappingTester
                .Element("class/id").ShouldBeInParentAtPosition(0)
                .Element("class/version").ShouldBeInParentAtPosition(1)
                .Element("class/bag").ShouldBeInParentAtPosition(2);
        }
        public void AnyIsAfterIdElement()
        {
            var mapTest = new MappingTester<MappedObject>()
                .ForMapping(map =>
                                {
                                    map.Id(x => x.Id);
                                    map.ReferencesAny(x => x.Parent)
                                        .EntityIdentifierColumn("AnyId")
                                        .EntityTypeColumn("AnyType")
                                        .IdentityType(x => x.Id)
                                        .AddMetaValue<SecondMappedObject>("SMO");
                                });

            mapTest.Element("class/id").ShouldBeInParentAtPosition(0);
        }
        public void PartsWithSamePositionAreOrderedByLevel()
        {
            var mappingTester = new MappingTester<MappedObject>().ForMapping(mappedObject =>
            {
                mappedObject.Version(x => x.Version); //Level 4
                mappedObject.DiscriminateSubClassesOnColumn<string>("Type").SubClass<SecondMappedObject>(sc => sc.Map(x => x.Name)); //Level 3
                mappedObject.Id(x => x.Id); //Level 2
                mappedObject.Cache.ReadWrite(); //Level 1
            });

            mappingTester
                .Element("class/cache").ShouldBeInParentAtPosition(0)
                .Element("class/id").ShouldBeInParentAtPosition(1)
                .Element("class/discriminator").ShouldBeInParentAtPosition(2)
                .Element("class/version").ShouldBeInParentAtPosition(3);
        }
        public void PartsAreOrderedByPosition()
        {
            var mappingTester = new MappingTester<MappedObject>().ForMapping(mappedObject =>
            {
                mappedObject.DiscriminateSubClassesOnColumn<string>("Type").SubClass<SecondMappedObject>(sc => sc.Map(x => x.Name)); //Last
                mappedObject.Id(x => x.Id); //First
                mappedObject.HasMany(x => x.Children).AsBag(); //Anywhere

            });

            mappingTester
                .Element("class/id").ShouldBeInParentAtPosition(0)
                .Element("class/discriminator").ShouldBeInParentAtPosition(1) //created due to subclassing
                .Element("class/bag").ShouldBeInParentAtPosition(2)
                .Element("class/subclass").ShouldBeInParentAtPosition(3);
        }
Exemple #7
0
 private void A_list_property_difference(MappingTester<OutputListClass> obj)
 {
     _context.Destination = new OutputListClass
         {
             Items = new List<int>
                 {
                     4,
                     5,
                     6
                 }
         };
     _context.Expected = new OutputListClass
         {
             Items = new List<int>
                 {
                     4,
                     5,
                     6,
                     7
                 }
         };
     _expectedDifferenceMessage = "Items";
 }
Exemple #8
0
 private static void Not_change_the_destination_object(SimpleMapper obj, LowerCaseContext context)
 {
     var result = new MappingTester<OutputClassLowerCase>().Verify(context.Destination, context.Expected);
     result.IsValid.ShouldBeTrue(result.ToString());
 }
Exemple #9
0
 private static void Map_the_property_values(SourceContext context)
 {
     var result = new MappingTester<OutputClass>().Verify(context.Destination, context.Expected);
     result.IsValid.ShouldBeTrue(result.ToString());
 }
Exemple #10
0
 private static void Map_the_property_values(DynamicDestinationContext context)
 {
     var result = new MappingTester<object>().Verify(context.Destination, context.Expected);
     result.IsValid.ShouldBeTrue(result.ToString());
 }
Exemple #11
0
 private void Verify_is_called(MappingTester<OutputListClass> obj)
 {
     _notification = obj.Verify(_context.Destination, _context.Expected);
 }
Exemple #12
0
 private void A_string_property_difference(MappingTester<OutputClass> obj)
 {
     var source = new ClassFiller<InputClass>().Source;
     _context.Expected = new OutputClass
         {
             BooleanProperty = source.BooleanProperty,
             IntegerProperty = source.IntegerProperty,
             StringProperty = source.StringProperty,
             DecimalProperty = source.DecimalProperty,
             DateTimeProperty = source.DateTimeProperty
         };
     _context.Destination = new OutputClass
         {
             BooleanProperty = _context.Expected.BooleanProperty,
             StringProperty = _context.Expected.StringProperty.ToUpper(),
             DecimalProperty = _context.Expected.DecimalProperty,
             DateTimeProperty = _context.Expected.DateTimeProperty,
             IntegerProperty = _context.Expected.IntegerProperty
         };
     _expectedDifferenceMessage = "StringProperty";
 }
Exemple #13
0
 private void A_list_property_difference(MappingTester<OutputListClassWithoutSetter> obj)
 {
     var destinationItems = new List<int>
         {
             4,
             5,
             6
         };
     _context.Destination = new OutputListClassWithoutSetter(destinationItems);
     var expectedItems = new List<int>
         {
             4,
             5,
             6,
             7
         };
     _context.Expected = new OutputListClassWithoutSetter(expectedItems);
     _expectedDifferenceMessage = "Items";
 }
Exemple #14
0
 private void Map_the_property_values(InputClass source)
 {
     var tester = new MappingTester<OutputClass>();
     var result = tester.Verify(_destination, _expected);
     result.IsValid.ShouldBeTrue();
     result.ToString().ShouldBeEqualTo("");
 }
        public void SpecificMetaTypeShouldNotClearMetaValues()
        {
            var mapTest = new MappingTester<MappedObject>()
                .ForMapping(map =>
                {
                    map.Id(x => x.Id);
                    map.ReferencesAny(x => x.Parent)
                        .EntityIdentifierColumn("AnyId")
                        .EntityTypeColumn("AnyType")
                        .IdentityType(x => x.Id)
                        .MetaType<int>()
                        .AddMetaValue<SecondMappedObject>("1");
                });

            mapTest
                .Element("class/any/meta-value")
                .HasAttribute("value", "1")
                .HasAttribute("class", typeof(SecondMappedObject).AssemblyQualifiedName);
        }