public void Category_Browse()
        {
            var sessionMock = new Mock<ISession>();
            var nHbernateContextMock = new Mock<NHibernateContext>(sessionMock.Object, UserName);
            var categoryBrowseModel = new CategoryBrowseModel();
            var services = GetSampleServices();

            nHbernateContextMock.Setup(c => c.ExecuteQuery(It.IsAny<QueryByCategory>()))
                .Returns(services);

            var fileSystemMock = new Mock<IFileSystem>();
            var geoCodingServicemMock = new Mock<IGeoCodingService>();

            var controller = new ServicesController(nHbernateContextMock.Object, fileSystemMock.Object, geoCodingServicemMock.Object);
            controller.SetFakeControllerContext(MvcMockHelpers.FakeAuthenticatedHttpContext("~/Services/Category/1/", UserName));
            controller.SetUserInfo();

            controller.Category(categoryBrowseModel);

            Assert.AreEqual(services, controller.ViewData[ViewDataKeys.Services]);
        }
Esempio n. 2
0
        public void Category_Browse()
        {
            var sessionMock          = new Mock <ISession>();
            var nHbernateContextMock = new Mock <NHibernateContext>(sessionMock.Object, UserName);
            var categoryBrowseModel  = new CategoryBrowseModel();
            var services             = GetSampleServices();

            nHbernateContextMock.Setup(c => c.ExecuteQuery(It.IsAny <QueryByCategory>()))
            .Returns(services);

            var fileSystemMock        = new Mock <IFileSystem>();
            var geoCodingServicemMock = new Mock <IGeoCodingService>();

            var controller = new ServicesController(nHbernateContextMock.Object, fileSystemMock.Object, geoCodingServicemMock.Object);

            controller.SetFakeControllerContext(MvcMockHelpers.FakeAuthenticatedHttpContext("~/Services/Category/1/", UserName));
            controller.SetUserInfo();

            controller.Category(categoryBrowseModel);

            Assert.AreEqual(services, controller.ViewData[ViewDataKeys.Services]);
        }