public async Task HandleAsync_SendsEmailWithMemberUploadComplianceYear() { // Arrange var competentAuthority = A.Fake <UKCompetentAuthority>(); Scheme scheme = A.Fake <Scheme>(); A.CallTo(() => scheme.CompetentAuthority) .Returns(competentAuthority); MemberUpload memberUpload = A.Fake <MemberUpload>(); A.CallTo(() => memberUpload.Scheme) .Returns(scheme); A.CallTo(() => memberUpload.ComplianceYear) .Returns(2015); var schemeSubmissionEvent = new SchemeMemberSubmissionEvent(memberUpload); var emailService = A.Fake <IWeeeEmailService>(); var handler = new SchemeMemberSubmissionEventHandler(emailService); // Act await handler.HandleAsync(schemeSubmissionEvent); // Assert A.CallTo(() => emailService.SendSchemeMemberSubmitted(A <string> ._, A <string> ._, 2015, A <int> ._)) .MustHaveHappened(Repeated.Exactly.Once); }
public async Task HandleAsync_SendsEmailToCompetentAuthorityNotificationAddress() { // Arrange string emailAddress = "*****@*****.**"; var competentAuthority = new UKCompetentAuthority(Guid.NewGuid(), "Name", "Abbreviation", A.Dummy <Country>(), emailAddress, 0); Scheme scheme = A.Fake <Scheme>(); A.CallTo(() => scheme.CompetentAuthority) .Returns(competentAuthority); MemberUpload memberUpload = A.Fake <MemberUpload>(); A.CallTo(() => memberUpload.Scheme) .Returns(scheme); A.CallTo(() => memberUpload.ComplianceYear) .Returns(2015); var schemeSubmissionEvent = new SchemeMemberSubmissionEvent(memberUpload); var emailService = A.Fake <IWeeeEmailService>(); var handler = new SchemeMemberSubmissionEventHandler(emailService); // Act await handler.HandleAsync(schemeSubmissionEvent); // Assert A.CallTo(() => emailService.SendSchemeMemberSubmitted(emailAddress, A <string> ._, A <int> ._, A <int> ._)) .MustHaveHappened(Repeated.Exactly.Once); }
private IGetSchemesDataAccess CreateFakeDataAccess() { IGetSchemesDataAccess dataAccess = A.Fake<IGetSchemesDataAccess>(); scheme1 = A.Fake<Domain.Scheme.Scheme>(); scheme2 = A.Fake<Domain.Scheme.Scheme>(); scheme3 = A.Fake<Domain.Scheme.Scheme>(); var results = new List<Domain.Scheme.Scheme>() { scheme1, scheme2, scheme3 }; A.CallTo(() => dataAccess.GetCompleteSchemes()).Returns(results); return dataAccess; }
private IGetSchemesDataAccess CreateFakeDataAccess() { IGetSchemesDataAccess dataAccess = A.Fake <IGetSchemesDataAccess>(); scheme1 = A.Fake <Domain.Scheme.Scheme>(); scheme2 = A.Fake <Domain.Scheme.Scheme>(); scheme3 = A.Fake <Domain.Scheme.Scheme>(); var results = new List <Domain.Scheme.Scheme>() { scheme1, scheme2, scheme3 }; A.CallTo(() => dataAccess.GetCompleteSchemes()).Returns(results); return(dataAccess); }