public void UsernameNotProvidedTest_TestsIfNewUserIsNotCreatedWhenUsernameIsNotGiven_ChecksActivationKeyisNotReturnedToConfirm() { IIdentityAccessPersistenceRepository persistenceRepository = new MockPersistenceRepository(false); RegistrationApplicationService registrationApplicationService = new RegistrationApplicationService(persistenceRepository, new PasswordEncryptionService(), new ActivationKeyGenerationService(), new MockEmailService(), new MockTierRepository(), new MockUserRepository()); registrationApplicationService.CreateAccount( new SignupUserCommand("*****@*****.**", null, "iammartinfowler", "ProgrammingNation", TimeZone.CurrentTimeZone, "")); }
public void UserCreatedTest_ChecksIfTheRegistrationServiceCreatesAUserAsExpected() { IIdentityAccessPersistenceRepository persistenceRepository = new MockPersistenceRepository(false); RegistrationApplicationService registrationApplicationService = new RegistrationApplicationService(persistenceRepository, new PasswordEncryptionService(), new ActivationKeyGenerationService(), new MockEmailService(), new MockTierRepository(), new MockUserRepository()); string activationKey = registrationApplicationService.CreateAccount( new SignupUserCommand("*****@*****.**", "iamnotmartinfowler", "butiamjohnskeet", "ProgrammingNation", TimeZone.CurrentTimeZone, "")); Assert.IsNotNull(activationKey); Assert.IsFalse(string.IsNullOrEmpty(activationKey)); }
public void EmailNotProvidedTest_TestsIfNewUserIsNotCreatedWhenEmailIsNotGiven_ChecksActivationKeyisNotReturnedToConfirm() { IIdentityAccessPersistenceRepository persistenceRepository = new MockPersistenceRepository(false); RegistrationApplicationService registrationApplicationService = new RegistrationApplicationService(persistenceRepository, new PasswordEncryptionService(), new ActivationKeyGenerationService(), new MockEmailService(), new MockTierRepository(), new MockUserRepository()); bool exceptionRaised = false; try { registrationApplicationService.CreateAccount( new SignupUserCommand("", "agilegeek", "iammartinfowler", "ProgrammingNation", TimeZone.CurrentTimeZone, "")); } catch (InvalidCredentialException e) { exceptionRaised = true; } Assert.IsTrue(exceptionRaised); }
public void DatabaseMockSaveFailTest_TestsIfUserIsNotSavedInDatabaseExceptionIsRaisedFromTheMockClass_HandlesTheExceptionToConfirm() { // Provide true to the Mock class so that it raises exception when SaveUpdate method is called inside it IIdentityAccessPersistenceRepository persistenceRepository = new MockPersistenceRepository(true); RegistrationApplicationService registrationApplicationService = new RegistrationApplicationService(persistenceRepository, new PasswordEncryptionService(), new ActivationKeyGenerationService(), new MockEmailService(), new MockTierRepository(), new MockUserRepository()); bool exceptionRaised = false; try { string activationKey = registrationApplicationService.CreateAccount(new SignupUserCommand( "*****@*****.**", "iamnotmartinfowler", "butiamjacksparrow", "PirateNation", TimeZone.CurrentTimeZone, "")); Assert.IsNull(activationKey); } catch (Exception e) { exceptionRaised = true; } Assert.IsTrue(exceptionRaised); }