public void You_can_map_an_object_to_one_of_its_sub_types() { var goblin = new GoblinBoss(new[] { new Goblin(sneakyness: 10), new Goblin(sneakyness: 15) }); GoblinDto result = goblin.Map(); Assert.Equal(goblin.Name, result.Name); Assert.Equal(goblin.HitPoints, result.HitPoints); Assert.Equal(goblin.Sneakyness, result.Sneakyness); }
public void You_can_map_objects_with_collection_properties() { var goblin = new GoblinBoss(new[] { new Goblin(sneakyness: 10), new Goblin(sneakyness: 15) }); GoblinBossDto result = goblin.Map(); Assert.Equal(goblin.Name, result.Name); Assert.Equal(goblin.HitPoints, result.HitPoints); Assert.Equal(goblin.Sneakyness, result.Sneakyness); Assert.Equal(2, result.Subjects.Count()); Assert.Equal(goblin.Subjects.ElementAt(0).Name, result.Subjects.ElementAt(0).Name); Assert.Equal(goblin.Subjects.ElementAt(0).HitPoints, result.Subjects.ElementAt(0).HitPoints); Assert.Equal(goblin.Subjects.ElementAt(0).Sneakyness, result.Subjects.ElementAt(0).Sneakyness); Assert.Equal(goblin.Subjects.ElementAt(1).Name, result.Subjects.ElementAt(1).Name); Assert.Equal(goblin.Subjects.ElementAt(1).HitPoints, result.Subjects.ElementAt(1).HitPoints); Assert.Equal(goblin.Subjects.ElementAt(1).Sneakyness, result.Subjects.ElementAt(1).Sneakyness); }