public void FileSystemWatcher_RazorDocumentOutputEvent_InvokesOutputListeners() { // Arrange var projectInstance = new ProjectInstance(ProjectRootElement.Create()); void AssertCallbackArgs(RazorFileChangeEventArgs args) { Assert.Equal("/path/to/file.cshtml", args.FilePath); Assert.Equal(RazorFileChangeKind.Removed, args.Kind); Assert.Same(projectInstance, args.UnevaluatedProjectInstance); } var listener1 = new Mock <IRazorDocumentOutputChangeListener>(MockBehavior.Strict); listener1.Setup(listener => listener.RazorDocumentOutputChanged(It.IsAny <RazorFileChangeEventArgs>())) .Callback <RazorFileChangeEventArgs>((args) => AssertCallbackArgs(args)) .Verifiable(); var listener2 = new Mock <IRazorDocumentOutputChangeListener>(MockBehavior.Strict); listener2.Setup(listener => listener.RazorDocumentOutputChanged(It.IsAny <RazorFileChangeEventArgs>())) .Callback <RazorFileChangeEventArgs>((args) => AssertCallbackArgs(args)) .Verifiable(); var detector = new MSBuildProjectDocumentChangeDetector( Enumerable.Empty <IRazorDocumentChangeListener>(), new[] { listener1.Object, listener2.Object }); // Act detector.FileSystemWatcher_RazorDocumentOutputEvent("/path/to/file.cshtml", projectInstance, RazorFileChangeKind.Removed); // Assert listener1.VerifyAll(); listener2.VerifyAll(); }
public void ResolveRelativeFilePath_NotRelative_ReturnsOriginalPath() { // Arrange var filePath = "file.cshtml"; var projectDirectory = "/path/project"; // Act var relativePath = MSBuildProjectDocumentChangeDetector.ResolveRelativeFilePath(filePath, projectDirectory); // Assert Assert.Equal(filePath, relativePath); }