System.Reflection.MethodBase.GetCurrentMethod()

Here are the examples of the csharp api System.Reflection.MethodBase.GetCurrentMethod() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2365 Examples 7

19 View Source File : AutoIncrement.cs
License : Apache License 2.0
Project Creator : adamralph

[Theory]
        [InlineData("1.2.3", VersionPart.Major, "2.0.0-alpha.0.1")]
        [InlineData("1.2.3", VersionPart.Minor, "1.3.0-alpha.0.1")]
        [InlineData("1.2.3", VersionPart.Patch, "1.2.4-alpha.0.1")]
        public static async Task RtmVersionIncrement(string tag, VersionPart autoIncrement, string expectedVersion)
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory((tag, autoIncrement));
            await EnsureEmptyRepositoryAndCommit(path);
            await Tag(path, tag);
            await Commit(path);

            // act
            var actualVersion = Versioner.GetVersion(path, default, default, default, autoIncrement, default, default);

            // replacedert
            replacedert.Equal(expectedVersion, actualVersion.ToString());
        }

19 View Source File : BuildMetadata.cs
License : Apache License 2.0
Project Creator : adamralph

[Theory]
        [InlineData(default, "0.0.0-alpha.0")]
        [InlineData("a", "0.0.0-alpha.0+a")]
        public static async Task NoCommits(string buildMetadata, string expectedVersion)
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory(buildMetadata);
            await EnsureEmptyRepository(path);

            // act
            var actualVersion = Versioner.GetVersion(path, default, default, buildMetadata, default, default, default);

            // replacedert
            replacedert.Equal(expectedVersion, actualVersion.ToString());
        }

19 View Source File : BuildMetadata.cs
License : Apache License 2.0
Project Creator : adamralph

[Theory]
        [InlineData(default, "0.0.0-alpha.0")]
        [InlineData("a", "0.0.0-alpha.0+a")]
        public static async Task NoTag(string buildMetadata, string expectedVersion)
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory(buildMetadata);
            await EnsureEmptyRepositoryAndCommit(path);

            // act
            var actualVersion = Versioner.GetVersion(path, default, default, buildMetadata, default, default, default);

            // replacedert
            replacedert.Equal(expectedVersion, actualVersion.ToString());
        }

19 View Source File : BuildMetadata.cs
License : Apache License 2.0
Project Creator : adamralph

[Theory]
        [InlineData("1.2.3+a", default, "1.2.3+a")]
        [InlineData("1.2.3", "b", "1.2.3+b")]
        [InlineData("1.2.3+a", "b", "1.2.3+a.b")]
        [InlineData("1.2.3-pre+a", default, "1.2.3-pre+a")]
        [InlineData("1.2.3-pre", "b", "1.2.3-pre+b")]
        [InlineData("1.2.3-pre+a", "b", "1.2.3-pre+a.b")]
        public static async Task CurrentTag(string tag, string buildMetadata, string expectedVersion)
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory((tag, buildMetadata));
            await EnsureEmptyRepositoryAndCommit(path);
            await Tag(path, tag);

            // act
            var actualVersion = Versioner.GetVersion(path, default, default, buildMetadata, default, default, default);

            // replacedert
            replacedert.Equal(expectedVersion, actualVersion.ToString());
        }

19 View Source File : BuildMetadata.cs
License : Apache License 2.0
Project Creator : adamralph

[Theory]
        [InlineData("1.2.3+a", default, "1.2.4-alpha.0.1")]
        [InlineData("1.2.3", "b", "1.2.4-alpha.0.1+b")]
        [InlineData("1.2.3+a", "b", "1.2.4-alpha.0.1+b")]
        [InlineData("1.2.3-pre+a", default, "1.2.3-pre.1")]
        [InlineData("1.2.3-pre", "b", "1.2.3-pre.1+b")]
        [InlineData("1.2.3-pre+a", "b", "1.2.3-pre.1+b")]
        public static async Task PreviousTag(string tag, string buildMetadata, string expectedVersion)
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory((tag, buildMetadata));
            await EnsureEmptyRepositoryAndCommit(path);
            await Tag(path, tag);
            await Commit(path);

            // act
            var actualVersion = Versioner.GetVersion(path, default, default, buildMetadata, default, default, default);

            // replacedert
            replacedert.Equal(expectedVersion, actualVersion.ToString());
        }

19 View Source File : DefaultPreReleasePhases.cs
License : Apache License 2.0
Project Creator : adamralph

[Theory]
        [InlineData(default, "0.0.0-alpha.0")]
        [InlineData("", "0.0.0-alpha.0")]
        [InlineData("preview", "0.0.0-preview.0")]
        public static async Task DefaultPreReleasePhase(string phase, string expectedVersion)
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory(phase);
            await EnsureEmptyRepositoryAndCommit(path);

            // act
            var actualVersion = Versioner.GetVersion(path, default, default, default, default, phase, default);

            // replacedert
            replacedert.Equal(expectedVersion, actualVersion.ToString());
        }

19 View Source File : MinMajorMinor.cs
License : Apache License 2.0
Project Creator : adamralph

[Fact]
        public static async Task NoCommits()
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory();
            await EnsureEmptyRepository(path);

            // act
            var actualVersion = Versioner.GetVersion(path, default, new MajorMinor(1, 2), default, default, default, default);

            // replacedert
            replacedert.Equal("1.2.0-alpha.0", actualVersion.ToString());
        }

19 View Source File : MinMajorMinor.cs
License : Apache License 2.0
Project Creator : adamralph

[Theory]
        [InlineData("4.0.0", 3, 2, "4.0.0", true)]
        [InlineData("4.3.0", 4, 3, "4.3.0", true)]
        [InlineData("4.3.0", 5, 4, "5.4.0-alpha.0", false)]
        public static async Task Tagged(string tag, int major, int minor, string expectedVersion, bool isRedundant)
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory((tag, major, minor));
            await EnsureEmptyRepositoryAndCommit(path);
            await Tag(path, tag);
            var logger = new TestLogger();

            // act
            var actualVersion = Versioner.GetVersion(path, default, new MajorMinor(major, minor), default, default, default, logger);

            // replacedert
            replacedert.Equal(expectedVersion, actualVersion.ToString());

            if (isRedundant)
            {
                replacedert.Contains(logger.DebugMessages, message => message.Contains($"The calculated version {actualVersion} satisfies the minimum major minor {major}.{minor}.", StringComparison.Ordinal));
            }
        }

19 View Source File : MinMajorMinor.cs
License : Apache License 2.0
Project Creator : adamralph

[Fact]
        public static async Task NotTagged()
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory();
            await EnsureEmptyRepositoryAndCommit(path);

            // act
            var actualVersion = Versioner.GetVersion(path, default, new MajorMinor(1, 0), default, default, default, default);

            // replacedert
            replacedert.Equal("1.0.0-alpha.0", actualVersion.ToString());
        }

19 View Source File : TagPrefixes.cs
License : Apache License 2.0
Project Creator : adamralph

[Theory]
        [InlineData("1.2.3", default, "1.2.3")]
        [InlineData("2.3.4", "", "2.3.4")]
        [InlineData("v3.4.5", "v", "3.4.5")]
        [InlineData("version5.6.7", "version", "5.6.7")]
        public static async Task TagPrefix(string tag, string prefix, string expectedVersion)
        {
            // act
            var path = MethodBase.GetCurrentMethod().GetTestDirectory((tag, prefix));
            await EnsureEmptyRepositoryAndCommit(path);
            await Tag(path, tag);

            // act
            var actualVersion = Versioner.GetVersion(path, prefix, default, default, default, default, default);

            // replacedert
            replacedert.Equal(expectedVersion, actualVersion.ToString());
        }

19 View Source File : Versions.cs
License : Apache License 2.0
Project Creator : adamralph

[Fact]
        public static async Task RepoWithHistory()
        {
            // arrange
            var historicalCommands =
@"git commit --allow-empty -m '.'
git commit --allow-empty -m '.'
git commit --allow-empty -m '.'
git tag 0.0.0-alpha.1
git commit --allow-empty -m '.'
git commit --allow-empty -m '.'
git tag 0.0.0
git commit --allow-empty -m '.'
git commit --allow-empty -m '.'
git tag 0.1.0-beta.1
git commit --allow-empty -m '.'
git commit --allow-empty -m '.'
git tag 0.1.0
git commit --allow-empty -m '.'
git commit --allow-empty -m '.'
git tag 1.0.0-alpha.1
git commit --allow-empty -m '.'
git commit --allow-empty -m '.'
git tag 1.0.0-rc.1
git tag 1.0.0
git checkout -b foo
git commit --allow-empty -m '.'
git commit --allow-empty -m '.'
git commit --allow-empty -m '.'
git tag 1.0.1-alpha.1
git commit --allow-empty -m '.'
git commit --allow-empty -m '.'
git tag 1.0.1
git commit --allow-empty -m '.'
git checkout main
git commit --allow-empty -m '.'
git commit --allow-empty -m '.'
git commit --allow-empty -m '.'
git tag 1.1.0-alpha.1
git commit --allow-empty -m '.'
git merge foo --no-edit
git commit --allow-empty -m '.'
git tag 1.1.0-beta.2
git tag 1.1.0-beta.10
git commit --allow-empty -m '.'
git commit --allow-empty -m '.'
git tag 1.1.0-rc.1
git tag 1.1.0 -a -m '.'";

            var path = MethodBase.GetCurrentMethod().GetTestDirectory();

            await EnsureEmptyRepositoryAndCommit(path);

            foreach (var command in historicalCommands.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries))
            {
                var nameAndArgs = command.Split(" ", 2);
                _ = await ReadAsync(nameAndArgs[0], nameAndArgs[1], path);
                await Task.Delay(200);
            }

            // act
            var versionCounts = new Dictionary<string, int>();
            foreach (var sha in await GetCommitShas(path))
            {
                await Checkout(path, sha);

                var version = Versioner.GetVersion(path, default, default, default, default, default, default);
                var versionString = version.ToString();
                var tagName = $"v/{versionString}";

                _ = versionCounts.TryGetValue(versionString, out var oldVersionCount);
                var versionCount = oldVersionCount + 1;
                versionCounts[versionString] = versionCount;

                tagName = versionCount > 1 ? $"v({versionCount})/{versionString}" : tagName;

                await Tag(path, tagName, sha);
            }

            await Checkout(path, "main");

            // replacedert
            await replacedertFile.Contains("../../../versions.txt", await GetGraph(path));
        }

19 View Source File : CommitAfterRtmTag.cs
License : Apache License 2.0
Project Creator : adamralph

[Fact]
        public static async Task HasNextPatchWithHeightOne()
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory();
            await Sdk.CreateProject(path);

            await Git.Init(path);
            await Git.Commit(path);
            await Git.Tag(path, "2.3.4");
            await Git.Commit(path);

            var expected = Package.WithVersion(2, 3, 5, new[] { "alpha", "0" }, 1);

            // act
            var (actual, _) = await Sdk.BuildProject(path);
            var cli = await MinVerCli.ReadAsync(path);

            // replacedert
            replacedert.Equal(expected, actual);
            replacedert.Equal(expected.Version, cli.StandardOutput.Trim());
        }

19 View Source File : CustomAutoIncrement.cs
License : Apache License 2.0
Project Creator : adamralph

[Fact]
        public static async Task HasCustomAutoIncrement()
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory();
            await Sdk.CreateProject(path);

            await Git.Init(path);
            await Git.Commit(path);
            await Git.Tag(path, "2.3.4");
            await Git.Commit(path);

            var envVars = ("MinVerAutoIncrement".ToAltCase(), "minor");

            var expected = Package.WithVersion(2, 4, 0, new[] { "alpha", "0" }, 1);

            // act
            var (actual, _) = await Sdk.BuildProject(path, envVars: envVars);
            var cli = await MinVerCli.ReadAsync(path, envVars: envVars);

            // replacedert
            replacedert.Equal(expected, actual);
            replacedert.Equal(expected.Version, cli.StandardOutput.Trim());
        }

19 View Source File : EmptyRepo.cs
License : Apache License 2.0
Project Creator : adamralph

[Fact]
        public static async Task HasDefaultVersion()
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory();
            await Sdk.CreateProject(path);
            await Git.Init(path);
            var expected = Package.WithVersion(0, 0, 0, new[] { "alpha", "0" });

            // act
            var (actual, sdk) = await Sdk.BuildProject(path);
            var cli = await MinVerCli.ReadAsync(path);

            // replacedert
            replacedert.Equal(expected, actual);
            replacedert.Contains("No commits found", sdk.StandardOutput, StringComparison.Ordinal);

            replacedert.Equal(expected.Version, cli.StandardOutput.Trim());
            replacedert.Contains("No commits found", cli.StandardError, StringComparison.Ordinal);
        }

19 View Source File : FirstCommit.cs
License : Apache License 2.0
Project Creator : adamralph

[Fact]
        public static async Task HasDefaultVersion()
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory();
            await Sdk.CreateProject(path);

            await Git.Init(path);
            await Git.Commit(path);

            var expected = Package.WithVersion(0, 0, 0, new[] { "alpha", "0" });

            // act
            var (actual, _) = await Sdk.BuildProject(path);
            var cli = await MinVerCli.ReadAsync(path);

            // replacedert
            replacedert.Equal(expected, actual);
            replacedert.Equal(expected.Version, cli.StandardOutput.Trim());
        }

19 View Source File : MinimumMajorMinorOnTag.cs
License : Apache License 2.0
Project Creator : adamralph

[Fact]
        public static async Task HasMinimumMajorMinor()
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory();
            await Sdk.CreateProject(path);

            await Git.Init(path);
            await Git.Commit(path);
            await Git.Tag(path, "2.3.4");

            var envVars = ("MinVerMinimumMajorMinor".ToAltCase(), "3.0");

            var expected = Package.WithVersion(3, 0, 0, new[] { "alpha", "0" });

            // act
            var (actual, _) = await Sdk.BuildProject(path, envVars: envVars);
            var cli = await MinVerCli.ReadAsync(path, envVars: envVars);

            // replacedert
            replacedert.Equal(expected, actual);
            replacedert.Equal(expected.Version, cli.StandardOutput.Trim());
        }

19 View Source File : NoRepo.cs
License : Apache License 2.0
Project Creator : adamralph

[Fact]
        public static async Task HasDefaultVersion()
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory();
            await Sdk.CreateProject(path);
            var expected = Package.WithVersion(0, 0, 0, new[] { "alpha", "0" });

            // act
            var (actual, sdk) = await Sdk.BuildProject(path);
            var cli = await MinVerCli.ReadAsync(path);

            // replacedert
            replacedert.Equal(expected, actual);
            replacedert.Contains("MINVER1001", sdk.StandardOutput, StringComparison.Ordinal);

            replacedert.Equal(expected.Version, cli.StandardOutput.Trim());
            replacedert.Contains("not a valid Git working directory", cli.StandardError, StringComparison.Ordinal);
        }

19 View Source File : RtmTag.cs
License : Apache License 2.0
Project Creator : adamralph

[Fact]
        public static async Task HasTagVersion()
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory();
            await Sdk.CreateProject(path);

            await Git.Init(path);
            await Git.Commit(path);
            await Git.Tag(path, "2.3.4");

            var expected = Package.WithVersion(2, 3, 4);

            // act
            var (actual, _) = await Sdk.BuildProject(path);
            var cli = await MinVerCli.ReadAsync(path);

            // replacedert
            replacedert.Equal(expected, actual);
            replacedert.Equal(expected.Version, cli.StandardOutput.Trim());
        }

19 View Source File : Skip.cs
License : Apache License 2.0
Project Creator : adamralph

[Fact]
        public static async Task HasDefaultSdkVersion()
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory();
            await Sdk.CreateProject(path);
            var envVars = ("MinVerSkip".ToAltCase(), "true");
            var expected = Package.WithVersion(1, 0, 0);

            // act
            var (actual, _) = await Sdk.BuildProject(path, envVars: envVars);

            // replacedert
            replacedert.Equal(expected, actual);
        }

19 View Source File : TwoCommitsAfterRtmTag.cs
License : Apache License 2.0
Project Creator : adamralph

[Fact]
        public static async Task HasNextPatchWithHeightTwo()
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory();
            await Sdk.CreateProject(path);

            await Git.Init(path);
            await Git.Commit(path);
            await Git.Tag(path, "2.3.4");
            await Git.Commit(path);
            await Git.Commit(path);

            var expected = Package.WithVersion(2, 3, 5, new[] { "alpha", "0" }, 2);

            // act
            var (actual, _) = await Sdk.BuildProject(path);
            var cli = await MinVerCli.ReadAsync(path);

            // replacedert
            replacedert.Equal(expected, actual);
            replacedert.Equal(expected.Version, cli.StandardOutput.Trim());
        }

19 View Source File : OutputVariables.cs
License : Apache License 2.0
Project Creator : adamralph

[Fact]
        public static async Task AreSet()
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory();
            await Sdk.CreateProject(path);
            var envVars = ("MinVerVersionOverride".ToAltCase(), "2.3.4-alpha-x.5+build.6");

            // act
            var (_, sdk) = await Sdk.BuildProject(path, envVars: envVars);

            // replacedert
            replacedert.Contains("MinVer: [output] MinVerVersion=2.3.4-alpha-x.5+build.6", sdk.StandardOutput, StringComparison.Ordinal);
            replacedert.Contains("MinVer: [output] MinVerMajor=2", sdk.StandardOutput, StringComparison.Ordinal);
            replacedert.Contains("MinVer: [output] MinVerMinor=3", sdk.StandardOutput, StringComparison.Ordinal);
            replacedert.Contains("MinVer: [output] MinVerPatch=4", sdk.StandardOutput, StringComparison.Ordinal);
            replacedert.Contains("MinVer: [output] MinVerPreRelease=alpha-x.5", sdk.StandardOutput, StringComparison.Ordinal);
            replacedert.Contains("MinVer: [output] MinVerBuildMetadata=build.6", sdk.StandardOutput, StringComparison.Ordinal);
            replacedert.Contains("MinVer: [output] replacedemblyVersion=2.0.0.0", sdk.StandardOutput, StringComparison.Ordinal);
            replacedert.Contains("MinVer: [output] FileVersion=2.3.4.0", sdk.StandardOutput, StringComparison.Ordinal);
            replacedert.Contains("MinVer: [output] PackageVersion=2.3.4-alpha-x.5+build.6", sdk.StandardOutput, StringComparison.Ordinal);
            replacedert.Contains("MinVer: [output] Version=2.3.4-alpha-x.5+build.6", sdk.StandardOutput, StringComparison.Ordinal);
        }

19 View Source File : TagWithPrefix.cs
License : Apache License 2.0
Project Creator : adamralph

[Fact]
        public static async Task HasTagVersion()
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory();
            await Sdk.CreateProject(path);

            await Git.Init(path);
            await Git.Commit(path);
            await Git.Tag(path, "v.2.3.4-alpha.5");

            var envVars = ("MinVerTagPrefix", "v.");

            var expected = Package.WithVersion(2, 3, 4, new[] { "alpha", "5" });

            // act
            var (actual, _) = await Sdk.BuildProject(path, envVars: envVars);
            var cli = await MinVerCli.ReadAsync(path, envVars: envVars);

            // replacedert
            replacedert.Equal(expected, actual);
            replacedert.Equal(expected.Version, cli.StandardOutput.Trim());
        }

19 View Source File : VersionOverride.cs
License : Apache License 2.0
Project Creator : adamralph

[Fact]
        public static async Task HasVersionOverride()
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory();
            await Sdk.CreateProject(path);

            await Git.Init(path);
            await Git.Commit(path);
            await Git.Tag(path, "2.3.4");

            var envVars = ("MinVerVersionOverride".ToAltCase(), "3.4.5-alpha.6+build.7");

            var expected = Package.WithVersion(3, 4, 5, new[] { "alpha", "6" }, 0, "build.7");

            // act
            var (actual, _) = await Sdk.BuildProject(path, envVars: envVars);
            var cli = await MinVerCli.ReadAsync(path, envVars: envVars);

            // replacedert
            replacedert.Equal(expected, actual);
            replacedert.Equal(expected.Version, cli.StandardOutput.Trim());
        }

19 View Source File : Versions.cs
License : Apache License 2.0
Project Creator : adamralph

[Fact]
        public static async Task EmptyRepo()
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory();
            await EnsureEmptyRepository(path);

            // act
            var version = Versioner.GetVersion(path, default, default, default, default, default, default);

            // replacedert
            replacedert.Equal("0.0.0-alpha.0", version.ToString());
        }

19 View Source File : PreReleaseTag.cs
License : Apache License 2.0
Project Creator : adamralph

[Fact]
        public static async Task HasTagVersion()
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory();
            await Sdk.CreateProject(path);

            await Git.Init(path);
            await Git.Commit(path);
            await Git.Tag(path, "2.3.4-alpha.5");

            var expected = Package.WithVersion(2, 3, 4, new[] { "alpha", "5" });

            // act
            var (actual, _) = await Sdk.BuildProject(path);
            var cli = await MinVerCli.ReadAsync(path);

            // replacedert
            replacedert.Equal(expected, actual);
            replacedert.Equal(expected.Version, cli.StandardOutput.Trim());
        }

19 View Source File : TwoCommitsAfterPreReleaseTag.cs
License : Apache License 2.0
Project Creator : adamralph

[Fact]
        public static async Task HasHeightTwo()
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory();
            await Sdk.CreateProject(path);

            await Git.Init(path);
            await Git.Commit(path);
            await Git.Tag(path, "2.3.4-alpha.5");
            await Git.Commit(path);
            await Git.Commit(path);

            var expected = Package.WithVersion(2, 3, 4, new[] { "alpha", "5" }, 2);

            // act
            var (actual, _) = await Sdk.BuildProject(path);
            var cli = await MinVerCli.ReadAsync(path);

            // replacedert
            replacedert.Equal(expected, actual);
            replacedert.Equal(expected.Version, cli.StandardOutput.Trim());
        }

19 View Source File : Versions.cs
License : Apache License 2.0
Project Creator : adamralph

[Fact]
        public static void NoRepo()
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory();
            EnsureEmptyDirectory(path);

            // act
            var version = Versioner.GetVersion(path, default, default, default, default, default, default);

            // replacedert
            replacedert.Equal("0.0.0-alpha.0", version.ToString());
        }

19 View Source File : AnnotatedTag.cs
License : Apache License 2.0
Project Creator : adamralph

[Fact]
        public static async Task HasTagVersion()
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory();
            await Sdk.CreateProject(path);

            await Git.Init(path);
            await Git.Commit(path);
            await Git.AnnotatedTag(path, "2.3.4-alpha.5+build.6", "foo");

            var expected = Package.WithVersion(2, 3, 4, new[] { "alpha", "5" }, 0, "build.6");

            // act
            var (actual, _) = await Sdk.BuildProject(path);
            var cli = await MinVerCli.ReadAsync(path);

            // replacedert
            replacedert.Equal(expected, actual);
            replacedert.Equal(expected.Version, cli.StandardOutput.Trim());
        }

19 View Source File : BuildMetadata.cs
License : Apache License 2.0
Project Creator : adamralph

[Fact]
        public static async Task HasBuildMetadata()
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory();
            await Sdk.CreateProject(path);
            var envVars = ("MinVerBuildMetadata", "build.123");
            var expected = Package.WithVersion(0, 0, 0, new[] { "alpha", "0" }, 0, "build.123");

            // act
            var (actual, _) = await Sdk.BuildProject(path, envVars: envVars);
            var cli = await MinVerCli.ReadAsync(path, envVars: envVars);

            // replacedert
            replacedert.Equal(expected, actual);
            replacedert.Equal(expected.Version, cli.StandardOutput.Trim());
        }

19 View Source File : BuildMetadataWithMultiplePlusSigns.cs
License : Apache License 2.0
Project Creator : adamralph

[Fact]
        public static async Task IsUsed()
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory();
            await Sdk.CreateProject(path);
            var envVars = ("MinVerVersionOverride".ToAltCase(), "2.3.4-alpha-x.5+build.6+7");

            // act
            // SemVer doesn't allow multiple plus signs, but MinVer doesn't care
            Result result = null;
            var exception = await Record.ExceptionAsync(async () => (_, result) = await Sdk.BuildProject(path, envVars: envVars));
            var actual = exception != null ? exception.Message : result.StandardOutput;

            // replacedert
            replacedert.Contains("MinVer: [output] MinVerVersion=2.3.4-alpha-x.5+build.6+7", actual, StringComparison.Ordinal);
            replacedert.Contains("MinVer: [output] MinVerBuildMetadata=build.6+7", actual, StringComparison.Ordinal);
            replacedert.Contains("MinVer: [output] PackageVersion=2.3.4-alpha-x.5+build.6+7", actual, StringComparison.Ordinal);
            replacedert.Contains("MinVer: [output] Version=2.3.4-alpha-x.5+build.6+7", actual, StringComparison.Ordinal);
        }

19 View Source File : CommitAfterPreReleaseTag.cs
License : Apache License 2.0
Project Creator : adamralph

[Fact]
        public static async Task HasHeightOne()
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory();
            await Sdk.CreateProject(path);

            await Git.Init(path);
            await Git.Commit(path);
            await Git.Tag(path, "2.3.4-alpha.5");
            await Git.Commit(path);

            var expected = Package.WithVersion(2, 3, 4, new[] { "alpha", "5" }, 1);

            // act
            var (actual, _) = await Sdk.BuildProject(path);
            var cli = await MinVerCli.ReadAsync(path);

            // replacedert
            replacedert.Equal(expected, actual);
            replacedert.Equal(expected.Version, cli.StandardOutput.Trim());
        }

19 View Source File : CommitAfterTagWithBuildMetadata.cs
License : Apache License 2.0
Project Creator : adamralph

[Fact]
        public static async Task DoesNotHaveBuildMetadata()
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory();
            await Sdk.CreateProject(path);

            await Git.Init(path);
            await Git.Commit(path);
            await Git.Tag(path, "2.3.4+build.5");
            await Git.Commit(path);

            var expected = Package.WithVersion(2, 3, 5, new[] { "alpha", "0" }, 1);

            // act
            var (actual, _) = await Sdk.BuildProject(path);
            var cli = await MinVerCli.ReadAsync(path);

            // replacedert
            replacedert.Equal(expected, actual);
            replacedert.Equal(expected.Version, cli.StandardOutput.Trim());
        }

19 View Source File : CustomDefaultPreReleasePhase.cs
License : Apache License 2.0
Project Creator : adamralph

[Fact]
        public static async Task HasCustomDefaultPreReleasePhase()
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory();
            await Sdk.CreateProject(path);

            await Git.Init(path);
            await Git.Commit(path);
            await Git.Tag(path, "2.3.4");
            await Git.Commit(path);

            var envVars = ("MinVerDefaultPreReleasePhase".ToAltCase(), "preview");

            var expected = Package.WithVersion(2, 3, 5, new[] { "preview", "0" }, 1);

            // act
            var (actual, _) = await Sdk.BuildProject(path, envVars: envVars);
            var cli = await MinVerCli.ReadAsync(path, envVars: envVars);

            // replacedert
            replacedert.Equal(expected, actual);
            replacedert.Equal(expected.Version, cli.StandardOutput.Trim());
        }

19 View Source File : MinimumMajorMinorAfterTag.cs
License : Apache License 2.0
Project Creator : adamralph

[Fact]
        public static async Task HasMinimumMajorMinorWithHeightOne()
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory();
            await Sdk.CreateProject(path);

            await Git.Init(path);
            await Git.Commit(path);
            await Git.Tag(path, "2.3.4");
            await Git.Commit(path);

            var envVars = ("MinVerMinimumMajorMinor".ToAltCase(), "3.0");

            var expected = Package.WithVersion(3, 0, 0, new[] { "alpha", "0" }, 1);

            // act
            var (actual, _) = await Sdk.BuildProject(path, envVars: envVars);
            var cli = await MinVerCli.ReadAsync(path, envVars: envVars);

            // replacedert
            replacedert.Equal(expected, actual);
            replacedert.Equal(expected.Version, cli.StandardOutput.Trim());
        }

19 View Source File : MultipleProjects.cs
License : Apache License 2.0
Project Creator : adamralph

[Net5PlusFact]
        public async Task MultipleTagPrefixes()
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory();

            await Sdk.CreateSolution(path, new[] { "project0", "project1", "project2", "project3" });

            var props =
[email protected]"<Project>

{"  "}<PropertyGroup>
{"    "}<MinVerTagPrefix>v</MinVerTagPrefix>
{"  "}</PropertyGroup>

</Project>
";

            File.WriteAllText(Path.Combine(path, "project1", "Directory.Build.props"), props);
            File.WriteAllText(Path.Combine(path, "project3", "Directory.Build.props"), props);

            await Git.Init(path);
            await Git.Commit(path);
            await Git.Tag(path, "2.3.4");
            await Git.Tag(path, "v5.6.7");

            var expected0 = Package.WithVersion(2, 3, 4);
            var expected1 = Package.WithVersion(5, 6, 7);
            var expected2 = Package.WithVersion(2, 3, 4);
            var expected3 = Package.WithVersion(5, 6, 7);

            // act
            var (actual, sdk) = await Sdk.Build(path);

            // replacedert
            replacedert.NotNull(sdk.StandardOutput);

            var versionCalculations = sdk.StandardOutput
                .Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)
                .Select(line => line.Trim())
                .Where(line => line.StartsWith("MinVer: Calculated version ", StringComparison.OrdinalIgnoreCase));

            replacedert.Collection(
                versionCalculations,
                message => replacedert.Equal("MinVer: Calculated version 2.3.4.", message),
                message => replacedert.Equal("MinVer: Calculated version 5.6.7.", message),
                message => replacedert.Equal("MinVer: Calculated version 2.3.4.", message),
                message => replacedert.Equal("MinVer: Calculated version 5.6.7.", message));

            replacedert.Collection(
                actual,
                package => replacedert.Equal(expected0, package),
                package => replacedert.Equal(expected1, package),
                package => replacedert.Equal(expected2, package),
                package => replacedert.Equal(expected3, package));
        }

19 View Source File : NonVersionTag.cs
License : Apache License 2.0
Project Creator : adamralph

[Fact]
        public static async Task HasDefaultVersion()
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory();
            await Sdk.CreateProject(path);

            await Git.Init(path);
            await Git.Commit(path);
            await Git.Tag(path, "foo");

            var expected = Package.WithVersion(0, 0, 0, new[] { "alpha", "0" });

            // act
            var (actual, _) = await Sdk.BuildProject(path);
            var cli = await MinVerCli.ReadAsync(path);

            // replacedert
            replacedert.Equal(expected, actual);
            replacedert.Equal(expected.Version, cli.StandardOutput.Trim());
        }

19 View Source File : TagWithBuildMetadata.cs
License : Apache License 2.0
Project Creator : adamralph

[Fact]
        public static async Task HasTagVersion()
        {
            // arrange
            var path = MethodBase.GetCurrentMethod().GetTestDirectory();
            await Sdk.CreateProject(path);

            await Git.Init(path);
            await Git.Commit(path);
            await Git.Tag(path, "2.3.4-alpha.5+build.6");

            var expected = Package.WithVersion(2, 3, 4, new[] { "alpha", "5" }, 0, "build.6");

            // act
            var (actual, _) = await Sdk.BuildProject(path);
            var cli = await MinVerCli.ReadAsync(path);

            // replacedert
            replacedert.Equal(expected, actual);
            replacedert.Equal(expected.Version, cli.StandardOutput.Trim());
        }

19 View Source File : CrmEntityIndexBuilder.cs
License : MIT License
Project Creator : Adoxio

public void BuildIndex()
		{
			var timer = Stopwatch.StartNew();

			ADXTrace.Instance.TraceInfo(TraceCategory.Application, "Start");

			var indexers = _index.GetIndexers();

			ADXTrace.Instance.TraceInfo(TraceCategory.Application, "Retrieving index doreplacedents");

			var enreplacedyIndexDoreplacedents = indexers.SelectMany(indexer => indexer.GetDoreplacedents());

			UsingWriter(MethodBase.GetCurrentMethod().Name, true, true, writer =>
			{
				foreach (var enreplacedyIndexDoreplacedent in enreplacedyIndexDoreplacedents)
				{
					writer.AddDoreplacedent(enreplacedyIndexDoreplacedent.Doreplacedent, enreplacedyIndexDoreplacedent.replacedyzer);
				}
			});

			timer.Stop();

			ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format("End. Elapsed time: {0}", timer.ElapsedMilliseconds));
		}

19 View Source File : CrmEntityIndexBuilder.cs
License : MIT License
Project Creator : Adoxio

private void UpdateWithIndexers(string enreplacedyLogicalName, IEnumerable<ICrmEnreplacedyIndexer> indexers)
		{
			if (!indexers.Any(indexer => indexer.Indexes(enreplacedyLogicalName)))
			{
				ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format("Application does not index enreplacedy {0}. No update performed.", enreplacedyLogicalName));

				return;
			}

			var enreplacedyIndexDoreplacedents = indexers.SelectMany(indexer => indexer.GetDoreplacedents()).ToArray();

			UsingWriter(MethodBase.GetCurrentMethod().Name, false, true, writer =>
			{
				foreach (var enreplacedyDoc in enreplacedyIndexDoreplacedents)
				{
					writer.DeleteDoreplacedents(GetEnreplacedyQuery(_index, enreplacedyLogicalName, enreplacedyDoc.PrimaryKey));
				}
			});

			int currentIndex = 0;
			while (currentIndex < enreplacedyIndexDoreplacedents.Length)
			{
				UsingWriter(MethodBase.GetCurrentMethod().Name, false, true, writer =>
				{
					var stopwatch = new Stopwatch();
					stopwatch.Start();

					for (; currentIndex < enreplacedyIndexDoreplacedents.Length; currentIndex++)
					{
						writer.AddDoreplacedent(enreplacedyIndexDoreplacedents[currentIndex].Doreplacedent, enreplacedyIndexDoreplacedents[currentIndex].replacedyzer);

						// We've held onto the write lock too long, there might be other updates waiting on us.
						// Release the lock so they don't time out, then re-enter the queue for the write lock.
						if (stopwatch.Elapsed.TotalSeconds > 10)
						{
							// break;
						}
					}
				});
			}
		}

19 View Source File : CrmEntityIndexBuilder.cs
License : MIT License
Project Creator : Adoxio

public void DeleteEnreplacedy(string enreplacedyLogicalName, Guid id)
		{
			var indexers = _index.GetIndexers(enreplacedyLogicalName).ToArray();

			if (!indexers.Any(indexer => indexer.Indexes(enreplacedyLogicalName)))
			{
				ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format("Application does not index enreplacedy {0}. No update performed.", enreplacedyLogicalName));

				return;
			}

			ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format("Deleting index for EnreplacedyLogicalName: {0}, Guid: {1} ", EnreplacedyNamePrivacy.GetEnreplacedyName(enreplacedyLogicalName), id));

			UsingWriter(MethodBase.GetCurrentMethod().Name, false, false, writer => writer.DeleteDoreplacedents(GetEnreplacedyQuery(_index, enreplacedyLogicalName, id)));
		}

19 View Source File : CrmEntityIndexBuilder.cs
License : MIT License
Project Creator : Adoxio

public void DeleteEnreplacedySet(string enreplacedyLogicalName)
		{
			var indexers = _index.GetIndexers(enreplacedyLogicalName).ToArray();

			if (!indexers.Any(indexer => indexer.Indexes(enreplacedyLogicalName)))
			{
				ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format("Application does not index enreplacedy {0}. No update performed.", enreplacedyLogicalName));

				return;
			}

			ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format("Deleting index set for EnreplacedyLogicalName: {0}", EnreplacedyNamePrivacy.GetEnreplacedyName(enreplacedyLogicalName)));

			UsingWriter(MethodBase.GetCurrentMethod().Name, false, true, writer => writer.DeleteDoreplacedents(new Term(_index.LogicalNameFieldName, enreplacedyLogicalName)));
		}

19 View Source File : CrmEntityIndexBuilder.cs
License : MIT License
Project Creator : Adoxio

public void UpdateEnreplacedy(string enreplacedyLogicalName, Guid id)
		{
			var indexers = _index.GetIndexers(enreplacedyLogicalName, id).ToArray();

			if (!indexers.Any(indexer => indexer.Indexes(enreplacedyLogicalName)))
			{
				ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format("Application does not index enreplacedy {0}. No update performed.", enreplacedyLogicalName));

				return;
			}

			var enreplacedyIndexDoreplacedents = indexers.SelectMany(indexer => indexer.GetDoreplacedents()).ToArray();

			UsingWriter(MethodBase.GetCurrentMethod().Name, false, false, writer =>
			{
				writer.DeleteDoreplacedents(GetEnreplacedyQuery(_index, enreplacedyLogicalName, id));

				foreach (var enreplacedyIndexDoreplacedent in enreplacedyIndexDoreplacedents)
				{
					writer.AddDoreplacedent(enreplacedyIndexDoreplacedent.Doreplacedent, enreplacedyIndexDoreplacedent.replacedyzer);
				}
			});
		}

19 View Source File : CrmEntityIndexBuilder.cs
License : MIT License
Project Creator : Adoxio

public void UpdateEnreplacedySet(string enreplacedyLogicalName)
		{
			var indexers = _index.GetIndexers(enreplacedyLogicalName).ToArray();

			if (!indexers.Any(indexer => indexer.Indexes(enreplacedyLogicalName)))
			{
				ADXTrace.Instance.TraceInfo(TraceCategory.Application, string.Format("Application does not index enreplacedy {0}. No update performed.", enreplacedyLogicalName));

				return;
			}

			var enreplacedyIndexDoreplacedents = indexers.SelectMany(indexer => indexer.GetDoreplacedents());

			UsingWriter(MethodBase.GetCurrentMethod().Name, false, true, writer =>
			{
				writer.DeleteDoreplacedents(new Term(_index.LogicalNameFieldName, enreplacedyLogicalName));

				foreach (var enreplacedyIndexDoreplacedent in enreplacedyIndexDoreplacedents)
				{
					writer.AddDoreplacedent(enreplacedyIndexDoreplacedent.Doreplacedent, enreplacedyIndexDoreplacedent.replacedyzer);
				}
			});
		}

19 View Source File : ClassAndMethodNamesSample.cs
License : The Unlicense
Project Creator : ahotko

public override void Execute()
        {
            string clreplacedName = this.GetType().Name;
            string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;

            replacedle("ClreplacedAndMethodNamesSampleExecute");
            Console.WriteLine($"This Clreplaced Name = {clreplacedName}");
            Console.WriteLine($"This Method Name = {methodName}");
            Finish();
        }

19 View Source File : WarehouseManager.cs
License : MIT License
Project Creator : AlphaYu

public async Task<bool> BlockQtyAsync(long orderId, Dictionary<long, int> blockQtyProductsInfo, List<Warehouse> warehouses, List<Product> products)
        {
            bool isSuccess = false;
            string remark = string.Empty;

            Checker.NotEmptyCollection(blockQtyProductsInfo, nameof(blockQtyProductsInfo));
            Checker.NotEmptyCollection(warehouses, nameof(warehouses));
            Checker.NotEmptyCollection(products, nameof(products));

            if (orderId <= 0)
                remark += $"{orderId}订单号错误";
            else if (blockQtyProductsInfo?.Count == 0)
                remark += $"商品数量为空";
            else if (warehouses?.Count == 0)
                remark += $"仓储数量为空";
            else if (products?.Count == 0)
                remark += remark + $"产品数量为空";
            else if (warehouses.Count != blockQtyProductsInfo.Count)
                remark += remark + $"商品数量与库存数量不一致";
            else
            {
                try
                {
                    //这里需要捕获业务逻辑的异常
                    foreach (var productId in blockQtyProductsInfo.Keys)
                    {
                        var product = products.FirstOrDefault(x => x.Id == productId);

                        if (product == null)
                            remark += $"{productId}已经被删除;";
                        else if (product.Status.Code != ProductStatusEnum.SaleOn)
                            remark += $"{productId}已经下架;";
                        else
                        {
                            var needBlockQty = blockQtyProductsInfo[productId];
                            var warehouse = warehouses.FirstOrDefault(x => x.ProductId == productId);
                            warehouse.BlockQty(needBlockQty);
                        }
                    }
                }
                catch (Exception ex)
                {
                    remark += ex.Message;
                }
            }

            //成功冻结所有库存
            isSuccess = string.IsNullOrEmpty(remark);

            //发布冻结库存事件(不管是否冻结成功)
            var eventId = IdGenerater.GetNextId();
            var eventData = new WarehouseQtyBlockedEvent.EventData() { OrderId = orderId, IsSuccess = isSuccess, Remark = remark };
            var eventSource = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName;
            await _eventPublisher.PublishAsync(new WarehouseQtyBlockedEvent(eventId, eventData, eventSource));

            return isSuccess;
        }

19 View Source File : OrderManager.cs
License : MIT License
Project Creator : AlphaYu

public virtual async Task CancelAsync(Order order)
        {
            Checker.NotNull(order, nameof(order));

            order.ChangeStatus(OrderStatusEnum.Canceling, string.Empty);

            //发布领域事件,通知仓储中心解冻被冻结的库存
            var eventId = IdGenerater.GetNextId();
            var eventData = new OrderCanceledEvent.EventData() { OrderId = order.Id };
            var eventSource = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName;
            await _eventPubliser.PublishAsync(new OrderCanceledEvent(eventId, eventData, eventSource));
        }

19 View Source File : OrderManager.cs
License : MIT License
Project Creator : AlphaYu

public virtual async Task PayAsync(Order order)
        {
            Checker.NotNull(order, nameof(order));

            order.ChangeStatus(OrderStatusEnum.Paying, string.Empty);

            //发布领域事件,通知客户中心扣款(Demo是从余额中扣款)
            var eventId = IdGenerater.GetNextId();
            var eventData = new OrderPaidEvent.EventData() { OrderId = order.Id, CustomerId = order.CustomerId, Amount = order.Amount };
            var eventSource = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName;
            await _eventPubliser.PublishAsync(new OrderPaidEvent(eventId, eventData, eventSource));
        }

19 View Source File : CustomerAppService.cs
License : MIT License
Project Creator : AlphaYu

public async Task<AppSrvResult<SimpleDto<string>>> RechargeAsync(long id, CustomerRechargeDto input)
        {
            var customer = await _customerRepo.FindAsync(id);
            if (customer == null)
                return Problem(HttpStatusCode.NotFound, "不存在该账号");

            var cusTransactionLog = new CustomerTransactionLog()
            {
                Id = IdGenerater.GetNextId() ,
                CustomerId = customer.Id,
                Account = customer.Account ,
                ExchangeType = ExchangeTypeEnum.Recharge,
                Remark = "",
                Amount = input.Amount ,
                ExchageStatus = ExchageStatusEnum.Processing
            };

            await _cusTransactionLogRepo.InsertAsync(cusTransactionLog);

            //发布充值事件
            var eventId = IdGenerater.GetNextId();
            var eventData = new CustomerRechargedEvent.EventData() { CustomerId = cusTransactionLog.CustomerId, TransactionLogId = cusTransactionLog.Id, Amount = cusTransactionLog.Amount };
            var eventSource = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName;
            await _eventPublisher.PublishAsync(new CustomerRechargedEvent(eventId, eventData, eventSource));
            return new SimpleDto<string>(cusTransactionLog.Id.ToString());
        }

19 View Source File : OrderManager.cs
License : MIT License
Project Creator : AlphaYu

public virtual async Task<Order> CreateAsync(long id, long customerId
            , IEnumerable<(OrderItemProduct Product, int Count)> items
            , OrderReceiver deliveryInfomation = null
            , string remark = null)
        {
            var order = new Order(
                id
               , customerId
               , deliveryInfomation
               , remark
            );

            //AddProduct会判断是否有重复的产品
            foreach (var (Product, Count) in items)
            {
                order.AddProduct(IdGenerater.GetNextId(),new OrderItemProduct(Product.Id, Product.Name, Product.Price), Count);
            }

            //发送OrderCreatedEvent事件,通知仓储中心冻结库存
            var products = order.Items.Select(x => new OrderCreatedEvent.OrderItem { ProductId = x.Product.Id, Qty = x.Count });
            var eventId = IdGenerater.GetNextId();
            var eventData = new OrderCreatedEvent.EventData() { OrderId = order.Id, Products = products };
            var eventSource = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName;
            await _eventPubliser.PublishAsync(new OrderCreatedEvent(eventId, eventData, eventSource));
            return order;
        }

19 View Source File : TypeExtensions.cs
License : MIT License
Project Creator : amolines

public static object GetDefault(this Type type)
        {
            if (type == null || !type.IsValueType || type == typeof(void))
                return null;

            if (type.ContainsGenericParameters)
                throw new ArgumentException(
                    "{" + MethodBase.GetCurrentMethod() + "} Error:\n\nThe supplied value type <" + type +
                    "> contains generic parameters, so the default value cannot be retrieved");

            if (!type.IsPrimitive && type.IsNotPublic)
                throw new ArgumentException("{" + MethodBase.GetCurrentMethod() +
                                            "} Error:\n\nThe supplied value type <" + type +
                                            "> is not a publicly-visible type, so the default value cannot be retrieved");
            try
            {
                return Activator.CreateInstance(type);
            }
            catch (Exception e)
            {
                throw new ArgumentException(
                    "{" + MethodBase.GetCurrentMethod() + "} Error:\n\nThe Activator.CreateInstance method could not " +
                    "create a default instance of the supplied value type <" + type +
                    "> (Inner Exception message: \"" + e.Message + "\")", e);
            }


        }

See More Examples