public void ApproveExample()
    {
        var engine = new ComparerEngine();
        var diff   = engine.CreateDiff("ExampleV1.dll", "ExampleV2.dll");

        var stringBuilder = new StringWriter();
        var formatter     = new APIUpgradeToMarkdownFormatter();

        formatter.WriteOut(ApiChanges.FromDiff(diff), stringBuilder);

        Approvals.Verify(stringBuilder.ToString());
    }
Ejemplo n.º 2
0
    static bool Compare(CompareSet compareSet, bool showAllVersions = true, bool nonInteractive = false, string reportPath = null)
    {
        var engine = new ComparerEngine();

        var diff = engine.CreateDiff(compareSet.LeftAssemblyGroup, compareSet.RightAssemblyGroup);

        var breakingChanges = BreakingChangeFinder.Find(diff)
                              .ToList();

        var hasBreakingChange = breakingChanges.Any();

        if (!showAllVersions && !hasBreakingChange)
        {
            return(true);
        }

        Console.Out.Write("Checking {0}", compareSet);

        if (hasBreakingChange)
        {
            Console.Out.WriteLine(": {0} Breaking Changes found", breakingChanges.Count);
        }
        else
        {
            Console.Out.WriteLine(": No breaking changes found");
        }

        var resultFile = reportPath ?? Path.Combine(Path.GetTempPath(), Guid.NewGuid() + ".md");

        using (var fileStream = File.OpenWrite(resultFile))
            using (var into = new StreamWriter(fileStream))
            {
                var formatter = new APIUpgradeToMarkdownFormatter();
                formatter.WriteOut(ApiChanges.FromDiff(diff), @into);

                @into.Flush();
                @into.Close();
                fileStream.Close();
            }

        Console.Out.WriteLine(resultFile);
        if (!nonInteractive)
        {
            Process.Start(resultFile);
        }
        return(!hasBreakingChange);
    }
    public void ApproveNServiceBus()
    {
        var packages = new[]
        {
            "4.6.4", "5.0.0-beta0004"
        };

        var nugetCacheDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "NuGet", "Cache");
        var repo = new AggregateRepository(new[]
        {
            PackageRepositoryFactory.Default.CreateRepository(nugetCacheDirectory),
            PackageRepositoryFactory.Default.CreateRepository("https://www.nuget.org/api/v2"),
            PackageRepositoryFactory.Default.CreateRepository("https://www.myget.org/F/particular/"),
        });

        var packageManager = new PackageManager(repo, "packages");

        foreach (var v in packages)
        {
            if (!Directory.Exists(Path.Combine("packages", "NServiceBus." + v)))
            {
                packageManager.InstallPackage("NServiceBus", SemanticVersion.Parse(v));
            }
        }

        var file1 = Path.Combine("packages", "NServiceBus." + packages[0], "lib", "net40", "NServiceBus.Core.dll");
        var file2 = Path.Combine("packages", "NServiceBus." + packages[1], "lib", "net45", "NServiceBus.Core.dll");

        var engine = new ComparerEngine();

        var diff = engine.CreateDiff(file1, file2);

        var stringBuilder = new StringWriter();
        var formatter     = new APIUpgradeToMarkdownFormatter();

        formatter.WriteOut(ApiChanges.FromDiff(diff), stringBuilder);

        Approvals.Verify(stringBuilder.ToString());
    }