예제 #1
0
        public void ShouldCallDatabaseToInsertCustomer()
        {
            var newCustomer  = new Models.Customer(NewCustomerEmail, NewCustomerFirstName, NewCustomerSurname, NewCustomerPassword);
            var mockDatabase = new Mock <ICustomerDb>();
            var sut          = new Services.CustomerService(mockDatabase.Object);

            sut.Add(newCustomer);

            mockDatabase.Verify(db => db.Insert(newCustomer), Times.Once);
        }
예제 #2
0
        public void ShouldReturnCustomerWithTheSameEmailPassedIntoIt()
        {
            var newCustomer  = new Models.Customer(NewCustomerEmail, NewCustomerFirstName, NewCustomerSurname, NewCustomerPassword);
            var mockDatabase = new Mock <ICustomerDb>();

            mockDatabase.Setup(db => db.Insert(newCustomer)).ReturnsAsync(newCustomer);
            var sut = new Services.CustomerService(mockDatabase.Object);

            var actualNewCustomer = sut.Add(newCustomer).Result;

            Assert.Equal(NewCustomerEmail, actualNewCustomer.Email);
        }