Пример #1
0
        public void Delete_Normally_ShouldWork()
        {
            Transfer createdTransfer, queriedTransfer;
            IEnumerable <Transfer> listedTransfers;

            using (var dataLayer = DataLayerHelper.CreateDataLayer())
                using (var categoriesController = new CategoriesController(dataLayer))
                    using (var currenciesController = new CurrenciesController(dataLayer))
                        using (var partnersController = new PartnersController(dataLayer))
                            using (var transfersController = new TransfersController(dataLayer))
                            {
                                var category = categoriesController.CreateCategory(TestDataProvider.CreateNewCategory());
                                var partner  = partnersController.CreatePartner(TestDataProvider.CreateAnotherNewPartner());
                                var currency = currenciesController.CreateCurrency(TestDataProvider.CreateAnotherNewCurrency());

                                var newTransfer = TestDataProvider.CreateNewTransfer(
                                    category.Id,
                                    partner.Id,
                                    currency.Id,
                                    TestDataProvider.CreateNewTransferItem());
                                createdTransfer = transfersController.CreateTransfer(newTransfer);

                                queriedTransfer = transfersController.Get(createdTransfer.Id);
                                transfersController.Delete(createdTransfer.Id);
                                listedTransfers = transfersController.List();
                            }

            Assert.AreEqual(createdTransfer.Id, queriedTransfer.Id, "Unexpected ID.");
            Assert.AreEqual(false, listedTransfers.Any(), "There should be no transfers returned.");
        }
Пример #2
0
 public void Delete_WhenRecordDoesNotExist_ShouldThrow()
 {
     using (var dataLayer = DataLayerHelper.CreateDataLayer())
         using (var controller = new TransfersController(dataLayer))
             controller.Delete(1);
 }