Esempio n. 1
0
        public void ListHoldings_LastPage()
        {
            // Arrange
            var mockLogger = new Mock <ILogger <StockItemsController> >();
            var mockRepo   = new Mock <IStockRepository>();

            mockRepo.Setup(repo => repo.ListHoldings(2, 1, 4)).Returns(predefinedHoldings);

            var test = new StockItemsController(mockLogger.Object, mockRepo.Object)
            {
                ControllerContext = new ControllerContext()
                {
                    HttpContext = new DefaultHttpContext()
                }
            };

            test.HttpContext.Request.Scheme = "https";
            test.HttpContext.Request.Host   = new HostString("api.example.com");

            // Act
            var actual = test.ListHoldings(2, new ListStockRequest()
            {
                PageSize = 4, PageToken = 1
            });

            // Assert
            CollectionAssert.AreEqual(predefinedHoldings, actual.Value.Holdings);
            Assert.IsNull(actual.Value.NextPage);
        }
Esempio n. 2
0
        public void ListHoldings_InvalidPageToken()
        {
            // Arrange
            var mockLogger = new Mock <ILogger <StockItemsController> >();
            var mockRepo   = new Mock <IStockRepository>();
            var test       = new StockItemsController(mockLogger.Object, mockRepo.Object);

            // Act
            var actual = test.ListHoldings(2, new ListStockRequest()
            {
                PageSize = 4, PageToken = -1
            });
            var result = actual.Result as ObjectResult;

            // Assert
            Assert.AreEqual(StatusCodes.Status400BadRequest, result.StatusCode);
        }