Ejemplo n.º 1
0
            public void ShouldSupplyRelativePathOnDemand()
            {
                // Arrange
                using var tempFolder = new AutoTempFolder();
                var file1     = tempFolder.CreateRandomFile();
                var sub       = tempFolder.CreateRandomFolder();
                var file2     = Path.Combine(sub, CreateRandomFileIn(sub));
                var expected1 = Path.GetRelativePath(tempFolder.Path, file1);
                var expected2 = Path.GetRelativePath(tempFolder.Path, file2);
                var sut       = Create(tempFolder);
                // Act
                var results = sut.ListResourcesRecursive();

                // Assert
                Expect(results)
                .To.Contain.Only(2)
                .Items();
                Expect(results)
                .To.Contain.Exactly(1)
                .Matched.By(o => o.RelativePath == expected1 &&
                            o.Path == file1);
                Expect(results)
                .To.Contain.Exactly(1)
                .Matched.By(o => o.RelativePath == expected2 &&
                            o.Path == file2);
            }
Ejemplo n.º 2
0
            public void ShouldIgnoreEmptyFoldersUnderBase()
            {
                // Arrange
                using var tempFolder = new AutoTempFolder();
                var path = tempFolder.CreateRandomFolder();
                var sut  = Create(tempFolder);

                Expect(path)
                .To.Exist();
                // Act
                var results = sut.ListResourcesRecursive();

                // Assert
                Expect(results)
                .To.Be.Empty();
            }
Ejemplo n.º 3
0
            public void ShouldListResourcesUnderFolders()
            {
                // Arrange
                using var tempFolder = new AutoTempFolder();
                var file1 = tempFolder.CreateRandomFile();
                var sub1  = tempFolder.CreateRandomFolder();
                var file2 = Path.Combine(sub1, CreateRandomFileIn(sub1));
                var file3 = Path.Combine(sub1, CreateRandomFileIn(sub1));
                var sub2  = Path.Combine(sub1, CreateRandomFolderIn(sub1));
                var file4 = Path.Combine(sub2, CreateRandomFileIn(sub2));

                new[]
                {
                    file1,
                    sub1,
                    file2,
                    file3,
                    sub2,
                    file4
                }.ForEach(o => Expect(o)
                          .To.Exist());
                var sut = Create(tempFolder);
                // Act
                var result = sut.ListResourcesRecursive();

                // Assert
                Expect(result)
                .To.Contain.Only(4)
                .Items();
                Expect(result)
                .To.Contain.Exactly(1)
                .Matched.By(o => o.Path == file1);
                Expect(result)
                .To.Contain.Exactly(1)
                .Matched.By(o => o.Path == file2);
                Expect(result)
                .To.Contain.Exactly(1)
                .Matched.By(o => o.Path == file3);
                Expect(result)
                .To.Contain.Exactly(1)
                .Matched.By(o => o.Path == file4);
            }