コード例 #1
0
        public void no_crawlers()
        {
            using (var fixture = ProgramFixture.Create())
            {
                fixture.With(W3LogBuilder.Create().WithMultipleRegularUsersFreshEntries());
                var sut = fixture.Build();

                sut.Run();

                fixture.InsertedEntries.Should().BeEmpty();
            }
        }
コード例 #2
0
        public void no_matching_rows_default_timespan_scenario()
        {
            using (var fixture = ProgramFixture.Create())
            {
                fixture.With(W3LogBuilder.Create().WithMultipleCrawlerOldEntries());
                var sut = fixture.Build();

                sut.Run();

                fixture.InsertedEntries.Should().BeEmpty();
            }
        }
コード例 #3
0
        public void success_unbounded_timespan_scenario()
        {
            using (var fixture = ProgramFixture.Create())
            {
                fixture.WithUnboundedTimespan();
                fixture.With(W3LogBuilder.Create().WithMultipleCrawlerOldEntries());
                var sut = fixture.Build();

                sut.Run();

                fixture.InsertedEntries.Should().NotBeEmpty();
            }
        }
コード例 #4
0
        public async Task The_Bootstrap_Option_Should_Install_Modules()
        {
            // Given
            var fixture = new ProgramFixture();

            // When
            var result = await fixture.Run("--bootstrap");

            // Then
            fixture.Builder.Processor.Received(1).InstallModules(
                Arg.Any <IReadOnlyCollection <PackageReference> >(),
                Arg.Is <DirectoryPath>(p => p.FullPath == "/Working/tools/Modules"));
        }
コード例 #5
0
        public async Task The_Info_Option_Should_Call_Info_Feature(params string[] args)
        {
            // Given
            var fixture = new ProgramFixture();
            var feature = Substitute.For <IInfoFeature>();

            fixture.Overrides.Add(builder => builder.RegisterInstance(feature));

            // When
            var result = await fixture.Run(args);

            // Then
            feature.Received(1).Run();
        }
コード例 #6
0
        public async Task The_Description_Option_Should_Show_Script_Descriptions(params string[] args)
        {
            // Given
            var fixture = new ProgramFixture();
            var feature = Substitute.For <IBuildFeature>();

            fixture.Overrides.Add(builder => builder.RegisterInstance(feature));

            // When
            var result = await fixture.Run(args);

            // Then
            feature.Received(1).Run(
                Arg.Any <IRemainingArguments>(),
                Arg.Is <BuildFeatureSettings>(settings =>
                                              settings.BuildHostKind == BuildHostKind.Description));
        }
コード例 #7
0
    private static async Task VerifyPullRequestVersionIsCalculatedProperly(string pullRequestRef, Dictionary <string, string> env)
    {
        using var fixture = new EmptyRepositoryFixture();
        var remoteRepositoryPath = ExecutableHelper.GetTempPath();

        RepositoryFixtureBase.Init(remoteRepositoryPath);
        using (var remoteRepository = new Repository(remoteRepositoryPath))
        {
            remoteRepository.Config.Set("user.name", "Test");
            remoteRepository.Config.Set("user.email", "*****@*****.**");
            fixture.Repository.Network.Remotes.Add("origin", remoteRepositoryPath);
            Console.WriteLine("Created git repository at {0}", remoteRepositoryPath);
            remoteRepository.MakeATaggedCommit("1.0.3");

            var branch = remoteRepository.CreateBranch("FeatureBranch");
            Commands.Checkout(remoteRepository, branch);
            remoteRepository.MakeCommits(2);
            Commands.Checkout(remoteRepository, remoteRepository.Head.Tip.Sha);
            //Emulate merge commit
            var mergeCommitSha = remoteRepository.MakeACommit().Sha;
            Commands.Checkout(remoteRepository, TestBase.MainBranch); // HEAD cannot be pointing at the merge commit
            remoteRepository.Refs.Add(pullRequestRef, new ObjectId(mergeCommitSha));

            // Checkout PR commit
            Commands.Fetch((Repository)fixture.Repository, "origin", Array.Empty <string>(), new FetchOptions(), null);
            Commands.Checkout(fixture.Repository, mergeCommitSha);
        }

        var programFixture = new ProgramFixture(fixture.RepositoryPath);

        programFixture.WithEnv(env.ToArray());

        var result = await programFixture.Run();

        result.ExitCode.ShouldBe(0);
        result.OutputVariables.ShouldNotBeNull();
        result.OutputVariables.FullSemVer.ShouldBe("1.0.4-PullRequest0005.3");

        // Cleanup repository files
        DirectoryHelper.DeleteDirectory(remoteRepositoryPath);
    }
コード例 #8
0
        public async Task Should_Use_Default_Parameters_By_Default()
        {
            // Given
            var fixture = new ProgramFixture();
            var feature = Substitute.For <IBuildFeature>();

            fixture.Overrides.Add(builder => builder.RegisterInstance(feature));

            // When
            var result = await fixture.Run();

            // Then
            feature.Received(1).Run(
                Arg.Any <IRemainingArguments>(),
                Arg.Is <BuildFeatureSettings>(settings =>
                                              settings.BuildHostKind == BuildHostKind.Build &&
                                              settings.Debug == false &&
                                              settings.Exclusive == false &&
                                              settings.Script == null &&
                                              settings.Verbosity == Verbosity.Normal));
        }
コード例 #9
0
    private static async Task VerifyTagCheckoutVersionIsCalculatedProperly(Dictionary <string, string> env)
    {
        using var fixture = new EmptyRepositoryFixture();
        var remoteRepositoryPath = ExecutableHelper.GetTempPath();

        RepositoryFixtureBase.Init(remoteRepositoryPath);
        using (var remoteRepository = new Repository(remoteRepositoryPath))
        {
            remoteRepository.Config.Set("user.name", "Test");
            remoteRepository.Config.Set("user.email", "*****@*****.**");
            fixture.Repository.Network.Remotes.Add("origin", remoteRepositoryPath);
            Console.WriteLine("Created git repository at {0}", remoteRepositoryPath);
            remoteRepository.MakeATaggedCommit("0.1.0");
            Commands.Checkout(remoteRepository, remoteRepository.CreateBranch("develop"));
            remoteRepository.MakeACommit();
            Commands.Checkout(remoteRepository, remoteRepository.CreateBranch("release/0.2.0"));
            remoteRepository.MakeACommit();
            Commands.Checkout(remoteRepository, TestBase.MainBranch);
            remoteRepository.MergeNoFF("release/0.2.0", Generate.SignatureNow());
            remoteRepository.MakeATaggedCommit("0.2.0");

            Commands.Fetch((Repository)fixture.Repository, "origin", Array.Empty <string>(), new FetchOptions(), null);
            Commands.Checkout(fixture.Repository, "0.2.0");
        }

        var programFixture = new ProgramFixture(fixture.RepositoryPath);

        programFixture.WithEnv(env.ToArray());

        var result = await programFixture.Run();

        result.ExitCode.ShouldBe(0);
        result.OutputVariables.ShouldNotBeNull();
        result.OutputVariables.FullSemVer.ShouldBe("0.2.0");

        // Cleanup repository files
        DirectoryHelper.DeleteDirectory(remoteRepositoryPath);
    }