public void Should_publish_if_project_was_found() { var locator = new FakeProjectLocator(new ChangedFile[] { new ChangedFile("someproject.csproj") }); _services.Stub(s => s.LocateAll<ILocateProjects>()).Return(new ILocateProjects[] { locator }); var fileChange = new FileChangeMessage(); fileChange.AddFile(new ChangedFile("asdf.cs")); _subject.Consume(fileChange); _bus.AssertWasCalled(b => b.Publish<ProjectChangeMessage>(null), b => b.IgnoreArguments()); }
public void When_finding_multiple_projects_all_should_be_published() { var locator = new FakeProjectLocator(new ChangedFile[] { new ChangedFile("FirstRootProject.csproj"), new ChangedFile("someproject.csproj") }); _services.Stub(s => s.LocateAll<ILocateProjects>()).Return(new ILocateProjects[] { locator }); var fileChange = new FileChangeMessage(); fileChange.AddFile(new ChangedFile(Path.Combine("SubFolder", Path.Combine("SecondSub", "asdf.cs")))); _subject.Consume(fileChange); _bus.AssertWasCalled(b => b.Publish<ProjectChangeMessage>(Arg<ProjectChangeMessage>.Matches(p => p.Files.Length.Equals(2)))); }
private void _batchTimer_Elapsed(object sender, ElapsedEventArgs e) { lock (_padLock) { if (_buffer.Count > 0) { Debug.AboutToPublishFileChanges(_buffer.Count); var fileChange = new FileChangeMessage(); fileChange.AddFile(_buffer.ToArray()); _bus.Publish(fileChange); } _buffer.Clear(); stopTimer(); } }
public void When_changed_file_is_project_mark_project_as_dirty() { var locator = new FakeProjectLocator(new ChangedFile[] { new ChangedFile("someproject.csproj") }); locator.WhenAskedIfFileIsProjectReturn(true); _services.Stub(s => s.LocateAll<ILocateProjects>()).Return(new ILocateProjects[] { locator }); var fileChange = new FileChangeMessage(); fileChange.AddFile(new ChangedFile("someproject.csproj")); _cache.Stub(c => c.Exists("someproject.csproj")).Return(true); _subject.Consume(fileChange); _cache.AssertWasCalled(c => c.Reload<Project>("someproject.csproj")); }
public void When_finding_more_projects_by_multiple_locators_the_ones_closest_to_the_changed_file_should_be_published() { var locator1 = new FakeProjectLocator(new ChangedFile[] { new ChangedFile("FirstRootProject.csproj") }); var locator2 = new FakeProjectLocator(new ChangedFile[] { new ChangedFile(Path.Combine("SubFolder", "FirstSubProject.vbproj")) }); var locator3 = new FakeProjectLocator(new ChangedFile[] { new ChangedFile(Path.Combine("SubFolder", "SecondSubProject.xproj")), new ChangedFile(Path.Combine("SubFolder", "ThirdSubProject.xproj")) }); _services.Stub(s => s.LocateAll<ILocateProjects>()).Return(new ILocateProjects[] { locator1, locator2, locator3 }); var fileChange = new FileChangeMessage(); fileChange.AddFile(new ChangedFile(Path.Combine("SubFolder", Path.Combine("SecondSub", "asdf.cs")))); _subject.Consume(fileChange); _bus.AssertWasCalled(b => b.Publish<ProjectChangeMessage>( Arg<ProjectChangeMessage>.Matches( p => p.Files.Length.Equals(3) && p.Files[0].Name.Equals("FirstSubProject.vbproj") && p.Files[1].Name.Equals("SecondSubProject.xproj") && p.Files[2].Name.Equals("ThirdSubProject.xproj")))); }