Esempio n. 1
0
        public async Task ReturnEmptyWhenNoDataReturnedFromRepoAsync()
        {
            MockUnitOfWOrk.Setup(p => p.CustomerRepository.FindByConditionAsync(It.IsAny <Expression <Func <Customer, bool> > >()))
            .ReturnsAsync(() => new List <Customer>());
            var result = await SystemUnderTest.FindCustomerByNameAsync("Arnab");

            Assert.Empty(result);
        }
Esempio n. 2
0
        public async Task ReturnEmptyWhenSomeDataReturnedFromRepoAsync()
        {
            MockUnitOfWOrk.Setup(p => p.CustomerRepository.FindByConditionAsync(It.IsAny <Expression <Func <Customer, bool> > >()))
            .ReturnsAsync(() => TestCustomers);
            var result = await SystemUnderTest.FindCustomerByNameAsync("Arnab");

            Assert.Equal(3, result.Count());
            Assert.Equal(TestCustomers[0], result.First());
        }
        public async Task CustomerIsAddedSuccessfully()
        {
            MockUnitOfWOrk.Setup(p => p.CustomerRepository.Create(It.IsAny <Customer>()))
            .Returns(() => TestCustomers[0]);
            MockUnitOfWOrk.Setup(m => m.SaveAsync()).ReturnsAsync(() => new List <Guid>()
            {
                TestCustomers[0].Id
            }.AsEnumerable());

            var result = await SystemUnderTest.AddCustomerAsync(TestCustomers[0]);

            Assert.Equal(TestCustomers[0].Id, result);
        }