public async Task DeletesUnreferencedClientsInInaccessibleWorkspaces() { var accessibleWorkspace = new MockWorkspace(1000, isInaccessible: false); var inaccessibleWorkspace = new MockWorkspace(2000, isInaccessible: true); var client1 = new MockClient(1001, accessibleWorkspace, SyncStatus.InSync); var client2 = new MockClient(1002, accessibleWorkspace, SyncStatus.SyncNeeded); var client3 = new MockClient(2001, inaccessibleWorkspace, SyncStatus.SyncNeeded); var client4 = new MockClient(2002, inaccessibleWorkspace, SyncStatus.InSync); var project1 = new MockProject(101, accessibleWorkspace, client1, syncStatus: SyncStatus.InSync); var project2 = new MockProject(102, accessibleWorkspace, client2, syncStatus: SyncStatus.InSync); var project3 = new MockProject(201, inaccessibleWorkspace, client3, syncStatus: SyncStatus.InSync); var clients = new[] { client1, client2, client3, client4 }; var projects = new[] { project1, project2, project3 }; var unreferencedClients = new[] { client4 }; var neededClients = clients.Where(client => !unreferencedClients.Contains(client)); configureDataSource(clients, projects); await state.Start().SingleAsync(); clientsDataSource.Received().DeleteAll(Arg.Is <IEnumerable <IThreadSafeClient> >(arg => arg.All(client => unreferencedClients.Contains(client)) && arg.None(client => neededClients.Contains(client)))); }
public override void MainSetup() { base.MainSetup(); _MockSolution.InitializeWithTargetAndMixinInSeparateProjects(); //Warm Caches by loading solution. var solution = TestSpecificKernel.Get<ISolutionFactory>().BuildCurrentSolution(); //Ensure All Classes are is in the solution foreach(var file in _MockSolution.AllMockSourceFiles) Assert.True(null != solution.FindCSharpFileByFileName(file.FileName), "{0} was not found in Solution. Test Environment is not valid.", file.FileName); //Simulate Project Item Removed (Basic Class) _projectToRemove = _MockSolution.Projects[0]; _MockSolution.Projects = _MockSolution.Projects.Skip(1).ToList(); //Fire Project Item Event EventProxy.FireOnProjectRemoved(this, new ProjectRemovedEventArgs { ProjectFullPath = _projectToRemove.FileName }); }
public void RemoveDirectoryWithEmptySubFolderShouldDeleteWholeFolderStructure() { MockProject sourceProject = new MockProject(@"c:\mockPath1\project1.csproj"); MockProject targetProject = new MockProject(); MockProjectItem folder = new MockProjectItem("MyFolder") { Kind = Constants.vsProjectItemKindPhysicalFolder }; MockProjectItem subFolder = new MockProjectItem("EmptySubFolder") { Kind = Constants.vsProjectItemKindPhysicalFolder }; folder.ProjectItems.AddProjectItem(subFolder); targetProject.ProjectItems.AddProjectItem(folder); string sourceFolder = Path.Combine(@"c:\mockPath1", @"MyFolder"); ProjectItemsSynchronizer syncher = new ProjectItemsSynchronizer(sourceProject, targetProject, new MockLogger(), null, new MockProjectItemsFilter()); Assert.AreEqual(1, targetProject.ProjectItems.Count); syncher.DirectoryRemovedFromSource(sourceFolder); Assert.IsTrue(folder.DeleteCalled); }
public async Task DeleteProjectsUnreferencedByTimeEntriesInInaccessibleWorkspace() { var accessibleWorkspace = new MockWorkspace(1000, isInaccessible: false); var inaccessibleWorkspace = new MockWorkspace(2000, isInaccessible: true); var project1 = new MockProject(101, accessibleWorkspace, syncStatus: SyncStatus.InSync); var project2 = new MockProject(102, accessibleWorkspace, syncStatus: SyncStatus.RefetchingNeeded); var project3 = new MockProject(201, inaccessibleWorkspace, syncStatus: SyncStatus.InSync); var project4 = new MockProject(202, inaccessibleWorkspace, syncStatus: SyncStatus.SyncNeeded); var project5 = new MockProject(203, inaccessibleWorkspace, syncStatus: SyncStatus.SyncNeeded); var project6 = new MockProject(204, inaccessibleWorkspace, syncStatus: SyncStatus.InSync); var project7 = new MockProject(205, inaccessibleWorkspace, syncStatus: SyncStatus.InSync); var te1 = new MockTimeEntry(10001, accessibleWorkspace, project: project1, syncStatus: SyncStatus.InSync); var te2 = new MockTimeEntry(10002, accessibleWorkspace, project: project2, syncStatus: SyncStatus.SyncNeeded); var te3 = new MockTimeEntry(20001, inaccessibleWorkspace, project: project3, syncStatus: SyncStatus.InSync); var te4 = new MockTimeEntry(20002, inaccessibleWorkspace, project: project4, syncStatus: SyncStatus.SyncNeeded); var te5 = new MockTimeEntry(20003, inaccessibleWorkspace, project: project4, syncStatus: SyncStatus.SyncFailed); var te6 = new MockTimeEntry(20004, inaccessibleWorkspace, project: project4, syncStatus: SyncStatus.InSync); var projects = new[] { project1, project2, project3, project4, project5, project6, project7 }; var tasks = new IThreadSafeTask[] { }; var timeEntries = new[] { te1, te2, te3, te4, te5, te6 }; var unreferencedProjects = new[] { project6, project7 }; var neededProjects = projects.Where(project => !unreferencedProjects.Contains(project)); configureDataSource(projects, tasks, timeEntries); await state.Start().SingleAsync(); projectsDataSource.Received().DeleteAll(Arg.Is <IEnumerable <IThreadSafeProject> >(arg => arg.All(project => unreferencedProjects.Contains(project)) && arg.None(project => neededProjects.Contains(project)))); }
public void ShouldAddFileInCorrectSubfolder() { MockLogger mockLogger = new MockLogger(); MockProject sourceProject = new MockProject(@"c:\mockPath1\project1.csproj"); MockProject targetProject = new MockProject(); MockProjectItem sourceFolder = new MockProjectItem("MyFolder") { Kind = Constants.vsProjectItemKindPhysicalFolder }; sourceProject.ProjectItems.AddProjectItem(sourceFolder); sourceFolder.ProjectItems.AddProjectItem(new MockProjectItem("MyFile.txt")); MockProjectItem targetFolder = new MockProjectItem("MyFolder") { Kind = Constants.vsProjectItemKindPhysicalFolder }; targetProject.ProjectItems.AddProjectItem(targetFolder); ProjectItemsSynchronizer syncher = new ProjectItemsSynchronizer(sourceProject, targetProject, mockLogger, null, new MockProjectItemsFilter()); string fileToAdd = @"c:\mockPath1\MyFolder\MyFile.txt"; syncher.FileAddedToSource(fileToAdd); Assert.IsTrue(targetFolder.ProjectItems.AddFromFileCalled); Assert.AreEqual(1, targetFolder.ProjectItems.Count); StringAssert.EndsWith(targetFolder.ProjectItems.Item(0).Name, "MyFile.txt"); Assert.AreEqual(1, mockLogger.MessageLog.Count); StringAssert.Contains(mockLogger.MessageLog[0], "added"); StringAssert.Contains(mockLogger.MessageLog[0], @"MyFolder\MyFile.txt"); }
public void SetUpFixture() { RubyMSBuildEngineHelper.InitMSBuildEngine(); List <ProjectBindingDescriptor> bindings = new List <ProjectBindingDescriptor>(); using (TextReader reader = RubyBindingAddInFile.ReadAddInFile()) { AddIn addin = AddIn.Load(reader, String.Empty); bindings.Add(new ProjectBindingDescriptor(AddInHelper.GetCodon(addin, "/SharpDevelop/Workbench/ProjectBindings", "Ruby"))); } ProjectBindingService.SetBindings(bindings); convertProjectCommand = new DerivedConvertProjectToRubyProjectCommand(); parseInfo = new ParseInformation(new DefaultCompilationUnit(new DefaultProjectContent())); convertProjectCommand.ParseInfo = parseInfo; convertProjectCommand.FileServiceDefaultEncoding = Encoding.Unicode; sourceProject = new MockProject(); sourceProject.Directory = @"d:\projects\test"; source = new FileProjectItem(sourceProject, ItemType.Compile, @"src\Program.cs"); targetProject = (RubyProject)convertProjectCommand.CallCreateProject(@"d:\projects\test\converted", sourceProject); target = new FileProjectItem(targetProject, source.ItemType, source.Include); source.CopyMetadataTo(target); textFileSource = new FileProjectItem(sourceProject, ItemType.None, @"src\readme.txt"); textFileTarget = new FileProjectItem(targetProject, textFileSource.ItemType, textFileSource.Include); textFileSource.CopyMetadataTo(textFileTarget); convertProjectCommand.AddParseableFileContent(source.FileName, sourceCode); convertProjectCommand.CallConvertFile(source, target); convertProjectCommand.CallConvertFile(textFileSource, textFileTarget); }
public void CannotParseNonRubyLanguageProject() { MockProject project = new MockProject(); project.Language = "Test"; Assert.IsFalse(parser.CanParse(project)); }
public void ShouldIncludeDirectoryInTargetWhenItsPresentInFileSystem() { MockIVsSolution mockSolution = new MockIVsSolution(); MockVsHierarchy mockTargetVsHierarchy = new MockVsHierarchy(); MockProject sourceProject = new MockProject(@"c:\mockPath1\project1.csproj"); MockProject targetProject = new MockProject(@"c:\mockPath2\project1.csproj"); mockTargetVsHierarchy.GetPropertyProjectValue = targetProject; mockSolution.Hierarchies.Add(mockTargetVsHierarchy); MockHierarchyHelper mockHierarchyHelper = new MockHierarchyHelper(); MockLogger mockLogger = new MockLogger(); ProjectItemsSynchronizer syncher = new ProjectItemsSynchronizer(sourceProject, targetProject, mockLogger, mockSolution, mockHierarchyHelper, new MockProjectItemsFilter()); string directoryToAdd = @"c:\mockPath1\MyFolder\"; targetProject.ProjectItems.ThrowOnAddFolder = true; syncher.DirectoryAddedToSource(directoryToAdd); Assert.IsTrue(mockTargetVsHierarchy.AddItemCalled); Assert.AreEqual(VSConstants.VSITEMID_ROOT, mockTargetVsHierarchy.AddItemArgumentItemidLoc); Assert.AreEqual(string.Empty, mockTargetVsHierarchy.AddItemArgumentItemName); Assert.AreEqual <uint>(1, mockTargetVsHierarchy.AddItemArgumentFilesToOpen); Assert.AreEqual(@"c:\mockPath2\MyFolder", mockTargetVsHierarchy.AddItemArgumentArrayFilesToOpen[0]); }
public void ShouldRemoveLinkedFolderWhenDeletingFolderFromSource() { MockLogger mockLogger = new MockLogger(); MockProject sourceProject = new MockProject(@"c:\mockPath1\project1.csproj"); MockProject targetProject = new MockProject(); MockProjectItem folder = new MockProjectItem("MyFolder") { Kind = Constants.vsProjectItemKindPhysicalFolder }; targetProject.ProjectItems.AddProjectItem(folder); string sourceFolder = Path.Combine(@"c:\mockPath1", @"MyFolder"); ProjectItemsSynchronizer syncher = new ProjectItemsSynchronizer(sourceProject, targetProject, mockLogger, null, new MockProjectItemsFilter()); Assert.AreEqual(1, targetProject.ProjectItems.Count); syncher.DirectoryRemovedFromSource(sourceFolder); Assert.IsTrue(folder.DeleteCalled); Assert.AreEqual(1, mockLogger.MessageLog.Count); StringAssert.Contains(mockLogger.MessageLog[0], "removed"); StringAssert.Contains(mockLogger.MessageLog[0], @"MyFolder"); StringAssert.Contains(mockLogger.MessageLog[0], targetProject.Name); }
public async Task ChecksIfTheProjectsWorkspaceHasTheProFeature(bool hasFeature) { const long projectId = 10; const long workspaceId = 11; var project = new MockProject { WorkspaceId = workspaceId }; var feature = new MockWorkspaceFeature { Enabled = hasFeature, FeatureId = WorkspaceFeatureId.Pro }; var featureCollection = new MockWorkspaceFeatureCollection { Features = new[] { feature } }; InteractorFactory.GetWorkspaceFeaturesById(workspaceId) .Execute() .Returns(Observable.Return(featureCollection)); InteractorFactory.GetProjectById(Arg.Is(projectId)) .Execute() .Returns(Observable.Return(project)); var hasProFeature = await InteractorFactory.IsBillableAvailableForProject(projectId).Execute(); hasProFeature.Should().Be(hasFeature); }
public void ShouldCreateFolderStructureWhenAddingLinkedFile() { MockLogger mockLogger = new MockLogger(); MockProject sourceProject = new MockProject(@"c:\mockPath1\project1.csproj"); MockProject targetProject = new MockProject(); MockProjectItem sourceFolder = new MockProjectItem("MyFolder") { Kind = Constants.vsProjectItemKindPhysicalFolder }; sourceProject.ProjectItems.AddProjectItem(sourceFolder); sourceFolder.ProjectItems.AddProjectItem(new MockProjectItem("MyFile.txt")); ProjectItemsSynchronizer syncher = new ProjectItemsSynchronizer(sourceProject, targetProject, mockLogger, null, new MockProjectItemsFilter()); string fileToAdd = @"c:\mockPath1\MyFolder\MyFile.txt"; syncher.FileAddedToSource(fileToAdd); Assert.IsNotNull(targetProject.ProjectItems.Item(0)); Assert.AreEqual(targetProject.ProjectItems.Item(0).Name, "MyFolder"); Assert.IsNotNull(targetProject.ProjectItems.Item(0).ProjectItems); Assert.AreEqual(1, targetProject.ProjectItems.Item(0).ProjectItems.Count); StringAssert.EndsWith(targetProject.ProjectItems.Item(0).ProjectItems.Item(0).Name, "MyFile.txt"); Assert.IsTrue(mockLogger.MessageLog.Count > 1); string loggedMessage = mockLogger.MessageLog.FirstOrDefault(x => x.IndexOf("folder", StringComparison.OrdinalIgnoreCase) >= 0); Assert.IsNotNull(loggedMessage); StringAssert.Contains(loggedMessage, "created"); Assert.AreEqual(-1, loggedMessage.IndexOf("MyFile.txt")); }
public void ShouldNotRemoveFileIfTargetFileIsNotALink() { MockLogger mockLogger = new MockLogger(); MockProject sourceProject = new MockProject(@"c:\mockPath1\project1.csproj"); MockProject targetProject = new MockProject(); MockProjectItem targetFile = new MockProjectItem("MyClass.cs") { Kind = Constants.vsProjectItemKindPhysicalFile }; targetProject.ProjectItems.AddProjectItem(targetFile); string sourceFile = Path.Combine(@"c:\mockPath1", @"MyClass.cs"); ProjectItemsSynchronizer syncher = new ProjectItemsSynchronizer(sourceProject, targetProject, mockLogger, null, new MockProjectItemsFilter()); Assert.AreEqual(1, targetProject.ProjectItems.Count); syncher.FileRemovedFromSource(sourceFile); Assert.IsFalse(targetFile.DeleteCalled); Assert.AreEqual(1, mockLogger.MessageLog.Count); StringAssert.Contains(mockLogger.MessageLog[0], "not linked"); StringAssert.Contains(mockLogger.MessageLog[0], @"MyClass.cs"); StringAssert.Contains(mockLogger.MessageLog[0], targetProject.Name); }
public override void MainSetup() { base.MainSetup(); _MockSolution.InitializeWithTargetAndMixinInSeparateProjects(); //Warm Caches by loading solution. var solution = TestSpecificKernel.Get <ISolutionFactory>().BuildCurrentSolution(); //Ensure All Classes are is in the solution foreach (var file in _MockSolution.AllMockSourceFiles) { Assert.True(null != solution.FindCSharpFileByFileName(file.FileName), "{0} was not found in Solution. Test Environment is not valid.", file.FileName); } //Simulate Project Item Removed (Basic Class) _projectToRemove = _MockSolution.Projects[0]; _MockSolution.Projects = _MockSolution.Projects.Skip(1).ToList(); //Fire Project Item Event EventProxy.FireOnProjectRemoved(this, new ProjectRemovedEventArgs { ProjectFullPath = _projectToRemove.FileName }); }
public void ShouldAddFileThatIsLinkInCorrectSubfolder() { string fileToAdd = @"c:\alternativeExternalPath\file.txt"; MockLogger mockLogger = new MockLogger(); MockProject sourceProject = new MockProject(@"c:\mockPath1\project1.csproj"); MockProject targetProject = new MockProject(); MockProjectItem sourceFolder = new MockProjectItem("MyFolder") { Kind = Constants.vsProjectItemKindPhysicalFolder }; sourceProject.ProjectItems.AddProjectItem(sourceFolder); MockProjectItem linkedSourceFile = new MockProjectItem("file.txt"); linkedSourceFile.MockProperties.PropertiesList.Add(new MockProperty("FullPath", fileToAdd)); sourceFolder.ProjectItems.AddProjectItem(linkedSourceFile); MockProjectItem targetFolder = new MockProjectItem("MyFolder") { Kind = Constants.vsProjectItemKindPhysicalFolder }; targetProject.ProjectItems.AddProjectItem(targetFolder); ProjectItemsSynchronizer syncher = new ProjectItemsSynchronizer(sourceProject, targetProject, mockLogger, null, new MockProjectItemsFilter()); syncher.FileAddedToSource(fileToAdd); Assert.IsTrue(targetFolder.ProjectItems.AddFromFileCalled); Assert.AreEqual(1, targetFolder.ProjectItems.Count); StringAssert.EndsWith(targetFolder.ProjectItems.Item(0).Name, "file.txt"); }
public void ShouldIncludeSubDirectoryInTargetWhenItsPresentInFileSystem() { MockIVsSolution mockSolution = new MockIVsSolution(); MockVsHierarchy mockTargetVsHierarchy = new MockVsHierarchy(); MockProject sourceProject = new MockProject(@"c:\mockPath1\project1.csproj"); MockProject targetProject = new MockProject(@"c:\mockPath2\project1.csproj"); mockTargetVsHierarchy.GetPropertyProjectValue = targetProject; mockSolution.Hierarchies.Add(mockTargetVsHierarchy); targetProject.ProjectItems.AddFolder("Folder1", Constants.vsProjectItemKindPhysicalFolder); MockProjectItem folder1 = targetProject.ProjectItems.Item(0) as MockProjectItem; folder1.ProjectItems.ThrowOnAddFolder = true; MockHierarchyHelper mockHierarchyHelper = new MockHierarchyHelper(); MockLogger mockLogger = new MockLogger(); ProjectItemsSynchronizer syncher = new ProjectItemsSynchronizer(sourceProject, targetProject, mockLogger, mockSolution, mockHierarchyHelper, new MockProjectItemsFilter()); string directoryToAdd = @"c:\mockPath1\Folder1\Folder2\"; syncher.DirectoryAddedToSource(directoryToAdd); Assert.IsTrue(mockTargetVsHierarchy.AddItemCalled); Assert.AreEqual(VSConstants.VSITEMID_ROOT, mockTargetVsHierarchy.AddItemArgumentItemidLoc); Assert.AreEqual(string.Empty, mockTargetVsHierarchy.AddItemArgumentItemName); Assert.AreEqual <uint>(1, mockTargetVsHierarchy.AddItemArgumentFilesToOpen); Assert.AreEqual(@"c:\mockPath2\Folder1\Folder2", mockTargetVsHierarchy.AddItemArgumentArrayFilesToOpen[0]); Assert.AreEqual(1, mockLogger.MessageLog.Count); StringAssert.Contains(mockLogger.MessageLog[0], "already exists"); StringAssert.Contains(mockLogger.MessageLog[0], "included"); StringAssert.Contains(mockLogger.MessageLog[0], @"Folder2"); StringAssert.Contains(mockLogger.MessageLog[0], targetProject.Name); }
IProject GetProject(string content, string projFileName = @"c:\test\code\fake1.csproj") { _fs.File.WriteAllText(projFileName, content); var project = new MockProject(Solution, _fs, new Logger(Verbosity.Quiet), projFileName); project.FileName = projFileName; project.Files.Add(new CSharpFile(project, @"c:\test\code\test.cs", "some c# code")); return(project); }
public void ShouldRetrieveDefaultFilter() { MockProject mockProject = new MockProject(); IProjectItemsFilter result = FilterManager.GetFilterForProject(mockProject); Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(RegexProjectItemsFilter)); }
public void ShouldPersistDefaultFiltersOnProject() { MockProject mockProject = new MockProject(); string defaultFilterExpressions = @"\\?desktop(\\.*)?$;\\?silverlight(\\.*)?$;\.desktop;\.silverlight;\.xaml;^service references(\\.*)?$;\.clientconfig;^web references(\\.*)?$"; IProjectItemsFilter filter = FilterManager.GetFilterForProject(mockProject); Assert.IsTrue(mockProject.Globals.SetVariablePersistsCalled); Assert.AreEqual(defaultFilterExpressions, mockProject.Globals.Dictionary["ProjectLinkerExcludeFilter"]); }
public void ShouldAddDirectoryToTargetWhenAddingToSourceProject() { MockProject sourceProject = new MockProject(@"c:\mockPath1\project1.csproj"); MockProject targetProject = new MockProject(); ProjectItemsSynchronizer syncher = new ProjectItemsSynchronizer(sourceProject, targetProject, new MockLogger(), null, new MockProjectItemsFilter()); string directoryToAdd = @"c:\mockPath1\MyFolder\"; syncher.DirectoryAddedToSource(directoryToAdd); Assert.IsTrue(targetProject.ProjectItems.AddFolderCalled); Assert.AreEqual(1, targetProject.ProjectItems.Count); StringAssert.EndsWith(targetProject.ProjectItems.Item(0).Name, "MyFolder"); }
public async Task ReturnsTheBillableValueOfTheQueriedProject(bool isBillable) { const long projectId = 10; var project = new MockProject { Billable = isBillable }; InteractorFactory.GetProjectById(Arg.Is(projectId)) .Execute() .Returns(Observable.Return(project)); var defaultsToBillable = await InteractorFactory.ProjectDefaultsToBillable(projectId).Execute(); defaultsToBillable.Should().Be(isBillable); }
public async Task ReturnsSuccessTransitionWhenItDeletesSomeProjects() { var project = new MockProject { Id = 123, SyncStatus = SyncStatus.RefetchingNeeded }; projectsDataSource.GetAll(Arg.Any <Func <IDatabaseProject, bool> >()) .Returns(Observable.Return(new[] { project })); timeEntriesDataSource.GetAll(Arg.Any <Func <IDatabaseTimeEntry, bool> >()) .Returns(Observable.Return(new IThreadSafeTimeEntry[0])); var transition = await state.Start(); transition.Result.Should().Be(state.Done); }
public void PreviewWindowModelToString_Test() { var added = new List <AccessiblePackageIdentity>(); var deleted = new List <AccessiblePackageIdentity>(); var updated = new List <UpdatePreviewResult>(); added.Add(new AccessiblePackageIdentity(new PackageIdentity("PkgA", new Versioning.NuGetVersion("1.2.3")))); deleted.Add(new AccessiblePackageIdentity(new PackageIdentity("PkgB", new Versioning.NuGetVersion("3.2.1")))); updated.Add(new UpdatePreviewResult( new PackageIdentity("PkgC", new Versioning.NuGetVersion("1.0.0")), new PackageIdentity("PkgC", new Versioning.NuGetVersion("2.0.0")) )); var ProjA = new MockProject(); var previewResult = new PreviewResult(ProjA, added, deleted, updated); var allResults = new List <PreviewResult>(); allResults.Add(previewResult); var model = new PreviewWindowModel(allResults); var sb = new StringBuilder(); sb.AppendLine(Resources.Preview_UnknownProject); sb.AppendLine(); sb.AppendLine(Resources.Label_UninstalledPackages); sb.AppendLine(); foreach (var p in deleted) { sb.AppendLine(p.ToString()); } sb.AppendLine(); sb.AppendLine(Resources.Label_UpdatedPackages); sb.AppendLine(); foreach (var p in updated) { sb.AppendLine(p.ToString()); } sb.AppendLine(); sb.AppendLine(Resources.Label_InstalledPackages); sb.AppendLine(); foreach (var p in added) { sb.AppendLine(p.ToString()); } sb.AppendLine(); Assert.Equal(sb.ToString(), model.ToString()); }
public void ShouldFilterAddedDirectoryOnSource() { MockProject sourceProject = new MockProject(@"c:\mockPath1\project1.csproj"); MockProject targetProject = new MockProject(); MockProjectItemsFilter mockProjectItemsFilter = new MockProjectItemsFilter { IsSynchronizableReturnValue = false }; ProjectItemsSynchronizer syncher = new ProjectItemsSynchronizer(sourceProject, targetProject, new MockLogger(), null, null, mockProjectItemsFilter); string directoryToAdd = Path.Combine(@"c:\mockPath1", "MyFolder"); syncher.DirectoryAddedToSource(directoryToAdd); Assert.IsFalse(targetProject.ProjectItems.AddFolderCalled); Assert.IsTrue(mockProjectItemsFilter.IsSynchronizableCalled); }
public void ShouldLogMessageIfFileDoesNotExistInTargetProject() { MockLogger mockLogger = new MockLogger(); MockProject sourceProject = new MockProject(@"c:\mockPath1\project1.csproj"); MockProject targetProject = new MockProject(); string sourceFile = Path.Combine(@"c:\mockPath1", @"MyClass.cs"); ProjectItemsSynchronizer syncher = new ProjectItemsSynchronizer(sourceProject, targetProject, mockLogger, null, new MockProjectItemsFilter()); syncher.FileRemovedFromSource(sourceFile); Assert.AreEqual(1, mockLogger.MessageLog.Count); StringAssert.Contains(mockLogger.MessageLog[0], "not linked"); StringAssert.Contains(mockLogger.MessageLog[0], @"MyClass.cs"); StringAssert.Contains(mockLogger.MessageLog[0], targetProject.Name); }
public async Task DeletesProjectPlaceholderWhenItIsNotReferencedByAnyTimeEntry() { var project = new MockProject { Id = 123, SyncStatus = SyncStatus.RefetchingNeeded }; projectsDataSource.GetAll(Arg.Any <Func <IDatabaseProject, bool> >()) .Returns(Observable.Return(new[] { project })); timeEntriesDataSource.GetAll(Arg.Any <Func <IDatabaseTimeEntry, bool> >()) .Returns(Observable.Return(new IThreadSafeTimeEntry[0])); await state.Start(); await projectsDataSource.Received() .DeleteAll(Arg.Is <IEnumerable <IThreadSafeProject> >(projects => projects.Count() == 1 && projects.First().Id == project.Id)); }
static Workspace SetupWorkspace(int projectCount) { var result = new Workspace(); var solution = CreateWorkspaceItem("item"); result.Items.Add(solution); for (int i = 0; i < projectCount; ++i) { var project = new MockProject(solution.BaseDirectory.Combine("project" + i, "project_file")); solution.Children.Add(project); solution.OnRootDirectoriesChanged(project, isRemove: false, isAdd: true); } return(result); }
public void PropertyLocationSet_ShouldAssignValueCorrectly() { //Arrange string name = "Valid name"; string location = "Valid location"; var packagesMock = new Mock <IRepository <IPackage> >(); var sut = new MockProject(name, location, packagesMock.Object); //Act sut.Location = "other location"; string result = sut.Location; string expectedOutput = "other location"; //Assert Assert.AreEqual(expectedOutput, result); }
public async Task TestNotificationsSubscribedIncremental() { using var workspace = SetupWorkspace(0); await FileWatcherService.Add(workspace); var item = workspace.GetAllItems <MockWorkspaceItem> ().Single(); var projectFile = item.BaseDirectory.Combine("project", "project_file"); var project = new MockProject(projectFile); item.OnRootDirectoriesChanged(project, isRemove: false, isAdd: true); await TestAll(project, workspace); AssertData(project, Is.GreaterThan(0)); await FileWatcherService.Remove(workspace); }
async Task TestAll(MockProject project, Workspace ws) { await FileWatcherService.Update(); foreach (var toClear in ws.GetAllItems <MockProject> ()) { toClear.Reset(); } var testFile = project.BaseDirectory.Combine("test_file"); // Create -> Change -> Rename -> Delete File.WriteAllText(testFile, ""); File.Move(testFile, testFile + 2); File.Delete(testFile + 2); await WaitForFilesRemoved(new FilePath[] { testFile, testFile + 2 }); }
public void ShouldRetrievePersistedFilters() { MockProject mockProject = new MockProject(); mockProject.Globals.Dictionary["ProjectLinkerExcludeFilter"] = @"\.excludeMe;\.excludeMeToo"; IProjectItemsFilter filter = FilterManager.GetFilterForProject(mockProject); Assert.IsFalse(filter.CanBeSynchronized(@"c:\MyFolder\abc.silverlight.excludeMe")); Assert.IsFalse(filter.CanBeSynchronized(@"c:\MyFolder\abc.excludeMeToo")); Assert.IsTrue(filter.CanBeSynchronized(@"c:\MyFolder\abc.silverlight.cs")); Assert.IsTrue(filter.CanBeSynchronized(@"c:\MyFolder\abc.desktop")); Assert.IsTrue(filter.CanBeSynchronized(@"c:\MyFolder.Silverlight\abc.cs")); Assert.IsTrue(filter.CanBeSynchronized(@"c:\MyFolder.desktop\abc.cs")); Assert.IsTrue(filter.CanBeSynchronized(@"c:\silverlight\abc.cs")); Assert.IsTrue(filter.CanBeSynchronized(@"c:\Desktop\abc.cs")); Assert.IsTrue(filter.CanBeSynchronized(@"c:\MyFolder\abc.xaml")); }
private ProjectSuggestion getProjectSuggestion(int projectId, int workspaceId, IEnumerable <IThreadSafeTask> tasks) { var workspace = new MockWorkspace { Name = $"Workspace{workspaceId}", Id = workspaceId }; var project = new MockProject { Name = $"Project{projectId}", Workspace = workspace, WorkspaceId = workspaceId, Active = true, Tasks = tasks }; return(new ProjectSuggestion(project)); }