コード例 #1
0
        public async Task GivenCustomerIsDeleted_WhenUpdateCustomerAsync_ThenThrowException()
        {
            // Arrange
            var customer = new Customer()
            {
                ID             = Guid.NewGuid(),
                CurrentBalance = 200,
                Email          = "*****@*****.**",
                Surname        = "Test",
                GivenNames     = "Person",
                IsDeleted      = true
            };

            using (var ctx = _dbContextCreator.CreateDbContext())
            {
                ctx.Add(customer);
                await ctx.SaveChangesAsync();
            }

            var updatedCustomer = customer.Adapt <Customer>();

            updatedCustomer.Surname = "Updated";

            // Act + Assert
            await Assert.ThrowsAsync <UnableToUpdateDeletedRecordsException>(() => _repo.UpdateCustomerAsync(updatedCustomer));
        }