public void MapFoldersWhenDirNotFound()
        {
            var fixture = new Fixture();
            var data    = fixture.Build <FolderItemDto>()
                          .With(x => x.DeleteAfter, "30d")
                          .With(x => x.FolderPath, "c:\\TEMP\\nonexistingfolderBEE34A23-572A-4C0E-BA9B-FF0A9671ACF7")
                          .CreateMany(5).ToList();

            var    obj = new FolderItemService(Mock.Of <IStorageService>());
            Action sut = () => obj.MapFolders(data);

            sut.Should().ThrowExactly <DirectoryNotFoundException>().WithMessage(@"c:\TEMP\nonexistingfolderBEE34A23-572A-4C0E-BA9B-FF0A9671ACF7 is not exists.");
        }
        public void MapFoldersWhenBadFolderInConfig()
        {
            var fileSystem = new MockFileSystem(new Dictionary <string, MockFileData>
            {
                { @"c:\temp\myfile.txt", new MockFileData("Data") }
            });

            var fixture = new Fixture();
            var data    = fixture.Build <FolderItemDto>()
                          .With(x => x.DeleteAfter, "30d")
                          .With(x => x.FolderPath, "c:\temp")
                          .CreateMany(5).ToList();

            var    obj = new FolderItemService(new StorageService(fileSystem));
            Action sut = () => obj.MapFolders(data);

            sut.Should().ThrowExactly <DirectoryNotFoundException>().WithMessage(@"c:	emp is not exists.");
        }
        public void MapFoldersInvalid(string timespan)
        {
            var fileSystem = new MockFileSystem(new Dictionary <string, MockFileData>
            {
                { @"c:\temp\myfile.txt", new MockFileData("Data") }
            });

            var fixture = new Fixture();
            var data    = fixture.Build <FolderItemDto>()
                          .With(x => x.DeleteAfter, timespan)
                          .With(x => x.FolderPath, @"c:\temp\")
                          .CreateMany(5).ToList();

            var    obj = new FolderItemService(new StorageService(fileSystem));
            Action sut = () => obj.MapFolders(data);

            sut.Should().ThrowExactly <ArgumentException>().WithMessage($"Bad DeleteAfter parameter {timespan}*");
        }
        public void MapFoldersValid(string timespan, double rez)
        {
            var fileSystem = new MockFileSystem(new Dictionary <string, MockFileData>
            {
                { @"c:\temp\myfile.txt", new MockFileData("Data") }
            });

            var fixture = new Fixture();
            var data    = fixture.Build <FolderItemDto>()
                          .With(x => x.DeleteAfter, timespan)
                          .With(x => x.FolderPath, @"c:\temp\")
                          .CreateMany(5).ToList();

            var obj = new FolderItemService(new StorageService(fileSystem));
            var sut = obj.MapFolders(data).ToList();

            sut.Count.Should().Be(5);
            sut[0].Should().BeEquivalentTo(data[0], x => x.Excluding(t => t.DeleteAfter));
            sut[0].DeleteAfter.Should().Be(TimeSpan.FromMinutes(rez));
            sut[4].Should().BeEquivalentTo(data[4], x => x.Excluding(t => t.DeleteAfter));
            sut[4].DeleteAfter.Should().Be(TimeSpan.FromMinutes(rez));
        }