コード例 #1
0
        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());
            }
        }
コード例 #2
0
        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));
            }
        }