示例#1
0
        public void Given_InvalidUserName_ShouldThrow()
        {
            var service = new AccountService(_repositoryMock.Object, _customerServiceMock.Object);

            Executing.This(() => service.CreateNewAccount(newInvalidCustomerName, customerInitialPassword))
                .Should().Throw<InvalidCustomerNameException>();
        }
示例#2
0
        public void Given_InvalidPassword_ShouldThrow_InvalidPasswordException()
        {
            var service = new AccountService(_repositoryMock.Object, _customerServiceMock.Object);

            Executing.This(() => service.CreateNewAccount(newCustomerName, invalidPassowrd))
                .Should().Throw<InvalidPasswordException>();
        }
示例#3
0
        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);
        }