コード例 #1
0
        public void PreMergeGetsFiredWhenPulling(GitHooks sut, ObjectRepository repository, IObjectRepositoryContainer <ObjectRepository> origin, IObjectRepositoryContainerFactory containerFactory, Signature signature, string message)
        {
            // Arrange - Create origin and local repositories
            repository = origin.AddRepository(repository, signature, message);
            var tempPath        = RepositoryFixture.GetAvailableFolderPath();
            var clientContainer = containerFactory.Create <ObjectRepository>(tempPath);

            clientContainer.Clone(origin.Repositories.Single().RepositoryDescription.Path);

            // Arrange - Commit change on origin
            var change = repository.With(repository.Applications[0].Pages[0], p => p.Description, "foo");

            origin.Commit(change.Repository, signature, message);

            // Arrange - suscribe to hook
            MergeStartedEventArgs lastEvent = null;

            sut.MergeStarted += (_, args) => lastEvent = args;

            // Act - Pull commit from origin
            var pullResult = clientContainer.Pull(clientContainer.Repositories.Single().Id);
            var result     = pullResult.Apply(signature);

            // Assert
            Assert.That(lastEvent, Is.Not.Null);
            Assert.That(result, Is.Not.Null);
        }
コード例 #2
0
        public void PullRequiringMerge(ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, IObjectRepositoryContainerFactory containerFactory, Signature signature, string message)
        {
            // Arrange
            sut = container.AddRepository(sut, signature, message);
            var tempPath        = RepositoryFixture.GetAvailableFolderPath();
            var clientContainer = containerFactory.Create <ObjectRepository>(tempPath);

            clientContainer.Clone(container.Repositories.Single().RepositoryDescription.Path);

            // Arrange - Update source repository
            var change = sut.With(sut.Applications[0].Pages[0], p => p.Description, "foo");

            sut = container.Commit(change.Repository, signature, message);

            // Arrange - Update client repository
            var clientChange = sut.With(sut.Applications[0].Pages[0], p => p.Name, "bar");

            clientContainer.Commit(clientChange.Repository, signature, message);

            // Act
            var pullResult = clientContainer.Pull(clientContainer.Repositories.Single().Id);

            pullResult.Apply(signature);

            // Assert
            Assert.That(pullResult.RequiresMergeCommit, Is.True);
            Assert.That(clientContainer.Repositories.Single().Applications[0].Pages[0].Description, Is.EqualTo("foo"));
        }
コード例 #3
0
        public void CreateAndLoadRepository(ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, IObjectRepositoryContainerFactory containerFactory, Signature signature, string message)
        {
            // Arrange
            sut = container.AddRepository(sut, signature, message);

            // Act
            var newContainer = containerFactory.Create <ObjectRepository>(container.Path);
            var loaded       = newContainer.Repositories.Single();

            // Assert
            PAssert.IsTrue(AreFunctionnally.Equivalent <ObjectRepository>(() => sut == loaded));
            foreach (var apps in sut.Applications.OrderBy(v => v.Id).Zip(loaded.Applications.OrderBy(v => v.Id), (a, b) => new { source = a, desctination = b }))
            {
                PAssert.IsTrue(AreFunctionnally.Equivalent <Application>(() => apps.source == apps.desctination));
            }
        }
コード例 #4
0
        public void LoadLinkField(ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, IObjectRepositoryContainerFactory containerFactory, Signature signature, string message)
        {
            // Arrange
            container.AddRepository(sut, signature, message);
            var linkField = sut.Flatten().OfType <Field>().First(
                f => f.Content.MatchOrDefault(matchLink: l => true));

            // Act
            var newContainer    = containerFactory.Create <ObjectRepository>(container.Path);
            var loaded          = newContainer.Repositories.Single();
            var loadedLinkField = (Field)loaded.GetFromGitPath(linkField.GetFolderPath());

            // Assert
            var target    = linkField.Content.MatchOrDefault(matchLink: c => c.Target).Link;
            var newTarget = loadedLinkField.Content.MatchOrDefault(matchLink: c => c.Target).Link;

            Assert.That(newTarget.Id, Is.EqualTo(target.Id));
        }
コード例 #5
0
        public void Fetch(ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, IObjectRepositoryContainerFactory containerFactory, Signature signature, string message)
        {
            // Arrange
            sut = container.AddRepository(sut, signature, message);
            var tempPath        = RepositoryFixture.GetAvailableFolderPath();
            var clientContainer = containerFactory.Create <ObjectRepository>(tempPath);

            clientContainer.Clone(container.Repositories.Single().RepositoryDescription.Path);

            // Arrange - Update source repository
            var change       = sut.With(sut.Applications[0].Pages[0], p => p.Description, "foo");
            var commitResult = container.Commit(change.Repository, signature, message);

            // Act
            var fetchResult = clientContainer.Fetch(clientContainer.Repositories.Single().Id);

            // Assert
            Assert.That(fetchResult.CommitId, Is.EqualTo(commitResult.CommitId));
            Assert.That(clientContainer.Repositories.Single().CommitId, Is.EqualTo(sut.CommitId));
        }