Example #1
0
        public void Should_set_id_in_site_deleted_event()
        {
            var site = SiteFactory.CreateNew();

            site.Delete();

            var @event = site.Events.OfType <SiteDeleted>().SingleOrDefault();

            Assert.AreEqual(site.Id, @event.AggregateRootId);
        }
Example #2
0
        public void Should_set_name_in_site_deleted_event()
        {
            var site = SiteFactory.CreateNew();

            site.Delete();

            var @event = site.Events.OfType <SiteDeleted>().SingleOrDefault();

            Assert.AreEqual(site.Name, @event.Name);
        }
Example #3
0
        public void Should_save_new_site()
        {
            var newSite = SiteFactory.CreateNew(Guid.NewGuid(), "Name 3");

            using (var context = new MSSQLDbContext(_contextOptions))
            {
                var repository = new SiteRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper());
                repository.Create(newSite);
            }

            using (var context = new MSSQLDbContext(_contextOptions))
            {
                var repository = new SiteRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper());
                var language   = repository.GetById(newSite.Id);

                Assert.NotNull(language);
            }
        }
Example #4
0
        public void Should_return_true_if_page_is_set_as_home_page()
        {
            var siteId = Guid.NewGuid();
            var pageId = Guid.NewGuid();

            var site = SiteFactory.CreateNew();

            site.Update(pageId);

            var repositoryMock = new Mock <ISiteRepository>();

            repositoryMock.Setup(x => x.GetById(siteId)).Returns(site);

            var sut = new SiteRules(repositoryMock.Object);

            var actual = sut.IsPageSetAsHomePage(siteId, pageId);

            Assert.AreEqual(true, actual);
        }
Example #5
0
        public void Should_update_site()
        {
            const string newSiteName = "New Title 1";

            var siteToUpdate = SiteFactory.CreateNew(_siteId1, newSiteName);

            using (var context = new MSSQLDbContext(_contextOptions))
            {
                var repository = new SiteRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper());
                repository.Update(siteToUpdate);
            }

            using (var context = new MSSQLDbContext(_contextOptions))
            {
                var repository  = new SiteRepository(DbContextShared.CreateNewContextFactory(context), Shared.CreateNewMapper());
                var updatedSite = repository.GetById(_siteId1);

                Assert.AreEqual(newSiteName, updatedSite.Name);
            }
        }