public void Does_convert_models_with_collections() { var from = new ModelWithEnumerable { Collection = new[] { new User { FirstName = "First1", LastName = "Last1", Car = new Car { Name = "Car1", Age = 1 } }, new User { FirstName = "First2", LastName = "Last2", Car = new Car { Name = "Car2", Age = 2 } }, } }; Assert.That(MatchesUsers(from.Collection, from.ConvertTo <ModelWithEnumerable>().Collection)); Assert.That(MatchesUsers(from.Collection, from.ConvertTo <ModelWithList>().Collection)); Assert.That(MatchesUsers(from.Collection, from.ConvertTo <ModelWithArray>().Collection)); Assert.That(MatchesUsers(from.Collection, from.ConvertTo <ModelWithHashSet>().Collection)); Assert.That(MatchesUsers(from.Collection, from.Collection.ConvertTo <IEnumerable <User> >())); Assert.That(MatchesUsers(from.Collection, from.Collection.ConvertTo <List <User> >())); Assert.That(MatchesUsers(from.Collection, from.Collection.ConvertTo <User[]>())); Assert.That(MatchesUsers(from.Collection, from.Collection.ConvertTo <HashSet <User> >())); var array = from.Collection.ToArray(); Assert.That(MatchesUsers(array, from.Collection.ConvertTo <IEnumerable <User> >())); Assert.That(MatchesUsers(array, from.Collection.ConvertTo <List <User> >())); Assert.That(MatchesUsers(array, from.Collection.ConvertTo <User[]>())); Assert.That(MatchesUsers(array, from.Collection.ConvertTo <HashSet <User> >())); var hashset = from.Collection.ToHashSet(); Assert.That(MatchesUsers(hashset, from.Collection.ConvertTo <IEnumerable <User> >())); Assert.That(MatchesUsers(hashset, from.Collection.ConvertTo <List <User> >())); Assert.That(MatchesUsers(hashset, from.Collection.ConvertTo <User[]>())); Assert.That(MatchesUsers(hashset, from.Collection.ConvertTo <HashSet <User> >())); }
public void Does_convert_models_with_collections() { var from = new ModelWithEnumerable { Collection = new[] { new User { FirstName = "First1", LastName = "Last1", Car = new Car { Name = "Car1", Age = 1} }, new User { FirstName = "First2", LastName = "Last2", Car = new Car { Name = "Car2", Age = 2} }, } }; Assert.That(MatchesUsers(from.Collection, from.ConvertTo<ModelWithEnumerable>().Collection)); Assert.That(MatchesUsers(from.Collection, from.ConvertTo<ModelWithList>().Collection)); Assert.That(MatchesUsers(from.Collection, from.ConvertTo<ModelWithArray>().Collection)); Assert.That(MatchesUsers(from.Collection, from.ConvertTo<ModelWithHashSet>().Collection)); Assert.That(MatchesUsers(from.Collection, from.Collection.ConvertTo<IEnumerable<User>>())); Assert.That(MatchesUsers(from.Collection, from.Collection.ConvertTo<List<User>>())); Assert.That(MatchesUsers(from.Collection, from.Collection.ConvertTo<User[]>())); Assert.That(MatchesUsers(from.Collection, from.Collection.ConvertTo<HashSet<User>>())); var array = from.Collection.ToArray(); Assert.That(MatchesUsers(array, from.Collection.ConvertTo<IEnumerable<User>>())); Assert.That(MatchesUsers(array, from.Collection.ConvertTo<List<User>>())); Assert.That(MatchesUsers(array, from.Collection.ConvertTo<User[]>())); Assert.That(MatchesUsers(array, from.Collection.ConvertTo<HashSet<User>>())); var hashset = from.Collection.ToHashSet(); Assert.That(MatchesUsers(hashset, from.Collection.ConvertTo<IEnumerable<User>>())); Assert.That(MatchesUsers(hashset, from.Collection.ConvertTo<List<User>>())); Assert.That(MatchesUsers(hashset, from.Collection.ConvertTo<User[]>())); Assert.That(MatchesUsers(hashset, from.Collection.ConvertTo<HashSet<User>>())); }