public void ShouldReturnBetHistorySuccessfully() { //Arrange var mockResult = GetMockResult(); _betHistoryLogic.Setup(x => x.GetBetHistory()).Returns(Task.FromResult(mockResult)); var controller = new BetHistoryController(_betHistoryLogic.Object); //Act var result = controller.Get(); //Assert Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(JsonResult)); }
public void ShouldThrowBadRequestIfLogicLayerReturnsNull() { //Arrange var mockResult = GetMockResult(); _betHistoryLogic.Setup(x => x.GetBetHistory()).Returns(Task.FromResult <List <BetHistory> >(null)); var controller = new BetHistoryController(_betHistoryLogic.Object); //Act var result = controller.Get(); var badRequestResult = result as BadRequestObjectResult; //Assert Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(BadRequestObjectResult)); Assert.AreEqual(badRequestResult.StatusCode, 400); Assert.AreEqual(badRequestResult.Value, "Failed to get Bet History."); }