Deletes the given cache directory as an additional clean step
Inheritance: ICleanExtension
Esempio n. 1
0
        public void DeletesCacheDirectory()
        {
            var be = new Mock<IBuilderEnumerator>();
            be.Setup(b => b.GetAllPersistentBuilders()).Returns(new Type[0]);

            var parameters = new Mock<ICleanParameters>();
            var predicates = new SoftCleanPredicates();
            var cdir = new TestFileSystemDirectory("cache");
            var cleaner = new CacheCleaner(new Lazy<IFileSystemDirectory>(() => cdir), be.Object, () => predicates);

            cdir.IsDeleted.Should().BeFalse();
            cleaner.Clean(parameters.Object);
            cdir.IsDeleted.Should().BeTrue();
        }
Esempio n. 2
0
        public void KeepsPersistentReferences()
        {
            var cdir = new TestFileSystemDirectory("cache",
                new[]
                {
                    new TestFileSystemDirectory("Bari.Core.Test.Build.Cache.NonPersistentReference_1"),
                    new TestFileSystemDirectory("Bari.Core.Test.Build.Cache.NonPersistentReference_2"),
                    new TestFileSystemDirectory("Bari.Core.Test.Build.Cache.PersistentReference_3"),
                    new TestFileSystemDirectory("Bari.Core.Test.Build.Cache.PersistentReference_4")
                });

            var be = new Mock<IBuilderEnumerator>();
            be.Setup(b => b.GetAllPersistentBuilders()).Returns(new[] {typeof(PersistentReference)});

            var predicates = new SoftCleanPredicates();
            var cleaner = new CacheCleaner(new Lazy<IFileSystemDirectory>(() => cdir), be.Object, () => predicates);

            cdir.IsDeleted.Should().BeFalse();
            ((TestFileSystemDirectory) cdir.GetChildDirectory("Bari.Core.Test.Build.Cache.NonPersistentReference_1"))
                .IsDeleted.Should().BeFalse();
            ((TestFileSystemDirectory)cdir.GetChildDirectory("Bari.Core.Test.Build.Cache.NonPersistentReference_2"))
                .IsDeleted.Should().BeFalse();
            ((TestFileSystemDirectory)cdir.GetChildDirectory("Bari.Core.Test.Build.Cache.PersistentReference_3"))
                .IsDeleted.Should().BeFalse();
            ((TestFileSystemDirectory)cdir.GetChildDirectory("Bari.Core.Test.Build.Cache.PersistentReference_4"))
                .IsDeleted.Should().BeFalse();

            var parameters = new Mock<ICleanParameters>();
            parameters.SetupGet(p => p.KeepReferences).Returns(true);

            cleaner.Clean(parameters.Object);

            cdir.IsDeleted.Should().BeFalse();
            ((TestFileSystemDirectory)cdir.GetChildDirectory("Bari.Core.Test.Build.Cache.NonPersistentReference_1"))
                .IsDeleted.Should().BeTrue();
            ((TestFileSystemDirectory)cdir.GetChildDirectory("Bari.Core.Test.Build.Cache.NonPersistentReference_2"))
                .IsDeleted.Should().BeTrue();
            ((TestFileSystemDirectory)cdir.GetChildDirectory("Bari.Core.Test.Build.Cache.PersistentReference_3"))
                .IsDeleted.Should().BeFalse();
            ((TestFileSystemDirectory)cdir.GetChildDirectory("Bari.Core.Test.Build.Cache.PersistentReference_4"))
                .IsDeleted.Should().BeFalse();
        }