public void Given_InvalidUserName_ShouldThrow() { var service = new AccountService(_repositoryMock.Object, _customerServiceMock.Object); Executing.This(() => service.CreateNewAccount(newInvalidCustomerName, customerInitialPassword)) .Should().Throw<InvalidCustomerNameException>(); }
public void Given_InvalidPassword_ShouldThrow_InvalidPasswordException() { var service = new AccountService(_repositoryMock.Object, _customerServiceMock.Object); Executing.This(() => service.CreateNewAccount(newCustomerName, invalidPassowrd)) .Should().Throw<InvalidPasswordException>(); }
public void Given_NewUser_ShouldCreateAnAccount() { var newAccountId = 123; var newCustomerId = 321; var newCustomerInstance = new Customer(){Id = newCustomerId}; var someAccountObj = new Account() { Customer = new Customer() { Id = newCustomerId } }; _repositoryMock .Setup( it=>it.InsertAccount(It.IsAny<Account>())) .ReturnsAsync(newAccountId); _customerServiceMock.Setup(it => it.CreateCustomer(It.IsAny<String>())) .Returns(newCustomerInstance); var service = new AccountService(_repositoryMock.Object, _customerServiceMock.Object); var result = service.CreateNewAccount(newCustomerName, customerInitialPassword).Result; result.Should().Be.EqualTo(newAccountId); }