Beispiel #1
0
        public void CreatePostRepostedTest()
        {
            PostAuthoringController sut = new PostAuthoringController(
                _postRepo,
                _postModificationRepo,
                _userRepo,
                _redirectRepo,
                _securableRepo,
                _blogRepo,
                _mockSecurityHelper.Object,
                new MockDateTimeProvider(new DateTime(2013, 1, 2)),
                _mockHttpContext.Object);

            var result = sut.Create(new Areas.Manage.Models.PostEditModel
            {
                Title        = "Test Title",
                Body         = "Test Body",
                Description  = "Test Description",
                Reposted     = true,
                CanonicalUrl = "http://someotherblog.com/post"
            }) as RedirectToRouteResult;

            Assert.IsNotNull(result);

            Assert.AreEqual("Index", result.RouteValues["action"]);
            Assert.AreEqual("Dashboard", result.RouteValues["controller"]);

            Assert.AreEqual(2, _postRepo.GetAll().Count());
            Assert.AreEqual("http://someotherblog.com/post", _postRepo.GetAll().Last().Canonical);
        }
Beispiel #2
0
        public void CreatePostContentTest()
        {
            PostAuthoringController sut = new PostAuthoringController(
                _postRepo,
                _postModificationRepo,
                _userRepo,
                _redirectRepo,
                _securableRepo,
                _blogRepo,
                _mockSecurityHelper.Object,
                new DateTimeProvider(),
                _mockHttpContext.Object);

            var result = sut.Create(new Areas.Manage.Models.PostEditModel
            {
                Title       = "Test Title",
                Body        = "Test Body",
                Description = "Test Description",
                Reposted    = false
            }) as RedirectToRouteResult;

            Assert.IsNotNull(result);

            Assert.AreEqual("Index", result.RouteValues["action"]);
            Assert.AreEqual("Dashboard", result.RouteValues["controller"]);

            Assert.AreEqual(2, _postRepo.GetAll().Count());
            Assert.IsNull(_postRepo.GetAll().Last().Title);
            Assert.IsNull(_postRepo.GetAll().Last().Body);
            Assert.IsNull(_postRepo.GetAll().Last().Description);
            Assert.AreEqual("Test Title", _postRepo.GetAll().Last().DraftTitle);
            Assert.AreEqual("Test Body", _postRepo.GetAll().Last().DraftBody);
            Assert.AreEqual("Test Description", _postRepo.GetAll().Last().DraftDescription);
        }
Beispiel #3
0
        public void CreatePostAuthorTest()
        {
            var userRepo = new SimpleRepository <Data.User>(new InMemoryRepositoryDataSource <Data.User>(new List <Data.User> {
                new Data.User {
                    Id = 1,
                    //ClaimedIdentifier = "zzz",
                    Email = "*****@*****.**"
                }
            }));

            PostAuthoringController sut = new PostAuthoringController(
                _postRepo,
                _postModificationRepo,
                userRepo,
                _redirectRepo,
                _securableRepo,
                _blogRepo,
                _mockSecurityHelper.Object,
                new MockDateTimeProvider(new DateTime(2013, 1, 2)),
                _mockHttpContext.Object);

            var result = sut.Create(new Areas.Manage.Models.PostEditModel
            {
                Title        = "Test Title",
                Body         = "Test Body",
                Description  = "Test Description",
                Reposted     = true,
                CanonicalUrl = "http://someotherblog.com/post"
            }) as RedirectToRouteResult;

            Assert.IsNotNull(result);

            Assert.AreEqual("Index", result.RouteValues["action"]);
            Assert.AreEqual("Dashboard", result.RouteValues["controller"]);

            Assert.AreEqual(2, _postRepo.GetAll().Count());
            Assert.AreEqual(1, _postRepo.GetAll().Last().AuthorId);
        }