예제 #1
0
        public void TestModifyFile_InvokesProcessor()
        {
            const string input = @"{
  ""file"": [ ""test1.html"", ""test2.html"" ],
  ""template"":  [""templates/**.html""],
  ""content"": [""**.html""]
    }
";
            var fileSystem = new InMemoryFileSystem(new[]
            {
                "test1.html", "test2.html", "templates/tmpl1.html", "templates/tmpl2.html"
            });

            const string filePath = "templates/tmpl3.html";
            const string filePath2 = "content.html";
            var result = Project.FromFile(input, fileSystem);

            var processor = new Mock<IProjectObserver>(MockBehavior.Strict);
            processor.Setup(f =>
                f.NotifyItemAdded(result, It.Is<FileProjectItem>(i => i.FileInfo.FilePath.ToString() == filePath && i.Identifier.Kind == "template")));
            processor.Setup(f =>
                f.NotifyItemAdded(result, It.Is<FileProjectItem>(i => i.FileInfo.FilePath.ToString() == filePath && i.Identifier.Kind == "content")));
            processor.Setup(f =>
                f.NotifyItemAdded(result, It.Is<FileProjectItem>(i => i.FileInfo.FilePath.ToString() == filePath2 && i.Identifier.Kind == "content")));

            processor.Setup(f =>
                f.NotifyItemRemoved(result, It.Is<FileProjectItem>(i => i.FileInfo.FilePath.ToString() == filePath2 && i.Identifier.Kind == "content")));

            result.AddObserver(processor.Object);

            fileSystem.Add(filePath);
            // Not included file
            fileSystem.Add("templates/test.json");

            fileSystem.Add(filePath2);

            fileSystem.RemoveFile(PathInfo.Create(filePath2));

            processor.VerifyAll();
        }