public void DeepLoadTest() { var factoryMock = new Mock <ICSharpFactory>(); var loaderMock = new Mock <ICSharpLoader>(); using (var workspace = new CSharpWorkspace( new TestLogger <CSharpWorkspace>(this.testOutputHelper), factoryMock.Object, loaderMock.Object)) { var fileMock = new Mock <ICSharpFile>(); var declaration = DeclarationHelper.SetupDeclaration <IDeclaration <SyntaxNode> >("nameSpace", "name"); fileMock.SetupGet(f => f.Declarations).Returns(new IDeclaration <SyntaxNode>[] { declaration }); factoryMock.Setup(f => f.CreateFile(It.IsAny <string>())) .Returns <string>(f => fileMock.Object); workspace.RegisterFile("Test"); workspace.DeepLoad(); loaderMock.Verify(l => l.Load(It.IsAny <IDeclarationResolver>(), declaration)); } }
private IDeclarationResolver LoadWorkSpace( string patternInterfaceFile, string patternImplementationFile, string declarationInterfaceFile, out IInterfaceDeclaration itfDeclaration, out IInterfaceDeclaration itfPatternDeclaration, out IClassDeclaration implPatternDeclaration, out IEnumerable <ICSharpFile> files) { using (var ws = new CSharpWorkspace( Mock.Of <ILogger <CSharpWorkspace> >(), new CSharpFactory( Mock.Of <ILoggerFactory>(), DeclarationHelper.CreateDeclarationFactory(this.testOutputHelper)), new CSharpLoader())) { itfDeclaration = ws.RegisterFile(declarationInterfaceFile) .Declarations.First() as IInterfaceDeclaration; itfPatternDeclaration = ws.RegisterFile(patternInterfaceFile) .Declarations.First() as IInterfaceDeclaration; implPatternDeclaration = ws.RegisterFile(patternImplementationFile) .Declarations.First() as IClassDeclaration; files = ws.Files; return(ws.DeepLoad()); } }
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)); } }
public void Dispose() { if (_csharpWorkspaceDocument != null) { CSharpWorkspace.Dispose(); _csharpWorkspaceDocument = null; } }
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()); } }