Example #1
0
        public async Task AddNewCustomerAsync_ShouldReturnNull_WhenCustomerDoesExist()
        {
            //Arrange
            _customerRepository.GetByEmailAsync(Arg.Any <string>()).Returns(_existingCustomer);

            //Act
            var sut           = new CustomerService(_customerRepository);
            var cutomerReturn = await sut.AddNewCustomerAsync("name", _existingCustomer.Email);

            //Assert
            Assert.Null(cutomerReturn);
        }
Example #2
0
        public async Task AddNewCustomerAsync_ShouldPassCustomerToRepository_WhenCustomerDoesNotExist()
        {
            //Arrange
            string email = "fake-email";

            _customerRepository.GetByEmailAsync(email).Returns(_nullReturn);

            //Act
            var sut           = new CustomerService(_customerRepository);
            var cutomerReturn = await sut.AddNewCustomerAsync("name", email);

            //Assert
            await _customerRepository.Received(1).InsertAsync(
                Arg.Is <Customer>(
                    x =>
                    x.Email == email &&
                    x.Name == "name"
                    )
                );
        }