System.Collections.Generic.List.Adapt()

Here are the examples of the csharp api class System.Collections.Generic.List.Adapt() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1 Example 7

1. Example

View license
[TestMethod]
        public void Map_Including_Derived_Class_With_List()
        {
            TypeAdapterConfig<Vehicle, VehicleDto>.NewConfig()
                .Include<Car, CarDto>()
                .Include<Bike, BikeDto>()
                .Compile();

            var vehicles = new List<Vehicle>
            {
                new Car {Id = 1, Name = "Car", Make = "Toyota", ChassiNumber = "XXX"},
                new Bike {Id = 2, Name = "Bike", Brand = "BMX"},
            };
            var dto = vehicles.Adapt<List<Vehicle>, IList<VehicleDto>>();

            ((CarDto)dto[0]).Make.ShouldBe("Toyota");
            ((BikeDto)dto[1]).Brand.ShouldBe("BMX");
        }