Пример #1
0
        public void CheckOutAction_WhenInvalidIdPassed_ReturnsNotFound()
        {
            var libraryAssetService = new Mock <ILibraryAsset>();
            var checkoutService     = new Mock <ICheckout>();
            var _controller         = new CatalogController(libraryAssetService.Object, checkoutService.Object);
            var notFoundResult      = _controller.CheckOut(0);

            Assert.IsType <NotFoundResult>(notFoundResult);
        }
        public void Should_Call_CheckoutItem_In_IChecOut_When_CheckOut_Called()
        {
            var mockLibraryAsset = new Mock <ILibraryAsset>();
            var mockCheckOut     = new Mock <ICheckOut>();

            mockLibraryAsset.Setup(x => x.GetById(23)).Returns(GetAsset());
            var catalog = new CatalogController(mockLibraryAsset.Object, mockCheckOut.Object);

            catalog.CheckOut(23, 1);

            mockCheckOut.Verify(x => x.CheckoutItem(23, 1), Times.Once());
        }
        public void Should_Redirect_To_DetailView_When_CheckOut_Called()
        {
            var mockLibraryAsset = new Mock <ILibraryAsset>();
            var mockCheckOut     = new Mock <ICheckOut>();

            mockLibraryAsset.Setup(x => x.GetById(23)).Returns(GetAsset());
            var catalog = new CatalogController(mockLibraryAsset.Object, mockCheckOut.Object);

            var result = catalog.CheckOut(23, 1);

            var redirectresult = result.Should().BeOfType <RedirectToActionResult>();

            redirectresult.Subject.ActionName.Should().Be("Detail");
        }
Пример #4
0
        public void CheckOutAction_WhenValidIdPassed_ReturnsLibraryAssetObject()
        {
            //arrange
            var libraryAssetService = new Mock <ILibraryAsset>();
            var checkoutService     = new Mock <ICheckout>();

            libraryAssetService.Setup(r => r.GetById(233)).Returns(TestHelper.LibraryAsset());
            var _controller = new CatalogController(libraryAssetService.Object, checkoutService.Object);

            //act
            var checkoutModel = _controller.CheckOut(233);

            //assert
            var viewResult = Assert.IsType <ViewResult>(checkoutModel);
            var model      = Assert.IsType <CheckoutModels>(viewResult.ViewData.Model);

            Assert.Equal(233, model.AssetId);
            Assert.Equal("Testing", model.Title);
        }