public void Update_WhenCodeNull_ShouldThrow()
 {
     using (var dataLayer = DataLayerHelper.CreateDataLayer())
         using (var controller = new CurrenciesController(dataLayer))
             controller.Update(new CurrencyUpdate {
                 Id = 1, Code = null
             });
 }
 public void Update_WhenRecordDoesNotExist_ShouldThrow()
 {
     using (var dataLayer = DataLayerHelper.CreateDataLayer())
         using (var controller = new CurrenciesController(dataLayer))
         {
             var currencyUpdate = new CurrencyUpdate {
                 Id = 1, Code = "USD"
             };
             controller.Update(currencyUpdate);
         }
 }
        public void Update_Normally_ShouldWork()
        {
            Currency createdCurrency, updatedCurrency;

            using (var dataLayer = DataLayerHelper.CreateDataLayer())
                using (var controller = new CurrenciesController(dataLayer))
                {
                    createdCurrency = controller.CreateCurrency(TestDataProvider.CreateNewCurrency());
                    controller.Update(new CurrencyUpdate {
                        Id = createdCurrency.Id, Code = "USD"
                    });
                    updatedCurrency = controller.Get(createdCurrency.Id);
                }

            Assert.AreEqual("USD", updatedCurrency.Code);
        }
示例#4
0
        public void TestCurrencyControllerUpdateModelIdLessThanZeroOrZeroReturnsBadResultObjectFail()
        {
            Currency currency = new Currency
            {
                Code      = "INR",
                Name      = "Rupees",
                IsActive  = true,
                IsDeleted = false
            };

            currencyMock.Setup(x => x.UpdateEntity(currency)).Returns(Task.FromResult(new BaseResult <bool>()
            {
                Result = true, IsError = false
            }));

            var result = mockCurrencyController.Update(currency).Result;

            Assert.That(result is BadRequestObjectResult);
        }
 public void Update_WhenNull_ShouldThrow()
 {
     using (var dataLayer = DataLayerHelper.CreateDataLayer())
         using (var controller = new CurrenciesController(dataLayer))
             controller.Update(null);
 }