Пример #1
0
        public void GetReturnsHttpResponseException()
        {
            // Arrange
            var mockUnitOfWork = new Mock <IUnitOfWork>();

            mockUnitOfWork.Setup(x => x.Cashiers.GetCashierById("2")).Returns(() => null);

            var controller = new CashiersController(mockUnitOfWork.Object);

            // Act
            Action action = () => controller.GetCashier("2");

            // Assert
            action.ShouldThrow <HttpResponseException>();
        }
Пример #2
0
        public void GetReturnsCashierWithSameId()
        {
            // Arrange
            var unitOfWork = new Mock <IUnitOfWork>();

            unitOfWork.Setup(x => x.Cashiers.GetCashierById("1")).Returns(new Cashier()
            {
                Id = "1"
            });

            var controller = new CashiersController(unitOfWork.Object);

            // Act
            IHttpActionResult actionResult = controller.GetCashier("1");
            var contentResult = actionResult as OkNegotiatedContentResult <Cashier>;

            // Assert
            contentResult.Should().NotBeNull();
            contentResult.Content.Should().NotBeNull();
            contentResult.Content.Id.Should().Be("1");
        }