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); }
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); }
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); } }
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); }
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); } }