Exemple #1
0
        public async Task Get()
        {
            //Arrange
            _daySummaryServiceMock.Setup(x => x.Get(It.IsAny <service.DaySummaryGetRequest>())).ReturnsAsync(new service.DaySummary
            {
                Date      = "2013-06-20",
                Opening   = 262.99999,
                Closing   = 269.0,
                Lowest    = 260.00002,
                Highest   = 269.0,
                Volume    = 7253.1336356785,
                Quantity  = 27.11390588,
                Amount    = 28,
                Avg_price = 267.5060416518087
            });

            var expecteResult = new DaySummary
            {
                Date     = new DateTime(2013, 06, 20),
                Opening  = 262.99999,
                Closing  = 269.0,
                Lowest   = 260.00002,
                Highest  = 269.0,
                Volume   = 7253.1336356785,
                Quantity = 27.11390588,
                Amount   = 28,
                AvgPrice = 267.5060416518087
            };

            var request = new DaySummaryGetRequest()
            {
                Coins = Domain.CoinsEnum.BTC,
                Date  = DateTime.Now
            };

            //Act
            var result = await _daySummaryController.Get(request);

            var okObjectResult = result as OkObjectResult;
            var resultObj      = okObjectResult.Value as DaySummary;

            //Assert
            Assert.Equal(200, okObjectResult.StatusCode);
            Assert.NotNull(resultObj);

            Assert.Equal(expecteResult.Date, resultObj.Date);
            Assert.Equal(expecteResult.Opening, resultObj.Opening);
            Assert.Equal(expecteResult.Closing, resultObj.Closing);
            Assert.Equal(expecteResult.Lowest, resultObj.Lowest);
            Assert.Equal(expecteResult.Highest, resultObj.Highest);
            Assert.Equal(expecteResult.Volume, resultObj.Volume);
            Assert.Equal(expecteResult.Quantity, resultObj.Quantity);
            Assert.Equal(expecteResult.Amount, resultObj.Amount);
            Assert.Equal(expecteResult.AvgPrice, resultObj.AvgPrice);
        }
Exemple #2
0
        public async Task Get_StatusOk()
        {
            //Arrange
            var expectedResult = new DaySummary
            {
                Date     = new DateTime(2013, 06, 20),
                Opening  = 262.99999,
                Closing  = 269.0,
                Lowest   = 260.00002,
                Highest  = 269.0,
                Volume   = 7253.1336356785,
                Quantity = 27.11390588,
                Amount   = 28,
                AvgPrice = 267.5060416518087
            };

            var httpResponseMessage = new HttpResponseMessageBuilder().StatusOk_DaySummary().Build();

            _httpRequestHandlerMock.Setup(p => p.Get(It.IsAny <string>())).ReturnsAsync(httpResponseMessage);

            var request = new DaySummaryGetRequest()
            {
                Coins = Domain.CoinsEnum.BTC,
                Date  = DateTime.Now
            };

            //Act
            var result = await _daySummaryController.Get(request);

            var okObjectResult = result as OkObjectResult;
            var resultObj      = okObjectResult.Value as DaySummary;

            //Assert
            Assert.Equal(200, okObjectResult.StatusCode);
            Assert.NotNull(resultObj);

            Assert.Equal(expectedResult.Date, resultObj.Date);
            Assert.Equal(expectedResult.Opening, resultObj.Opening);
            Assert.Equal(expectedResult.Closing, resultObj.Closing);
            Assert.Equal(expectedResult.Lowest, resultObj.Lowest);
            Assert.Equal(expectedResult.Highest, resultObj.Highest);
            Assert.Equal(expectedResult.Volume, resultObj.Volume);
            Assert.Equal(expectedResult.Quantity, resultObj.Quantity);
            Assert.Equal(expectedResult.Amount, resultObj.Amount);
            Assert.Equal(expectedResult.AvgPrice, resultObj.AvgPrice);
        }