예제 #1
0
        public void ReturnCheckoutViewAndModel()
        {
            var mockLibraryAssetService = new Mock <ILibraryAsset>();
            var mockCheckoutService     = new Mock <ICheckout>();

            mockLibraryAssetService.Setup(r => r.GetById(24)).Returns(GetAsset);

            var controller = new CatalogController(mockLibraryAssetService.Object, mockCheckoutService.Object);

            var result = controller.Checkout(24);

            var viewResult = Assert.IsType <ViewResult>(result);

            var model = Assert.IsType <CheckoutModel>(viewResult.Model);

            Assert.Equal("Orlando", model.Title);
        }
예제 #2
0
        public void ReturnCheckInViewAndModel()
        {
            var mockLibraryAssetService = new Mock <ILibraryAsset>();
            var mockCheckoutService     = new Mock <ICheckout>();

            mockLibraryAssetService.Setup(r => r.GetById(24)).Returns(GetAsset);

            mockLibraryAssetService.Setup(r => r.GetCurrentLocation(24)).Returns(new LibraryBranch
            {
                Name = "Hawkins Library"
            });

            var controller = new CatalogController(mockLibraryAssetService.Object, mockCheckoutService.Object);

            var result = controller.Detail(24);

            var viewResult = Assert.IsType <ViewResult>(result);

            var model = Assert.IsType <AssetDetailModel>(viewResult.Model);

            Assert.Equal("Orlando", model.Title);
        }
예제 #3
0
        public void ReturnDetailViewAndModel()
        {
            var mockLibraryAssetService = new Mock <ILibraryAsset>();
            var mockCheckoutService     = new Mock <ICheckout>();

            mockLibraryAssetService.Setup(r => r.GetById(24)).Returns(GetAsset());

            mockCheckoutService.Setup(r => r.GetCurrentHoldPatronName(24)).Returns(GetCurrentHold().HoldPlaced);
            mockCheckoutService.Setup(r => r.GetCurrentHoldPatronName(24)).Returns(GetCurrentHold().PatronName);

            mockCheckoutService.Setup(r => r.GetCheckoutHistory(24)).Returns(new List <CheckoutHistory>
            {
                new CheckoutHistory()
            });

            mockLibraryAssetService.Setup(r => r.GetType(24)).Returns("Book");
            mockLibraryAssetService.Setup(r => r.GetCurrentLocation(24)).Returns(new LibraryBranch
            {
                Name = "Hawkins Library"
            });
            mockLibraryAssetService.Setup(r => r.GetAuthorOrDirector(24)).Returns("Virginia Woolf");

            mockLibraryAssetService.Setup(r => r.GetDeweyIndex(24)).Returns("ELEVEN");
            mockCheckoutService.Setup(r => r.GetCheckoutHistory(24)).Returns(new List <CheckoutHistory>
            {
                new CheckoutHistory()
            });
            mockCheckoutService.Setup(r => r.GetLatestCheckout(24)).Returns(new Checkout());
            mockCheckoutService.Setup(r => r.GetCurrentHoldPatronName(24)).Returns("NANCY");
            var controller = new CatalogController(mockLibraryAssetService.Object, mockCheckoutService.Object);

            var result     = controller.Detail(24);
            var viewResult = Assert.IsType <ViewResult>(result);
            var model      = Assert.IsType <AssetDetailModel>(
                viewResult.ViewData.Model);

            Assert.Equal("Orlando", model.Title);
        }