Skip to content

Commit 98d9268

Browse files
committed
Update test to include multiple new entities and also a remove
1 parent 1b369b5 commit 98d9268

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

src/AutoMapper.Collection.Tests/NullableIdTests.cs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,37 @@ public void Should_Work_With_Null_Id()
3535
original.Should().HaveSameCount(dtos);
3636
}
3737

38+
39+
[Fact]
40+
public void Should_Work_With_Multiple_Null_Id()
41+
{
42+
Mapper.Reset();
43+
Mapper.Initialize(x =>
44+
{
45+
x.AddCollectionMappers();
46+
x.CreateMap<ThingWithStringIdDto, ThingWithStringId>().EqualityComparison((dto, entity) => dto.ID == entity.ID);
47+
});
48+
49+
var original = new List<ThingWithStringId>
50+
{
51+
new ThingWithStringId { ID = "1", Title = "test0" },
52+
new ThingWithStringId { ID = "2", Title = "test2" },
53+
new ThingWithStringId { ID = "3", Title = "test3" },
54+
};
55+
56+
var dtos = new List<ThingWithStringIdDto>
57+
{
58+
new ThingWithStringIdDto { ID = "1", Title = "test0" },
59+
new ThingWithStringIdDto { ID = "2", Title = "test2" },
60+
new ThingWithStringIdDto { Title = "test3" },
61+
new ThingWithStringIdDto { Title = "test4" },
62+
};
63+
64+
Mapper.Map(dtos, original);
65+
66+
original.Should().HaveSameCount(dtos);
67+
}
68+
3869
public class ThingWithStringId
3970
{
4071
public string ID { get; set; }

0 commit comments

Comments
 (0)