public SelfTestDetectionsResult RunDetectionTests(IList <Project> targetProjects)
        {
            var dte = (DTE2)ServiceProvider.GlobalProvider.GetService(typeof(DTE));

            var result = new SelfTestDetectionsResult();

            var frameworkPickerService = new FrameworkPickerService();
            var defaultSettings        = new MockBoilerplateSettings
            {
                PreferredTestFramework = null,
                PreferredMockFramework = null
            };

            var vsMoqSettings = new MockBoilerplateSettings
            {
                PreferredTestFramework = TestFrameworks.Get(TestFrameworks.VisualStudioName),
                PreferredMockFramework = MockFrameworks.Get(MockFrameworks.MoqName)
            };

            var nunitNSubSettings = new MockBoilerplateSettings
            {
                PreferredTestFramework = TestFrameworks.Get(TestFrameworks.NUnitName),
                PreferredMockFramework = MockFrameworks.Get(MockFrameworks.NSubstituteName)
            };

            var testList = new List <SelfTestDetectionTest>
            {
                new SelfTestDetectionTest("AutoMoqTestCases", defaultSettings, TestFrameworks.VisualStudioName, MockFrameworks.AutoMoqName),
                new SelfTestDetectionTest("NetCoreMoqTestCases", defaultSettings, TestFrameworks.VisualStudioName, MockFrameworks.MoqName),
                new SelfTestDetectionTest("NetCoreNSubstituteTestCases", defaultSettings, TestFrameworks.VisualStudioName, MockFrameworks.NSubstituteName),
                new SelfTestDetectionTest("NetCoreNUnitTestCases", defaultSettings, TestFrameworks.NUnitName, MockFrameworks.MoqName),
                new SelfTestDetectionTest("NetCoreSimpleStubsTestCases", defaultSettings, TestFrameworks.VisualStudioName, MockFrameworks.SimpleStubsName),
                new SelfTestDetectionTest("NetCoreVSRhinoMocksTestCases", defaultSettings, TestFrameworks.VisualStudioName, MockFrameworks.RhinoMocksName),
                new SelfTestDetectionTest("NoFrameworkTestCases", defaultSettings, TestFrameworks.VisualStudioName, MockFrameworks.MoqName),
                new SelfTestDetectionTest("NoFrameworkTestCases", nunitNSubSettings, TestFrameworks.NUnitName, MockFrameworks.NSubstituteName),
                new SelfTestDetectionTest("NSubstituteTestCases", defaultSettings, TestFrameworks.VisualStudioName, MockFrameworks.NSubstituteName),
                new SelfTestDetectionTest("NUnitTestCases", defaultSettings, TestFrameworks.NUnitName, MockFrameworks.MoqName),
                new SelfTestDetectionTest("NUnitUwpTestCases", defaultSettings, TestFrameworks.NUnitName, MockFrameworks.SimpleStubsName),
                new SelfTestDetectionTest("SimpleStubsTestCases", defaultSettings, TestFrameworks.VisualStudioName, MockFrameworks.SimpleStubsName),
                new SelfTestDetectionTest("VSRhinoMocksTestCases", defaultSettings, TestFrameworks.VisualStudioName, MockFrameworks.RhinoMocksName),
                new SelfTestDetectionTest("VSTestCases", defaultSettings, TestFrameworks.VisualStudioName, MockFrameworks.MoqName),
                new SelfTestDetectionTest("XUnitMoqTestCases", defaultSettings, TestFrameworks.XUnitName, MockFrameworks.MoqName),
                new SelfTestDetectionTest("MultipleFrameworkTestCases", defaultSettings, TestFrameworks.NUnitName, MockFrameworks.NSubstituteName),
                new SelfTestDetectionTest("MultipleFrameworkTestCases", vsMoqSettings, TestFrameworks.VisualStudioName, MockFrameworks.MoqName),
            };

            var failures = new List <string>();

            foreach (SelfTestDetectionTest test in testList)
            {
                result.TotalCount++;

                string projectFileName = GetFileNameFromSandboxProjectName(test.ProjectName, dte);

                frameworkPickerService.Settings = test.Settings;

                TestFramework actualTestFramework = frameworkPickerService.FindTestFramework(projectFileName);
                MockFramework actualMockFramework = frameworkPickerService.FindMockFramework(projectFileName);

                if (test.ExpectedTestFramework != actualTestFramework.Name)
                {
                    failures.Add($"Expected {test.ExpectedTestFramework} test framework for {test.ProjectName} but got {actualTestFramework.Name}. (Preferred Framework: {test.Settings.PreferredTestFramework})");
                }
                else if (test.ExpectedMockFramework != actualMockFramework.Name)
                {
                    failures.Add($"Expected {test.ExpectedMockFramework} mock framework for {test.ProjectName} but got {actualMockFramework.Name}. (Preferred Framework: {test.Settings.PreferredMockFramework})");
                }
                else
                {
                    result.SucceededCount++;
                }
            }

            //foreach (Project testProject in targetProjects)
            //{
            //	result.TotalCount++;

            //	TestFramework actualTestFramework = frameworkPickerService.FindTestFramework(testProject.FileName);
            //	MockFramework actualMockFramework = frameworkPickerService.FindMockFramework(testProject.FileName);

            //	SelfTestDetectionResult expectedDetectionResult;
            //	if (!ExpectedDetectionResults.TryGetValue(testProject.Name, out expectedDetectionResult))
            //	{
            //		failures.Add("Could not find expected detection results for project " + testProject.Name);
            //	}
            //	else if (expectedDetectionResult.TestFramework != actualTestFramework.Name)
            //	{
            //		failures.Add($"Expected {expectedDetectionResult.TestFramework} test framework for {testProject.Name} but got {actualTestFramework.Name}");
            //	}
            //	else if (expectedDetectionResult.MockFramework != actualMockFramework.Name)
            //	{
            //		failures.Add($"Expected {expectedDetectionResult.MockFramework} mock framework for {testProject.Name} but got {actualMockFramework.Name}");
            //	}
            //	else
            //	{
            //		result.SucceededCount++;
            //	}
            //}

            result.Failures = failures;

            return(result);
        }
        public SelfTestDetectionsResult RunDetectionTests(IList <Project> targetProjects)
        {
            var dte = (DTE2)ServiceProvider.GlobalProvider.GetService(typeof(DTE));

            var result = new SelfTestDetectionsResult();

            var frameworkPickerService = new FrameworkPickerService();
            var defaultSettings        = new MockBoilerplateSettings
            {
                PreferredTestFramework = null,
                PreferredMockFramework = null
            };

            var noMockFrameworkSettings = new MockBoilerplateSettings
            {
                PreferredTestFramework = null,
                PreferredMockFramework = MockFrameworks.Get(MockFrameworks.NoneName)
            };

            var vsMoqSettings = new MockBoilerplateSettings
            {
                PreferredTestFramework = TestFrameworks.Get(TestFrameworks.VisualStudioName),
                PreferredMockFramework = MockFrameworks.Get(MockFrameworks.MoqName)
            };

            var nunitNSubSettings = new MockBoilerplateSettings
            {
                PreferredTestFramework = TestFrameworks.Get(TestFrameworks.NUnitName),
                PreferredMockFramework = MockFrameworks.Get(MockFrameworks.NSubstituteName)
            };

            var testList = new List <SelfTestDetectionTest>
            {
                new SelfTestDetectionTest("AutoMoqTestCases", defaultSettings, TestFrameworks.VisualStudioName, MockFrameworks.AutoMoqName),
                new SelfTestDetectionTest("FakeItEasyTestCases", defaultSettings, TestFrameworks.VisualStudioName, MockFrameworks.FakeItEasyName),
                new SelfTestDetectionTest("JustMockTestCases", defaultSettings, TestFrameworks.VisualStudioName, MockFrameworks.JustMockName),
                new SelfTestDetectionTest("MoqTestCases", defaultSettings, TestFrameworks.VisualStudioName, MockFrameworks.MoqName),
                new SelfTestDetectionTest("NetFrameworkPackagesConfigTestCases", defaultSettings, TestFrameworks.NUnitName, MockFrameworks.NSubstituteName),
                new SelfTestDetectionTest("NetStandardPropsTestCases", defaultSettings, TestFrameworks.NUnitName, MockFrameworks.NSubstituteName),
                new SelfTestDetectionTest("NoFrameworkTestCases", defaultSettings, TestFrameworks.VisualStudioName, MockFrameworks.NoneName),
                new SelfTestDetectionTest("NoFrameworkTestCases", nunitNSubSettings, TestFrameworks.NUnitName, MockFrameworks.NSubstituteName),
                new SelfTestDetectionTest("NSubstituteTestCases", defaultSettings, TestFrameworks.VisualStudioName, MockFrameworks.NSubstituteName),
                new SelfTestDetectionTest("NUnitTestCases", defaultSettings, TestFrameworks.NUnitName, MockFrameworks.MoqName),
                new SelfTestDetectionTest("RhinoMocksTestCases", defaultSettings, TestFrameworks.VisualStudioName, MockFrameworks.RhinoMocksName),
                new SelfTestDetectionTest("VSTestCases", defaultSettings, TestFrameworks.VisualStudioName, MockFrameworks.MoqName),
                new SelfTestDetectionTest("VSTestCases", noMockFrameworkSettings, TestFrameworks.VisualStudioName, MockFrameworks.NoneName),
                new SelfTestDetectionTest("XUnitTestCases", defaultSettings, TestFrameworks.XUnitName, MockFrameworks.MoqName),
                new SelfTestDetectionTest("MultipleFrameworkTestCases", defaultSettings, TestFrameworks.NUnitName, MockFrameworks.NSubstituteName),
                new SelfTestDetectionTest("MultipleFrameworkTestCases", vsMoqSettings, TestFrameworks.VisualStudioName, MockFrameworks.MoqName),
            };

            var failures = new List <string>();

            foreach (SelfTestDetectionTest test in testList)
            {
                result.TotalCount++;

                Project project = GetProjectFromName(test.ProjectName, dte);

                if (project == null)
                {
                    failures.Add($"Cannot find project '{test.ProjectName}'");
                }
                else
                {
                    frameworkPickerService.SettingsFactory = new MockBoilerplateSettingsFactory(test.Settings);

                    TestFramework actualTestFramework = frameworkPickerService.FindTestFramework(project, test.Settings);
                    MockFramework actualMockFramework = frameworkPickerService.FindMockFramework(project, test.Settings);

                    if (test.ExpectedTestFramework != actualTestFramework.Name)
                    {
                        failures.Add($"Expected {test.ExpectedTestFramework} test framework for {test.ProjectName} but got {actualTestFramework.Name}. (Preferred Framework: {test.Settings.PreferredTestFramework})");
                    }
                    else if (test.ExpectedMockFramework != actualMockFramework.Name)
                    {
                        failures.Add($"Expected {test.ExpectedMockFramework} mock framework for {test.ProjectName} but got {actualMockFramework.Name}. (Preferred Framework: {test.Settings.PreferredMockFramework})");
                    }
                    else
                    {
                        result.SucceededCount++;
                    }
                }
            }

            result.Failures = failures;

            return(result);
        }