internal async Task Create_GeneralFlow_ConfirmationMailShouldBeSentToCorrectAccount( [Frozen] Mock <IUserAccountService> userAccountServiceMock, StudentAccountService studentAccountService) { // Arrange var data = new StudentCreationData(); var verifiedAccount = new Account(); userAccountServiceMock.Setup(e => e.Create(It.IsAny <AccountCreationData>())).ReturnsAsync(verifiedAccount); // Act await studentAccountService.Create(data); // Assert userAccountServiceMock.Verify(e => e.SendEmailConfirmation(verifiedAccount), Times.Once); }
internal async Task Create_GeneralFlow_StudentShouldBeCreatedWithCorrectAccount( [Frozen] Mock <IUserAccountService> userAccountServiceMock, [Frozen] Mock <IUnitOfWork> unitOfWorkMock, StudentAccountService studentAccountService) { // Arrange var data = new StudentCreationData(); var verifiedAccount = new Account(); userAccountServiceMock.Setup(e => e.Create(It.IsAny <AccountCreationData>())).ReturnsAsync(verifiedAccount); // Act await studentAccountService.Create(data); // Assert unitOfWorkMock.Verify(e => e.Add(It.Is <Student>(i => i.Account == verifiedAccount)), Times.Once); }
internal async Task Create_GeneralFlow_EmailShouldBeValidatedBeforeCreation( string email, [Frozen] Mock <IRegistrationValidationService> registrationValidationServiceMock, StudentAccountService studentAccountService) { // Arrange var data = new StudentCreationData { Email = email, }; // Act await studentAccountService.Create(data); // Assert registrationValidationServiceMock.Verify( e => e.TrowsIfEmailIsNotUniq(It.Is <string>(v => v == email)), Times.Once); }