Exemplo n.º 1
0
        public void FileWithSlash_ReturnsNull()
        {
            // Arrange

            // folder structure:
            // /root
            //   /foo
            //      /bar.cs
            // testing that a file specified as foo/bar in folder root will return null
            var vpp = new Mock <VirtualPathProvider>();

            var mockRootDir = new Mock <VirtualDirectory>("root");

            var mockFooDir = new Mock <VirtualDirectory>("foo");

            var mockFile = new Mock <VirtualFile>("/root/foo/bar.cs");

            mockFooDir.SetupGet(v => v.Files).Returns(new[] { mockFile.Object });

            mockRootDir.SetupGet(v => v.Directories).Returns(new[] { mockFooDir.Object });

            vpp.Setup(v => v.GetDirectory("root")).Returns(mockRootDir.Object);

            // Act
            var actual = Themes.FindMatchingFile(vpp.Object, "root", "foo/bar.cs");

            // Assert
            Assert.IsNull(actual);
        }
Exemplo n.º 2
0
        public void EmptyDirectory_MatchingFile_ReturnsNull()
        {
            // Arrange

            // build vpp
            var vpp = new Mock <VirtualPathProvider>();

            var mockNoFilesDir = new Mock <VirtualDirectory>("nofiles");

            vpp.Setup(v => v.GetDirectory("nofiles")).Returns(mockNoFilesDir.Object);

            // Act
            var actual = Themes.FindMatchingFile(vpp.Object, "nofiles", "file.cs");

            // Assert
            Assert.IsNull(actual);
        }
Exemplo n.º 3
0
        public void MatchingFiles_ReturnsCorrectFile()
        {
            // Arrange

            // build vpp
            var vpp = new Mock <VirtualPathProvider>();

            var mockNoMatchingFilesDir = new Mock <VirtualDirectory>("nomatchingfiles");

            var mockFile = new Mock <VirtualFile>("/nomatchingfiles/foo.cs");

            mockNoMatchingFilesDir.SetupGet(v => v.Files).Returns(new[] { mockFile.Object });

            vpp.Setup(v => v.GetDirectory("nomatchingfiles")).Returns(mockNoMatchingFilesDir.Object);

            // Act
            var bar = Themes.FindMatchingFile(vpp.Object, "nomatchingfiles", "bar.cs");
            var foo = Themes.FindMatchingFile(vpp.Object, "nomatchingfiles", "foo.cs");

            // Assert
            Assert.IsNull(bar);
            Assert.AreEqual("/nomatchingfiles/foo.cs", foo);
        }