Beispiel #1
0
        public void Pull_FromOtherWithRevisionSpecification_OnlyPullsInRelevantChanges()
        {
            WriteTextFileAndCommit(Repo1, "test1.txt", "initial contents", "initial commit", true);
            WriteTextFileAndCommit(Repo1, "test1.txt", "changed contents", "2nd commit", false);
            WriteTextFileAndCommit(Repo1, "test1.txt", "changed contents again", "3rd commit", false);

            Repo2.Pull(
                Repo1.Path, new PullCommand
            {
                Revisions =
                {
                    RevSpec.Single(1),
                },
            });

            Changeset[] pulledChangesets   = Repo2.Log().OrderBy(c => c.RevisionNumber).ToArray();
            Changeset[] originalChangesets = Repo1.Log(
                new LogCommand
            {
                Revisions =
                {
                    RevSpec.Range(0, 1),
                },
            }).OrderBy(c => c.RevisionNumber).ToArray();
            CollectionAssert.AreEqual(pulledChangesets, originalChangesets);
        }
Beispiel #2
0
        public void Phase_OfPushedChangeset_ChangesToPublic()
        {
            if (ClientExecutable.CurrentVersion < new Version(2, 1))
            {
                Assert.Inconclusive("The phase command is not present in this Mercurial version");
            }

            Repo1.Init();
            File.WriteAllText(Path.Combine(Repo1.Path, "test1.txt"), "dummy content");
            Repo1.AddRemove();
            Repo1.Commit("Test");

            Repo2.Init();
            Repo1.Push(Repo2.Path);

            ChangesetPhase[] phases = null;
            try
            {
                phases = Repo1.Phase("0").ToArray();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }

            CollectionAssert.AreEqual(new[]
            {
                new ChangesetPhase(0, Phases.Public),
            }, phases);
        }
Beispiel #3
0
        public void Pull_TwoChangesets_InvokesIncomingHookOnce()
        {
            if (IsUsingPersistentClient)
            {
                Assert.Inconclusive("Hook tests does not function correctly under the persistent client");
                return;
            }

            Repo1.Init();
            Repo2.Clone(Repo1.Path);

            WriteTextFileAndCommit(Repo1, "test.txt", "dummy1", "dummy1", true);
            WriteTextFileAndCommit(Repo1, "test.txt", "dummy2", "dummy2", true);
            Repo2.SetHook("changegroup");

            var command = new CustomCommand("pull")
                          .WithAdditionalArgument(string.Format(CultureInfo.InvariantCulture, "\"{0}\"", Repo1.Path));

            Repo2.Execute(command);

            Assert.That(command.RawExitCode, Is.EqualTo(0));
            Assert.That(command.RawStandardOutput.Count("Revision:"), Is.EqualTo(1));
            Assert.That(command.RawStandardOutput.Count("Url:"), Is.EqualTo(1));
            Assert.That(command.RawStandardOutput.Count("Source:"), Is.EqualTo(1));
        }
        public async Task <IActionResult> Get()
        {
            //Repo.BeginTransaction();
            //var result = await Repo.QueryFirstOrDefaultAsync("select * from goods ;");
            //Repo.CommitTransaction();
            //return Ok(result);

            var r1 = await Repo1.QueryAsync <object>("select * from COMPANY where id=1 LIMIT 1 OFFSET 0", enableCache : true, cacheExpire : TimeSpan.FromSeconds(100));

            int pageindex = 1;
            var page      = await Repo2.QueryPageAsync <object>("select count(*) from COMPANY;", "select * from COMPANY limit @Take OFFSET @Skip;", pageindex, 20, enableCache : true, cacheKey : $"page:{pageindex}");

            ////var r2 = await Repo2.QueryAsync("select * from COMPANY where id=2 LIMIT 1 OFFSET 0");
            //return Ok(new
            //{
            //    SQLite = new { r1, page },
            //    //SQL = new
            //    //{
            //    //    page = await SQLRepo.QueryPageAsync("select count(*) from Company;", "select * from Company;", 1, 20)
            //    //}
            //});

            var con  = Repo2.Query("select * from company;");
            var list = await Repo1.QueryAsync <object>(name : "COMPANY.list.query", new { id = 1 });

            var sql = Repo1.GetSQL("contact.query");
            var r   = await Repo1.QueryAsync <Contact, Passport, Contact>(sql, (contact, passport) =>
            {
                contact.Passport = passport;
                return(contact);
            }, null, "PassportNumber");

            return(Ok(new { r1, page }));
        }
Beispiel #5
0
        public void Outgoing_CloneOfMasterWithNoExtraChanges_ReturnsEmptyCollection()
        {
            Repo1.Init();
            Repo2.Clone(Repo1.Path);
            Changeset[] outgoing = Repo2.Outgoing().ToArray();

            Assert.That(outgoing.Length, Is.EqualTo(0));
        }
Beispiel #6
0
        public void Bundle_WithJustCommandButMissingFileName_ThrowsInvalidOperationException()
        {
            var command = new BundleCommand
            {
                Destination = "http://dummy/repo",
            };

            Assert.Throws <InvalidOperationException>(() => Repo1.Bundle(command));
        }
Beispiel #7
0
        public void Pull_FromOther_PullsInAllChanges()
        {
            WriteTextFileAndCommit(Repo1, "test1.txt", "initial contents", "initial commit", true);
            WriteTextFileAndCommit(Repo1, "test1.txt", "changed contents", "2nd commit", false);

            Repo2.Pull(Repo1.Path);

            CollectionAssert.AreEqual(Repo2.Log(), Repo1.Log());
        }
Beispiel #8
0
        public void Outgoing_UnrelatedRepositoryWithoutForce_ThrowsMercurialExecutionException()
        {
            Repo1.Init();
            WriteTextFileAndCommit(Repo1, "test1.txt", "dummy", "dummy", true);

            Repo2.Init();
            WriteTextFileAndCommit(Repo2, "test2.txt", "dummy", "dummy", true);

            Assert.Throws <MercurialExecutionException>(() => Repo2.Outgoing(Repo1.Path));
        }
Beispiel #9
0
        public void Bundle_UnrelatedDestinationRepository_ThrowsMercurialExecutionException()
        {
            Repo1.Init();
            WriteTextFileAndCommit(Repo1, "test1.txt", "dummy", "dummy", true);

            Repo2.Init();
            WriteTextFileAndCommit(Repo2, "test2.txt", "dummy", "dummy", true);

            Assert.Throws <MercurialExecutionException>(() => Repo1.Bundle(GetTempFileName(), Repo2.Path));
        }
Beispiel #10
0
        public void Unbundle_NoRepository_ThrowsMercurialExecutionException()
        {
            string bundleFileName = GetTempFileName();

            Repo1.Init();
            WriteTextFileAndCommit(Repo1, "test1.txt", "dummy", "dummy", true);
            Repo1.Bundle(bundleFileName, new BundleCommand().WithAll());

            Assert.Throws <MercurialExecutionException>(() => Repo2.Unbundle(bundleFileName));
        }
Beispiel #11
0
        public override void TearDown()
        {
            Repo1.Dispose();
            Repo1 = null;

            Repo2.Dispose();
            Repo2 = null;

            base.TearDown();
        }
Beispiel #12
0
        public void Phase_OfNonExistantChangeset_ThrowsMercurialExecutionException()
        {
            if (ClientExecutable.CurrentVersion < new Version(2, 1))
            {
                Assert.Inconclusive("The phase command is not present in this Mercurial version");
            }

            Repo1.Init();

            Assert.Throws <MercurialExecutionException>(() => Repo1.Phase("600").ToArray());
        }
Beispiel #13
0
        public void Outgoing_CloneOfMasterWithExtraChanges_ReturnsTheExtraChangesets()
        {
            const string commitMessage = "commit message in clone";

            Repo1.Init();
            Repo2.Clone(Repo1.Path);
            WriteTextFileAndCommit(Repo2, "test.txt", "dummy", commitMessage, true);
            Changeset[] outgoing = Repo2.Outgoing().ToArray();

            Assert.That(outgoing.Length, Is.EqualTo(1));
            Assert.That(outgoing[0].CommitMessage, Is.EqualTo(commitMessage));
        }
        public async Task <IActionResult> Transaction()
        {
            Repo1.BeginTransaction();
            var result = await Repo1.QueryFirstOrDefaultAsync("select * from COMPANY where id=1;");

            if (result != null)
            {
                await Repo1.ExecuteAsync("update COMPANY set name=@name where id=1;", new { name = Guid.NewGuid().ToString() });

                Repo1.CommitTransaction();
            }
            return(Ok());
        }
Beispiel #15
0
        public void Bundle_PulledIntoEmptyRepository_ProducesCloneOfSource()
        {
            string bundleFileName = GetTempFileName();

            Repo1.Init();
            WriteTextFileAndCommit(Repo1, "test1.txt", "dummy", "dummy", true);

            Repo2.Init();

            Repo1.Bundle(bundleFileName, Repo2.Path);
            Repo2.Pull(bundleFileName);

            CollectionAssert.AreEqual(Repo1.Log(new LogCommand().WithIncludePathActions()), Repo2.Log(new LogCommand().WithIncludePathActions()));
        }
Beispiel #16
0
        public void Outgoing_UnrelatedRepositoryWithForce_ReturnsCollectionOfChangesets()
        {
            const string commitMessage = "commit message in clone";

            Repo1.Init();
            WriteTextFileAndCommit(Repo1, "test1.txt", "dummy", "dummy", true);

            Repo2.Init();
            WriteTextFileAndCommit(Repo2, "test2.txt", "dummy", commitMessage, true);
            Changeset[] outgoing = Repo2.Outgoing(Repo1.Path, new OutgoingCommand().WithForce()).ToArray();

            Assert.That(outgoing.Length, Is.EqualTo(1));
            Assert.That(outgoing[0].CommitMessage, Is.EqualTo(commitMessage));
        }
Beispiel #17
0
        public void Push_IntoUnrelatedRepositoryWithForce_PushesSuccessfullyAndCreatesAnotherHead()
        {
            WriteTextFileAndCommit(Repo1, "test1.txt", "dummy", "dummy", true);
            WriteTextFileAndCommit(Repo2, "test2.txt", "dummy", "dummy", true);

            Repo2.Push(
                Repo1.Path, new PushCommand
            {
                Force = true,
            });

            Changeset[] log = Repo1.Heads().ToArray();

            Assert.That(log.Length, Is.EqualTo(2));
        }
Beispiel #18
0
        public void Incoming_SavingTheBundle_AllowsPullFromBundle()
        {
            string bundleFileName = Path.GetTempFileName();

            Repo1.Init();
            Repo2.Clone(Repo1.Path);

            WriteTextFileAndCommit(Repo1, "test1.txt", "dummy", "dummy", true);
            Repo2.Incoming(new IncomingCommand().WithBundleFileName(bundleFileName));

            Changeset[] log = Repo2.Log().ToArray();
            Assert.That(log.Length, Is.EqualTo(0));

            Repo2.Pull(bundleFileName);

            log = Repo2.Log().ToArray();
            Assert.That(log.Length, Is.EqualTo(1));
        }
        public void Pull_OneChangeset_InvokesIncomingHookOnce()
        {
            Repo1.Init();
            Repo2.Clone(Repo1.Path);

            WriteTextFileAndCommit(Repo1, "test.txt", "dummy", "dummy", true);
            Repo2.SetHook("incoming");

            var command = new CustomCommand("pull")
                          .WithAdditionalArgument(string.Format(CultureInfo.InvariantCulture, "\"{0}\"", Repo1.Path));

            Repo2.Execute(command);

            Assert.That(command.RawExitCode, Is.EqualTo(0));
            Assert.That(command.RawStandardOutput.Count("Revision:"), Is.EqualTo(1));
            Assert.That(command.RawStandardOutput.Count("Url:"), Is.EqualTo(1));
            Assert.That(command.RawStandardOutput.Count("Source:"), Is.EqualTo(1));
        }
Beispiel #20
0
        public void Bundle_DestinationIsACompleteClone_ThrowsNoChangesFoundMercurialExecutionExceptionAndLeavesFileAsIs()
        {
            string bundleFileName = GetTempFileName();

            Repo1.Init();
            WriteTextFileAndCommit(Repo1, "test1.txt", "dummy", "dummy", true);

            Repo2.Clone(Repo1.Path);

            Assert.Throws <NoChangesFoundMercurialExecutionException>(() => Repo1.Bundle(bundleFileName, Repo2.Path));

            long length;

            using (var stream = new FileStream(bundleFileName, FileMode.Open))
            {
                length = stream.Length;
            }
            Assert.That(length, Is.EqualTo(0));
        }
Beispiel #21
0
        public void Bundle_DestinationIsEmpty_ProducesBundleFile()
        {
            string bundleFileName = GetTempFileName();

            Repo1.Init();
            WriteTextFileAndCommit(Repo1, "test1.txt", "dummy", "dummy", true);

            Repo2.Init();

            Repo1.Bundle(bundleFileName, Repo2.Path);

            long length;

            using (var stream = new FileStream(bundleFileName, FileMode.Open))
            {
                length = stream.Length;
            }
            Assert.That(length, Is.GreaterThan(0));
        }
Beispiel #22
0
        public void Pull_Branch_OnlyPullsThatBranch()
        {
            WriteTextFileAndCommit(Repo1, "test1.txt", "initial contents", "initial commit", true);
            Repo2.Pull(Repo1.Path);

            Repo1.Branch("newbranch");
            WriteTextFileAndCommit(Repo1, "test2.txt", "initial contents", "2nd commit", true);
            Repo1.Update(0);
            WriteTextFileAndCommit(Repo1, "test3.txt", "initial contents", "3rd commit", true);

            Changeset[] log = Repo2.Log().ToArray();
            Assert.That(log.Length, Is.EqualTo(1));

            Repo2.Pull(
                Repo1.Path, new PullCommand
            {
                Branches =
                {
                    "newbranch",
                },
            });
            log = Repo2.Log().ToArray();
            Assert.That(log.Length, Is.EqualTo(2));
        }
Beispiel #23
0
 public Add(Repo1 repo1)
 {
     Repo = repo1;
 }
Beispiel #24
0
 public void Unbundle_NullOrEmptyFileName_ThrowsArgumentNullException(string input)
 {
     Repo1.Init();
     Assert.Throws <ArgumentNullException>(() => Repo1.Unbundle(input));
 }
Beispiel #25
0
 public void Unbundle_InvalidFile_ThrowsMercurialExecutionException()
 {
     Repo1.Init();
     Assert.Throws <MercurialExecutionException>(() => Repo1.Unbundle(GetTempFileName()));
 }
Beispiel #26
0
 public void Bundle_NullOrEmptyFileName_ThrowsArgumentNullException(string input)
 {
     Assert.Throws <ArgumentNullException>(() => Repo1.Bundle(input, "http://dummy/repo"));
 }
Beispiel #27
0
        public void Bundle_NullOrEmptyDestination_ThrowsArgumentNullException(string input)
        {
            string tempFileName = Path.GetTempFileName();

            Assert.Throws <ArgumentNullException>(() => Repo1.Bundle(tempFileName, input));
        }
Beispiel #28
0
 AConcreteViewModelEnricher(Repo1 repo1, Reop2 rep2)
 {
Beispiel #29
0
 public override void SetUp()
 {
     base.SetUp();
     Repo1.Init();
     Repo2.Init();
 }
Beispiel #30
0
        public void Bundle_NoRepository_ThrowsMercurialExecutionException()
        {
            string tempFileName = GetTempFileName();

            Assert.Throws <MercurialExecutionException>(() => Repo1.Bundle(tempFileName));
        }