private void GenerateAndAssertSnapshot(
            Type patternType,
            string patternInterfaceFile,
            string patternImplementationFile,
            string declarationInterfaceFile,
            string targetNameSpace,
            string snapshotName)
        {
            var resolver = this.LoadWorkSpace(
                patternInterfaceFile,
                patternImplementationFile,
                declarationInterfaceFile,
                out var itfDeclaration,
                out var itfPatternDeclaration,
                out var implPatternDeclaration,
                out var files);

            var locator = new RelativeLocator(string.Empty, targetNameSpace);

            var snapshotGenerator = new SnapshotGenerator();

            var implGenerator = new AutomatedGenerator(
                snapshotGenerator, locator, resolver, patternType);

            implGenerator.Generate(files);

            string location = SnapshotHelper.GetLocationFromCallingProjectRoot("Generator");

            SnapshotHelper.AssertSnapshot(snapshotGenerator.GetAllGenerated(), snapshotName, location);
        }
        private void GenerateSnapshot(string snapshotName, params string[] files)
        {
            var sc = new ServiceCollection();

            sc.AddTestLogging(this.testOutputHelper);
            sc.AddCSharpToolsGenerator();

            using (var sp = sc.BuildServiceProvider())
            {
                var workspace = sp.GetService <ICSharpWorkspace>();

                foreach (var file in files)
                {
                    workspace.RegisterFile(file);
                }

                var generator = new ToolsGenerator(
                    sp.GetService <ILogger <ToolsGenerator> >(),
                    workspace);

                var inputs  = new HashSet <string>();
                var locator = new RelativeLocator(string.Empty, "target.name.space");

                var snapshotGenerator = new SnapshotGenerator();

                generator.Generate(locator, snapshotGenerator, workspace.Files);

                var location = SnapshotHelper.GetLocationFromCallingProjectRoot(null);
                SnapshotHelper.AssertSnapshot(snapshotGenerator.GetAllGenerated(), snapshotName, location);
            }
        }
        public void It_should_revert_the_shadow_to_the_original_project_with_package_ref()
        {
            var projectPath = "./Shadow/Lib2.csproj";
            var rootPath    = "./Resources";

            var packages = new Dictionary <string, PackageDeclaration>();

            var packageProjectPath = "./Lib1/Lib1.csproj";
            var packageId          = "PackageLib1";
            var packageProject     = new Project(packageProjectPath);

            packages.Add(packageId, new PackageDeclaration(packageProjectPath, packageId, "3.2.1", new Project[] { packageProject }));

            var project    = new Project(projectPath);
            var aggregator = ShadowProjectHelper.CreateAggregator(rootPath, project, packages);

            var revertShadowService = new ShadowProjectPushService();

            var revertedPath = revertShadowService.PushShadow(aggregator, project);

            var fullPath = Path.Combine(rootPath, revertedPath);

            var snapshotLocation = SnapshotHelper.GetLocationFromCallingCodeProjectRoot("Services");

            SnapshotHelper.AssertSnapshot(
                File.ReadAllText(fullPath),
                nameof(this.It_should_revert_the_shadow_to_the_original_project_with_package_ref),
                snapshotLocation);
        }
        private void GenerateAndAssertSnapshot(
            string patternInterfaceFile,
            string patternImplementationFile,
            string declarationInterfaceFile,
            string targetNameSpace,
            string implName,
            string snapshotName)
        {
            this.LoadWorkSpace(
                patternInterfaceFile,
                patternImplementationFile,
                declarationInterfaceFile,
                out var itfDeclaration,
                out var itfPatternDeclaration,
                out var implPatternDeclaration);

            var locator = new RelativeLocator(string.Empty, targetNameSpace);

            var snapshotGenerator = new SnapshotGenerator();

            var implGenerator = new ImplementationGenerator(
                snapshotGenerator, locator, itfPatternDeclaration, implPatternDeclaration);

            var writerSelector = SetupWriterSelector(itfPatternDeclaration, implPatternDeclaration, itfDeclaration, implName);

            implGenerator.Generate(writerSelector, itfDeclaration, implName);

            string location = SnapshotHelper.GetLocationFromCallingProjectRoot("Generator");

            SnapshotHelper.AssertSnapshot(snapshotGenerator.GetAllGenerated(), snapshotName, location);
        }
        private void GenerateShadowAndAssertSnapshot(string rootPath, string projectPath, Dictionary <string, PackageDeclaration> packages, string snapshotName)
        {
            var shadowFullPath = ShadowProjectHelper.GenerateShadow(rootPath, projectPath, packages);

            var snapshotLocation = SnapshotHelper.GetLocationFromCallingCodeProjectRoot("Services");

            SnapshotHelper.AssertSnapshot(
                File.ReadAllText(shadowFullPath),
                snapshotName,
                snapshotLocation);
        }