public void Home_Page_With_Custom_Action(string virtualUrl) { // Arrange var pathData = new PathData(); var mapper = new Mock<IControllerMapper>(); var container = new Mock<IContainer>(); mapper.Setup(x => x.GetControllerName(typeof(DummyController))).Returns("Dummy"); mapper.Setup(x => x.ControllerHasAction("Dummy", "myaction")).Returns(true); container.Setup(x => x.GetInstance<IDocumentSession>()).Returns(_store.OpenSession()); mapper.Setup(m => m.ControllerHasAction("Content", "myaction")).Returns(true); // Act IPathData data; using (var session = _store.OpenSession()) { // create and store a new page model var pageModel = new DummyModel { Parent = null }; session.Store(pageModel); session.SaveChanges(); var resolver = new PathResolver(session, pathData, mapper.Object, container.Object); data = resolver.ResolvePath(new RouteData(), virtualUrl); } // Assert Assert.NotNull(data); Assert.AreEqual("myaction", data.Action); Assert.AreEqual("Dummy", data.Controller); }
public void Home_Page_With_Custom_Action(string virtualUrl) { // Arrange var pathData = new PathData(); var pageModel = new DummyModel(); var repository = new Mock<IPageRepository>(); var mapper = new Mock<IControllerMapper>(); var container = new Mock<IContainer>(); container.Setup(x => x.GetInstance<IPageRepository>()).Returns(repository.Object); repository.Setup(x => x.SingleOrDefault<IPageModel>(model => model.Parent == null)).Returns(pageModel); mapper.Setup(x => x.GetControllerName(typeof(DummyController))).Returns("Dummy"); mapper.Setup(x => x.ControllerHasAction("Dummy", "myaction")).Returns(true); mapper.Setup(m => m.ControllerHasAction("Content", "myaction")).Returns(true); var resolver = new PathResolver(pathData, repository.Object, mapper.Object, container.Object); // Act var data = resolver.ResolvePath(virtualUrl); // Assert Assert.NotNull(data); Assert.AreEqual("myaction", data.Action); Assert.AreEqual("Dummy", data.Controller); }
public void Home_Page_With_Default_Action(string path) { // Arrange var pathData = new PathData(); var pageModel = new DummyModel(); var repository = new Mock<IPageRepository>(); var mapper = new Mock<IControllerMapper>(); var container = new Mock<IContainer>(); container.Setup(x => x.GetInstance<IPageRepository>()).Returns(repository.Object); repository.Setup(x => x.SingleOrDefault<IPageModel>(model => model.Parent == null)).Returns(pageModel); var resolver = new DashboardPathResolver(pathData,repository.Object,mapper.Object, container.Object); // Act var data = resolver.ResolvePath(path); // Assert Assert.NotNull(data); Assert.AreEqual("index", data.Action); Assert.AreEqual("Content",data.Controller); }
public void Page_With_Custom_Action(string virtualUrl) { // Arrange var pathData = new PathData(); var pageModel = new DummyModel(); var repository = new Mock<IPageRepository>(); var mapper = new Mock<IControllerMapper>(); var container = new Mock<IContainer>(); container.Setup(x => x.GetInstance<IPageRepository>()).Returns(repository.Object); repository.Setup(r => r.GetPageByUrl<IPageModel>("page")).Returns(pageModel); mapper.Setup(x => x.GetControllerName(typeof(DummyController))).Returns("Dummy"); var resolver = new PathResolver(pathData, repository.Object, mapper.Object, container.Object); // Act var data = resolver.ResolvePath(virtualUrl); // Assert Assert.NotNull(data); Assert.AreEqual("myaction", data.Action); Assert.AreEqual("Dummy", data.Controller); }
//[TestCase("/myaction/")] //public void Can_Lookup_Controller_Without_ControllerType_Specified(string virtualUrl) { // // Arrange // var pathData = new PathData(); // var mapper = new Mock<IControllerMapper>(); // var container = new Mock<IContainer>(); // mapper.Setup(x => x.GetControllerName(typeof(DummyModelWithoutControllerTypeController))).Returns("DummyModelWithoutControllerType"); // mapper.Setup(x => x.ControllerHasAction("DummyModelWithoutControllerType", "myaction")).Returns(true); // container.Setup(x => x.GetInstance<IDocumentSession>()).Returns(_store.OpenSession()); // mapper.Setup(m => m.ControllerHasAction("DummyModelWithoutControllerType", "myaction")).Returns(true); // // Act // IPathData data; // using (var session = _store.OpenSession()) { // // create and store a new page model // var pageModel = new DummyModelWithoutControllerType { Parent = null }; // session.Store(pageModel); // session.SaveChanges(); // var resolver = new PathResolver(session, pathData, mapper.Object, container.Object); // data = resolver.ResolvePath(new RouteData(), virtualUrl); // } // // Assert // Assert.NotNull(data); // Assert.AreEqual("myaction", data.Action); // Assert.AreEqual("DummyModelWithoutControllerType", data.Controller); //} //[TestCase("/mypage")] public void Can_Create_Model_WithOut_Inheritance(string url) { // Arrange var pathData = new PathData(); var mapper = new Mock<IControllerMapper>(); var container = new Mock<IContainer>(); mapper.Setup(x => x.GetControllerName(typeof(DummyController))).Returns("Dummy"); mapper.Setup(x => x.ControllerHasAction("Dummy", "mypage")).Returns(true); container.Setup(x => x.GetInstance<IDocumentSession>()).Returns(_store.OpenSession()); // Act IPathData data; using (var session = _store.OpenSession()) { var siteMap = new SiteMap(); session.Store(siteMap); // create and store a new page model var page = new DummyModel(); //page.Childs.Add(new DummyModel {Metadata = { Name = "Child 1"}}); var content = new StandardPage(); session.Store(content); //page.PageReference.Id = content.Id; //var pageModel = new DummyModel(); //session.Store(pageModel); //session.SaveChanges(); var resolver = new PathResolver(session, pathData, mapper.Object, container.Object); data = resolver.ResolvePath(new RouteData(), url); } // Assert Assert.NotNull(data); }
public void Can_Query_Page_Using_AllPages_Index() { // Arrange IPageModel data; // Act using (var session = _store.OpenSession()) { var pageModel = new DummyModel { Id = "DummyPages/1", Parent = null }; session.Store(pageModel); session.SaveChanges(); } using (var session = _store.OpenSession()) { //data = session.Query<IPageModel, AllPages>() // .Customize(x => x.WaitForNonStaleResults()) // .SingleOrDefault(x => x.Parent == null); } // Assert //Assert.NotNull(data); }