public void RegisterProjectTest() { var projectName1 = "Test1"; var projectName2 = "Test2"; var workingDir = Path.GetFullPath(Environment.CurrentDirectory); var factoryMock = new Mock <ICSharpFactory>(); factoryMock.Setup(f => f.CreateProject(It.IsAny <string>())) .Returns <string>(f => Mock.Of <ICSharpProject>()); var loaderMock = new Mock <ICSharpLoader>(); using (var workspace = new CSharpWorkspace( new TestLogger <CSharpWorkspace>(this.testOutputHelper), factoryMock.Object, loaderMock.Object)) { var project1 = workspace.RegisterProject(projectName1); var project2 = workspace.RegisterProject(projectName1); Assert.Same(project1, project2); var project3 = workspace.RegisterProject(projectName2); Assert.NotSame(project1, project3); factoryMock.Verify(f => f.CreateProject(Path.Combine(workingDir, projectName1))); factoryMock.Verify(f => f.CreateProject(Path.Combine(workingDir, projectName2))); loaderMock.Verify(l => l.Load(workspace, project1)); loaderMock.Verify(l => l.Load(workspace, project3)); } }
private IDeclarationResolver LoadAndGetResolver(string projectFile, int expectedProjectCount) { using (var ws = new CSharpWorkspace( new TestLogger <CSharpWorkspace>(this.testOutputHelper), new CSharpFactory( this.testLoggerFactory, DeclarationHelper.CreateDeclarationFactory(this.testOutputHelper)), new CSharpLoader())) { ws.RegisterProject(projectFile); Assert.Equal(expectedProjectCount, ws.Projects.Count); Assert.NotEmpty(ws.Files); return(ws.DeepLoad()); } }