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")))); }
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 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_changed_file_is_project_handle_it() { 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")); _subject.Consume(fileChange); _marker.AssertWasCalled(m => m.HandleProjects(fileChange)); }
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)))); }
public void Should_serialize_file_change_message() { var file = new ChangedFile(System.Reflection.Assembly.GetExecutingAssembly().FullName); var message = new FileChangeMessage(); message.AddFile(file); var output = serializeDeserialize <FileChangeMessage>(message); output.Files.Length.ShouldEqual(1); output.Files[0].Name.ShouldEqual(file.Name); output.Files[0].FullName.ShouldEqual(file.FullName); output.Files[0].Extension.ShouldEqual(file.Extension); }
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 Should_add_projects_that_doesnt_exist() { var project = new Project("", new ProjectDocument(ProjectType.VisualBasic)); var cache = MockRepository.GenerateMock <ICache>(); var message = new FileChangeMessage(); message.AddFile(new ChangedFile(string.Format("TestResources{0}VS2008{0}NUnitTestProjectVisualBasic.vbproj", Path.DirectorySeparatorChar))); cache.Stub(c => c.Get <Project>(message.Files[0].FullName)).Return(null).Repeat.Once(); cache.Stub(c => c.Get <Project>(message.Files[0].FullName)).Return(project).Repeat.Once(); var marker = new ProjectRebuildMarker(cache); marker.HandleProjects(message); cache.AssertWasCalled(c => c.Add <Project>(message.Files[0].FullName)); }
private void _batchTimer_Elapsed(object sender, ElapsedEventArgs e) { Debug.AboutToPublishFileChanges(_buffer.Count); var fileChange = new FileChangeMessage(); while (_buffer.Count > 0) { var file = _buffer.Pop(); fileChange.AddFile(file); } if (fileChange.Files.Length > 0) { _bus.Publish(fileChange); } stopTimer(); }
public void Should_not_consume_regular_file() { _files.AddFile(new ChangedFile("someTextFile.txt")); _consumer.Consume(_files); _bus.AssertWasNotCalled(b => b.Publish <AssemblyChangeMessage>(null), b => b.IgnoreArguments()); }
private void _batchTimer_Elapsed(object sender, ElapsedEventArgs e) { Debug.AboutToPublishFileChanges(_buffer.Count); var fileChange = new FileChangeMessage(); while (_buffer.Count > 0) { var file = _buffer.Pop(); fileChange.AddFile(file); } if (fileChange.Files.Length > 0) _bus.Publish(fileChange); stopTimer(); }
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")))); }
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")); }