Ejemplo n.º 1
0
        public async Task AddCustomer_ShortName_ThrowsException()
        {
            using (var context = new CustomersDbContext(_options))
            {
                var customer = new CustomerDto()
                {
                    Name = "Ed", Email = "*****@*****.**"
                };
                var repository = new CustomersRepository(context, _mapper);
                Func <Task <CustomerDto> > result = async() => await repository.AddCustomerAsync(customer);

                await result.Should().ThrowAsync <Exception>();
            }
        }
Ejemplo n.º 2
0
        public async Task AddCustomer_WrongEmail_ThrowsException()
        {
            using (var context = new CustomersDbContext(_options))
            {
                var customer = new CustomerDto()
                {
                    Name = "Edward Stark", Email = "edward.stark.from.winterfell"
                };
                var repository = new CustomersRepository(context, _mapper);
                Func <Task <CustomerDto> > result = async() => await repository.AddCustomerAsync(customer);

                await result.Should().ThrowAsync <Exception>();
            }
        }
Ejemplo n.º 3
0
        public async Task AddCustomer_ValidParams_CreatesAndReturns()
        {
            using (var context = new CustomersDbContext(_options))
            {
                var customer = new CustomerDto()
                {
                    Name = "Elon Musk", Email = "*****@*****.**"
                };
                var repository = new CustomersRepository(context, _mapper);
                var result     = await repository.AddCustomerAsync(customer);

                result.Id.Should().BeGreaterThan(0);
                result.Should().BeEquivalentTo(customer, opt => opt.Excluding(c => c.Id));
            }
        }