public void GetByIdTest() { var currencyRateServiceMock = new Mock <ICurrencyRateByTimeService>(); currencyRateServiceMock.Setup(s => s.GetById(1)).ReturnsAsync(_currencyRates[0]); var currencyRateController = new CurrencyRateByTimeController(currencyRateServiceMock.Object); var result = currencyRateController.GetCurrencyRateByTime(1).Result.Queryable.Single(); Assert.AreEqual(result.Id, _currencyRates[0].Id); }
public void GetByIncorrectId() { var currencyRateServiceMock = new Mock <ICurrencyRateByTimeService>(); currencyRateServiceMock.Setup(s => s.GetById(It.IsAny <int>())).ReturnsAsync((int s) => null); var currencyRateController = new CurrencyRateByTimeController(currencyRateServiceMock.Object); var rateByTimeResult = currencyRateController.GetCurrencyRateByTime(1).Result.Queryable.Single(); Assert.IsNull(rateByTimeResult); var currencyResult = currencyRateController.GetCurrency(1).Result.Queryable.Single(); Assert.IsNull(currencyResult); var bankDepartmentResult = currencyRateController.GetBankDepartment(1).Result.Queryable.Single(); Assert.IsNull(bankDepartmentResult); }