コード例 #1
0
        public async Task Edit_Customer_Throw_Exception(CustomerDetailModel model)
        {
            IMapper mapper = TestUtilities.GetMapper(new CustomerProfile(), new SharedProfile());
            var     mock   = new Mock <ICustomerService>();

            mock.Setup(x => x.Update(It.IsAny <Customer>())).ThrowsAsync(new Exception("failed"));

            AddressDetailModel address = new Fixture().Create <AddressDetailModel>();

            address.State   = "MO";
            address.ZipCode = "12345";
            model.Addresses.Clear();
            model.Addresses.Add(new CustomerAddressDetailModel()
            {
                Address = address, Type = AddressType.Billing
            });
            model.Addresses.Add(new CustomerAddressDetailModel()
            {
                Address = address, Type = AddressType.Shipping
            });
            model.Contact.Email       = "*****@*****.**";
            model.Contact.Fax         = "123-1234";
            model.Contact.PhoneNumber = "123-1234";
            model.Institutions.Clear();
            model.ItemConfigurations.Clear();
            model.Documents.Clear();
            CustomerManager   manager           = new CustomerManager(_logger, mapper, mock.Object, Mock.Of <IUserService>(), Mock.Of <IIsotopeOrderingAuthorizationService>(), _eventService, Mock.Of <INotificationService>());
            ApplicationResult applicationResult = await manager.Edit(model);

            CustomAssertions.AssertExcpetionErrorsExist(applicationResult);
        }