コード例 #1
0
        public void TestInitialize()
        {
            var filesystem = new Mock <IFileSystem>(MockBehavior.Strict);

            this.mockDirectoryFactory = new Mock <IDirectoryInfoFactory>(MockBehavior.Strict);
            filesystem.Setup(m => m.DirectoryInfo).Returns(this.mockDirectoryFactory.Object);

            this.mockRootDirectory = new Mock <DirectoryInfoBase>(MockBehavior.Strict);
            this.mockDirectoryFactory.Setup(m => m.FromDirectoryName(RootDirectoryName))
            .Returns(() => this.mockRootDirectory.Object);

            this.yearDirectory = new Mock <DirectoryInfoBase>(MockBehavior.Strict);
            this.yearDirectory.Setup(m => m.Parent).Returns((DirectoryInfoBase)null);
            this.yearDirectory.Setup(m => m.Name).Returns("2013");
            this.monthDirectory = new Mock <DirectoryInfoBase>(MockBehavior.Strict);
            this.monthDirectory.Setup(m => m.Parent).Returns(this.yearDirectory.Object);
            this.monthDirectory.Setup(m => m.Name).Returns("12");
            this.dayDirectory = new Mock <DirectoryInfoBase>(MockBehavior.Strict);
            this.dayDirectory.Setup(m => m.Parent).Returns(this.monthDirectory.Object);
            this.dayDirectory.Setup(m => m.Name).Returns("31");
            this.hourDirectory = new Mock <DirectoryInfoBase>(MockBehavior.Strict);
            this.hourDirectory.Setup(m => m.Parent).Returns(this.dayDirectory.Object);
            this.hourDirectory.Setup(m => m.Name).Returns("24");
            this.hourDirectory.Setup(m => m.GetDirectories()).Returns(new DirectoryInfoBase[0]);

            var directoryList = new List <Mock <DirectoryInfoBase> > {
                this.hourDirectory
            };

            this.mockRootDirectory.Setup(m => m.GetDirectories(It.IsAny <string>(), SearchOption.AllDirectories))
            .Returns(directoryList.Select(i => i.Object).ToArray());

            this.target = new ImageDeleter(filesystem.Object);
        }
コード例 #2
0
        public void DeleteAllFromZip()
        {
            using (var folder = UnzipTestFiles())
            {
                var directoryInfo = folder.DirectoryInfo;
                var imageDeleter  = new ImageDeleter();

                imageDeleter.Run(new DateTime(2014, 12, 04, 15, 0, 0), directoryInfo.FullName);
                AssertFileCount(directoryInfo, 0);
            }
        }
コード例 #3
0
        public void DeleteSeptemberFromZip()
        {
            using (var folder = UnzipTestFiles())
            {
                var       directoryInfo          = folder.DirectoryInfo;
                var       imageDeleter           = new ImageDeleter();
                const int numberOfImagesToDelete = 1092 + 1092 + 1092;

                imageDeleter.Run(new DateTime(2014, 12, 04, 12, 0, 0), directoryInfo.FullName);
                AssertFileCount(directoryInfo, 3340 - numberOfImagesToDelete);
            }
        }