Beispiel #1
0
        public async Task Get_WhenCalled_ReturnsOk()
        {
            var model = new RatesRequest
            {
                From = "USD",
                To   = "RUB"
            };

            var response = await _ratesController.Get(model);

            var result = response.Result as OkObjectResult;

            Assert.IsType <OkObjectResult>(result);
            Assert.IsType <RatesResponse>(result.Value);
            Assert.Equal(model.From, (result.Value as RatesResponse).From);
            Assert.NotEmpty((result.Value as RatesResponse).Rates);
        }
Beispiel #2
0
        public async Task GetId_WhenFound_Test()
        {
            string testRateType = "USD";
            var    moq2         = new Mock <IGraphService>();
            var    moq          = new Mock <ICurrencyService>();

            moq2.Setup(call => call.GetGraphData(testRateType, "", "")).ReturnsAsync((GraphModel)null);
            moq.Setup(call => call.GetLatestRates(testRateType)).ReturnsAsync(new ResponseModel());
            var controller = new RatesController(moq.Object, moq2.Object);

            var result = await controller.Get(testRateType);

            Assert.AreEqual(typeof(OkObjectResult), result.GetType());
        }
Beispiel #3
0
        public void TestRatesController_Returns_OkStatus()
        {
            var actionResult = ratesController.Get(DateTime.Now, DateTime.Now);

            var okResult = Assert.IsType <OkObjectResult>(actionResult.Result);
        }