public void ESTestProjections() { FakeEventDto evDto = new FakeEventDto(); evDto.TestString = "Testing"; FakeEvent fc = evDto.ProjectAsEvent <FakeEventDto, FakeEvent>(); Assert.AreEqual <string>(fc.TestString, evDto.TestString, "Same Projection Id To DTO"); fc.TestString = "String changed"; evDto = fc.ProjectAsDto <FakeEvent, FakeEventDto>(); Assert.AreEqual <string>(fc.TestString, evDto.TestString, "Same Projection Id From DTO"); fc.TestString = "Testing collection"; List <FakeEvent> events = new List <FakeEvent>(); events.Add(fc); var dtos = new List <FakeEventDto>(events.ProjectAsDto <FakeEvent, FakeEventDto>()); Assert.AreEqual <string>(events[0].TestString, dtos[0].TestString, "Same Projection Id To Collection DTO"); evDto.TestString = "String collection changed"; List <FakeEventDto> fakeDTOs = new List <FakeEventDto>(); fakeDTOs.Add(evDto); List <FakeEvent> fakeCommands = new List <FakeEvent>(fakeDTOs.ProjectAsEvent <FakeEventDto, FakeEvent>()); Assert.AreEqual <string>(events[0].TestString, dtos[0].TestString, "Same Projection Id From Collection DTO"); var fcdto = fc.ProjectAsDto <FakeEvent, FakeEventDto>(CustomConvertToDTO); Assert.AreEqual <string>(fcdto.TestString, "As Dto", "Same custom Projection string From DTO"); fc = fcdto.ProjectAsEvent <FakeEventDto, FakeEvent>(CustomConvertToCommand); Assert.AreEqual <string>(fc.TestString, "As Event", "Same custom Projection string From command"); dtos = new List <FakeEventDto>(events.ProjectAsDto <FakeEvent, FakeEventDto>(CustomConvertToDTO)); Assert.AreEqual <string>(dtos[0].TestString, "As Dto", "Same custom Projection string From DTO"); fakeCommands = new List <FakeEvent>(fakeDTOs.ProjectAsEvent <FakeEventDto, FakeEvent>(CustomConvertToCommand)); Assert.AreEqual <string>(fakeCommands[0].TestString, "As Event", "Same custom Projection Id From Collection DTO"); }
public FakeEventDto CustomConvertToDTO(FakeEventDto command, object state) { command.TestString = "As Dto"; return(command); }