public async Task SaveDraft__ConfirmationReportViewModel_null__Throw_ArgumentNullException() { // Arrange ConfirmationReportViewModel model = null; mapper.Map <ConfirmationReport>(null).Returns(null as ConfirmationReport); mapper.Map <ConfirmationReportViewModel>(null).Returns(null as ConfirmationReportViewModel); var service = new ConfirmationReportCommandService(repo, mapper); // Act var actual = await service.SaveDraft(model); }
public async Task SaveDraft__ConfirmationReportViewModel_with_Id_Zero__Should_not_get_ConfirmationReport_from_Repo() { // Arrange ConfirmationReportViewModel model = new ConfirmationReportViewModel { }; ConfirmationReport domainModel = new ConfirmationReport { }; var service = new ConfirmationReportCommandService(repo, mapper); // Act await service.SaveDraft(model); // Assert await repo.DidNotReceive().GetById(Arg.Any <int>()); }
public async Task SaveDraft__ConfirmationReportViewModel_not_Empty__Should_call_SaveDraft_on_Domain() { // Arrange ConfirmationReportViewModel model = new ConfirmationReportViewModel { Id = 1 }; ConfirmationReport domainModel = Substitute.For <ConfirmationReport>(); repo.GetById(model.Id).Returns(domainModel); var service = new ConfirmationReportCommandService(repo, mapper); // Act await service.SaveDraft(model); // Assert domainModel.Received().SaveDraft(model); }
public async Task SaveDraft__ConfirmationReportViewModel_with_Id_not_Zero__Should_get_ConfirmationReport_from_Repo() { // Arrange ConfirmationReportViewModel model = new ConfirmationReportViewModel { Id = 1 }; ConfirmationReport domainModel = new ConfirmationReport { }; repo.GetById(model.Id).Returns(domainModel); var service = new ConfirmationReportCommandService(repo, mapper); // Act await service.SaveDraft(model); // Assert await repo.Received().GetById(model.Id); }