public void Can_Delete()
        {
            int contentId = CreateTestData("en-AU", out ContentType ct);

            IScopeProvider provider = ScopeProvider;

            using (IScope scope = provider.CreateScope())
            {
                DomainRepository repo = CreateRepository(provider);

                ILanguage lang    = LanguageRepository.GetByIsoCode("en-AU");
                IContent  content = DocumentRepository.Get(contentId);

                var domain = (IDomain) new UmbracoDomain("test.com")
                {
                    RootContentId = content.Id, LanguageId = lang.Id
                };
                repo.Save(domain);

                repo.Delete(domain);

                // re-get
                domain = repo.Get(domain.Id);

                Assert.IsNull(domain);
            }
        }
        public void WhenEntityDeleted_ThenPersists()
        {
            DatabaseTestUtility.DropCreateFirebrickDatabase();

            // Arrange
            var repository = new DomainRepository(new DatabaseFactory());
            Domain entity = DefaultModelHelper.DummyPopulatedDomain();

            // Act
            repository.Add(entity);
            repository.Commit();
            IEnumerable<Domain> returnedEntities = repository.GetAll();

            // Assert
            Assert.Equal(1, returnedEntities.Count());

            // Act
            repository.Delete(entity);
            repository.Commit();

            // Arrange
            // Use a new context and repository to verify the vehicle was deleted
            var repositoryTwo = new DomainRepository(new DatabaseFactory());
            IEnumerable<Domain> verifyEntities = repositoryTwo.GetAll();

            // Assert
            Assert.NotNull(verifyEntities);
            Assert.Equal(0, verifyEntities.Count());
        }
Ejemplo n.º 3
0
        public void TestDeleteDraftItem()
        {
            ItemSetUp();

            With.Transaction(delegate
            {
                DomainRepository <T> .Delete(DraftItem);
            });
            Assert.IsNull(DomainRepository <T> .GetGlobal(DraftItem.ObjectId));
            Assert.IsNull(DomainRepository <T> .GetDraft(DraftItem.ObjectId));
        }
Ejemplo n.º 4
0
        protected void ItemSetUp()
        {
            DraftItem = CreateAndSave();

            ActiveItem = DomainRepository <T> .AddNew();

            ActiveItem.Publish();
            SaveItem(ActiveItem);

            ArchivedItem = DomainRepository <T> .AddNew();

            ArchivedItem.Publish();
            ArchivedItem.Archive();
            SaveItem(ArchivedItem);

            ActiveDeletedItem = DomainRepository <T> .AddNew();

            ActiveDeletedItem.Publish();
            With.Transaction(delegate
            {
                DomainRepository <T> .Delete(ActiveDeletedItem);
            });

            ArchivedDeletedItem = DomainRepository <T> .AddNew();

            ArchivedDeletedItem.Publish();
            ArchivedDeletedItem.Archive();
            With.Transaction(delegate
            {
                DomainRepository <T> .Delete(ArchivedDeletedItem);
            });


            DraftDeletedItem = DomainRepository <T> .AddNew();

            With.Transaction(delegate
            {
                DomainRepository <T> .Delete(DraftDeletedItem);
            });
        }