public static CompilerResults AssertCompiles(this MockProject project)
        {
            var compilerResults = project.Compile();

            Assert.False(compilerResults.Errors.HasErrors,
                         "Project does not compile: " +
                         compilerResults.PrettyPrintErrorList());

            return(compilerResults);
        }
        public static void AssertCompilesAndCanExecuteMethod <T>(
            this MockProject project,
            string fullClassName,
            string methodName,
            T expectedReturnValue)
        {
            var compilerResults = AssertCompiles(project);

            compilerResults
            .ExecuteMethod <T>(
                fullClassName,
                methodName)
            .ShouldEqual(expectedReturnValue);
        }
        public static void AssertCompilesAndCanExecuteMethod(
            this MockSourceFile file,
            MockSolution solution,
            string methodName = MockSolutionInitializer.DefaultMixinMethodName,
            int returnValue   = MockSolutionInitializer.DefaultMixinMethodReturnValue)
        {
            MockProject project = solution.Projects.FirstOrDefault(p => p.ContainsFile(file));

            Assert.NotNull(project, "Failed to find Project for File [" + file.FileName + "]");

            AssertCompilesAndCanExecuteMethod <int>(
                project,
                "Testing." + file.Classname,
                methodName,
                returnValue);
        }
        protected bool CanGenerateMixinCodeForSourceFile(MockSourceFile sourceFile, MockProject project = null)
        {
            project = project ?? _MockSolution.Projects[0];

            var result =
                TestSpecificKernel.Get <IVisualStudioCodeGenerator>()
                .GenerateCode(new[]
            {
                new RawSourceFile
                {
                    FileContents    = sourceFile.Source,
                    FileName        = sourceFile.FileName,
                    ProjectFileName = project.FileName
                }
            })
                .ToArray();

            if (!result.Any())
            {
                return(false);
            }

            var text = result.First().GeneratedCodeSyntaxTree.GetText();

            if (string.IsNullOrEmpty(text))
            {
                return(false);
            }

            Console.WriteLine();
            Console.WriteLine("Mixin code behind:");
            Console.WriteLine(text);
            Console.WriteLine();
            Console.WriteLine();

            return(true);
        }
        protected bool CanGenerateMixinCodeForSourceFile(MockSourceFile sourceFile, MockProject project = null)
        {
            project = project ?? _MockSolution.Projects[0];

            var result =
                TestSpecificKernel.Get<IVisualStudioCodeGenerator>()
                    .GenerateCode(new[]
                    {
                        new RawSourceFile
                        {
                            FileContents = sourceFile.Source,
                            FileName = sourceFile.FileName,
                            ProjectFileName = project.FileName
                        }
                    })
                    .ToArray();

            if (!result.Any())
                return false;

            var text = result.First().GeneratedCodeSyntaxTree.GetText();

            if (string.IsNullOrEmpty(text))
                return false;

            Console.WriteLine();
            Console.WriteLine("Mixin code behind:");
            Console.WriteLine(text);
            Console.WriteLine();
            Console.WriteLine();

            return true;
        }