public void GetReturnsHttpResponseException() { // Arrange var mockUnitOfWork = new Mock <IUnitOfWork>(); mockUnitOfWork.Setup(x => x.Cashboxes.GetCashboxById(5)).Returns(() => null); var controller = new CashboxesController(mockUnitOfWork.Object); // Act Action action = () => controller.GetCashbox(5); // Assert action.ShouldThrow <HttpResponseException>(); }
public void GetReturnsCashboxWithSameId() { // Arrange var unitOfWork = new Mock <IUnitOfWork>(); unitOfWork.Setup(x => x.Cashboxes.GetCashboxById(5)).Returns(new Cashbox() { Id = 5, }); var controller = new CashboxesController(unitOfWork.Object); // Act IHttpActionResult actionResult = controller.GetCashbox(5); var contentResult = actionResult as OkNegotiatedContentResult <Cashbox>; // Assert contentResult.Should().NotBeNull(); contentResult.Content.Should().NotBeNull(); contentResult.Content.Id.Should().Be(5); }