예제 #1
0
        public async Task AttemptingToCreateSimpleContentWithIdAlreadyInUse()
        {
            await s_repo.CreateContentAsync(new SimpleContent { Id = "existing", Title = "Exists", Content = "Already here" });

            var toAdd = new SimpleContent {
                Id = "existing", Title = "Usurper", Content = "Trying to overwrite"
            };
            var controller = new ManageSimpleController(s_repo, s_mapRepo);
            var result     = await controller.Create(toAdd) as ViewResult;

            Assert.AreEqual("Create", result.ViewName, "Shows Create view again");
            Assert.AreSame(toAdd, result.Model, "Passes model back to view");
            Assert.AreEqual("Content with this id already exists", controller.ModelState["Id"].Errors.Single().ErrorMessage);
        }
예제 #2
0
        public static void Setup(TestContext context)
        {
            s_repo = new Data.InMemorySiteContentRepository();
            s_repo.CreateContentAsync(
                new ListLandingContent {
                Id = "NewsList", Title = "News", Content = "<b>News</b>"
            }
                ).Wait();
            s_repo.CreateContentAsync(
                new ListItemContent {
                Id            = "NewsItem",
                Title         = "News item",
                ListLandingId = "NewsList",
                Content       = "News content"
            });

            s_mapRepo = new Data.InMemorySiteMapRepository();
        }
예제 #3
0
        public static void Setup(TestContext context)
        {
            s_repo = new Data.InMemorySiteContentRepository();
            s_repo.CreateContentAsync(
                new SimpleContent {
                Id = "page1", Title = "Page 1", Content = "<b>page1</b>"
            }
                ).Wait();

            s_mapRepo = new Data.InMemorySiteMapRepository();
        }
예제 #4
0
        public static void Setup(TestContext context)
        {
            _repo = new Data.InMemorySiteContentRepository();
            _repo.CreateContentAsync(
                new SimpleContent {
                Id = "page1", Title = "Page 1", Content = "<b>page1</b>"
            }
                ).Wait();
            _repo.CreateContentAsync(
                new ListLandingContent {
                Id = "page2", Title = "News", Content = "<i>News</i> items"
            }
                ).Wait();
            _repo.CreateContentAsync(
                new ListItemContent {
                Id = "listItem1", Title = "News1", Content = "News item", ListLandingId = "page2"
            }).Wait();

            _mapRepo = new Data.InMemorySiteMapRepository();
        }
        public void ItemAddsToSiteMap()
        {
            //Assemble
            var content = new SimpleContent {
                Id = "Mappable", Title = "MapMe", Content = "<b>mapped</b>"
            };

            s_repo.CreateContentAsync(content).GetAwaiter().GetResult();

            var controller = new ManageSimpleController(s_repo, s_mapRepo);

            //Act
            var result       = controller.Add(content.Id, content.Title).GetAwaiter().GetResult() as ViewResult;
            var isEntryInMap = s_mapRepo.IsItemInSiteMapAsync(content.Id).GetAwaiter().GetResult();
            var foundEntry   = s_mapRepo.GetMapAsync().GetAwaiter().GetResult()
                               .Entries.Where(
                (e) => e.ContentIdentifier == content.Id)
                               .FirstOrDefault();

            //Assert
            Assert.AreEqual <string>("SiteMapConfirm", result.ViewName, "Incorrect view returned");
            Assert.IsTrue(isEntryInMap, "Map entry not reported as in the site map");
            Assert.IsNotNull(foundEntry, "Entry not found manually in map");
        }
예제 #6
0
        public void EditListLandingContent()
        {
            //Assemble
            var controller = new ManageListController(s_repo, s_mapRepo);

            controller.ControllerContext = new ControllerContext(new FakeHttpContext(), new System.Web.Routing.RouteData(), controller);
            var content = new ListLandingContent {
                Id = "Edit", Title = "Edit", Content = "<b>Edit</b>"
            };

            s_repo.CreateContentAsync(content);
            content.Title   = "Edited";
            content.Content = "<i>Edited</i>";

            //Act
            var result     = controller.Edit(content.Id, content).GetAwaiter().GetResult() as ViewResult;
            var items      = s_repo.GetListOfItemsAsync(ContentType.ListLanding.ToString()).GetAwaiter().GetResult();
            var targetItem = items.Where((i) => i.Id == "Edit").FirstOrDefault();

            //Assert
            Assert.AreEqual <string>("Confirm", result.ViewName, "Confirmation view not returned");
            Assert.IsNotNull(targetItem, "Item not found after editing");
            Assert.AreEqual <string>("Edited", targetItem.Title, "Title does not reflect edits");
        }
예제 #7
0
        public void GetBannerExistingBanner()
        {
            //assemble
            s_repo.CreateContentAsync(
                new BannerContent {
                Id = "tb1", Title = "Test Banner", Content = "Test Banner Content"
            });

            var controller = new ManageBannerController(s_repo, s_mapRepo);

            //act
            var result = controller.Index().GetAwaiter().GetResult() as ViewResult;
            var model  = result.Model;

            //Assert
            Assert.IsNotNull(model, "Model not set for missing banner");
            Assert.IsInstanceOfType(model, typeof(BannerContent), "Model is not a banner content model");
            Assert.AreEqual <string>(Constants.KEY_BANNER_CONTENT, ((BannerContent)model).Id);
        }