public void MergeFileAdditionChange(ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, IServiceProvider serviceProvider, Signature signature, string message, ComputeTreeChangesFactory computeTreeChangesFactory) { // master: A---C---D // \ / // newBranch: B---' // Arrange sut = container.AddRepository(sut, signature, message); // A // Act sut = container.Checkout(sut.Id, "newBranch", createNewBranch: true); var updateName = sut.With(c => c.Add(sut.Applications[0].Pages[0], p => p.Fields, new Field(serviceProvider, UniqueId.CreateNew(), "new field", FieldContent.Default))); container.Commit(updateName.Repository, signature, message); // B var a = container.Checkout(sut.Id, "master"); var updateDescription = a.With(a.Applications[0].Pages[0], p => p.Description, "modified description"); var commitC = container.Commit(updateDescription.Repository, signature, message); // C var mergeCommit = container.Merge(sut.Id, "newBranch").Apply(signature); // D // Assert var changes = computeTreeChangesFactory(container, container[sut.Id].RepositoryDescription) .Compare(commitC.CommitId, mergeCommit) .SkipIndexChanges(); Assert.That(changes, Has.Count.EqualTo(1)); Assert.That(changes[0].Status, Is.EqualTo(ChangeKind.Added)); Assert.That(changes[0].New.Name, Is.EqualTo("new field")); }
public void MergeFileDeletionChange(ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, Signature signature, string message, ComputeTreeChangesFactory computeTreeChangesFactory) { // master: A---C---D // \ / // newBranch: B---' // Arrange var a = container.AddRepository(sut, signature, message); // A // Act a = container.Checkout(a.Id, "newBranch", createNewBranch: true); var page = a.Applications[0].Pages[0]; var updateName = a.With(c => c.Remove(page, p => p.Fields, page.Fields[1])); container.Commit(updateName, signature, message); // B a = container.Checkout(a.Id, "master"); var updateDescription = a.With(a.Applications[0].Pages[0], p => p.Description, "modified description"); var commitC = container.Commit(updateDescription.Repository, signature, message); // C var mergeCommit = container.Merge(sut.Id, "newBranch").Apply(signature); // D // Assert var changes = computeTreeChangesFactory(container, container[sut.Id].RepositoryDescription) .Compare(commitC.CommitId, mergeCommit) .SkipIndexChanges(); Assert.That(changes, Has.Count.EqualTo(1)); Assert.That(changes[0].Status, Is.EqualTo(ChangeKind.Deleted)); Assert.That(changes[0].Old.Id, Is.EqualTo(page.Fields[1].Id)); }
public void MergeTwoDifferentPropertiesChanged(ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, Signature signature, string message, ComputeTreeChangesFactory computeTreeChangesFactory) { // master: A---C---D // \ / // newBranch: B---' // Arrange sut = container.AddRepository(sut, signature, message); // A // Act sut = container.Checkout(sut.Id, "newBranch", createNewBranch: true); var updateName = sut.With(sut.Applications[0].Pages[0], p => p.Name, "modified name"); container.Commit(updateName.Repository, signature, message); // B var a = container.Checkout(sut.Id, "master"); var updateDescription = a.With(a.Applications[0].Pages[0], p => p.Description, "modified description"); var commitC = container.Commit(updateDescription.Repository, signature, message); // C var mergeCommit = container.Merge(sut.Id, "newBranch").Apply(signature); // D // Assert var changes = computeTreeChangesFactory(container, container[sut.Id].RepositoryDescription) .Compare(commitC.CommitId, mergeCommit) .SkipIndexChanges(); Assert.That(changes, Has.Count.EqualTo(1)); Assert.That(changes[0].Status, Is.EqualTo(ChangeKind.Modified)); Assert.That(changes[0].Old.Name, Is.EqualTo(sut.Applications[0].Pages[0].Name)); Assert.That(changes[0].New.Name, Is.EqualTo(updateName.Name)); }
public void MergeSamePropertyConflict(ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, Signature signature, string message, ComputeTreeChangesFactory computeTreeChangesFactory) { // master: A---C---D // \ / // newBranch: B---' // Arrange var a = container.AddRepository(sut, signature, message); // A // Act a = container.Checkout(sut.Id, "newBranch", createNewBranch: true); var updateName = a.With(a.Applications[0].Pages[0], p => p.Name, "modified name"); container.Commit(updateName.Repository, signature, message); // B a = container.Checkout(sut.Id, "master"); var updateNameOther = a.With(a.Applications[0].Pages[0], p => p.Name, "yet again modified name"); var commitC = container.Commit(updateNameOther.Repository, signature, message); // C var merge = container.Merge(sut.Id, "newBranch"); var chunk = merge.ModifiedProperties.Single(); chunk.Resolve("merged name"); var mergeCommit = merge.Apply(signature); // D // Assert var changes = computeTreeChangesFactory(container, container[sut.Id].RepositoryDescription) .Compare(commitC.CommitId, mergeCommit) .SkipIndexChanges(); Assert.That(changes, Has.Count.EqualTo(1)); Assert.That(changes[0].Status, Is.EqualTo(ChangeKind.Modified)); Assert.That(changes[0].Old.Name, Is.EqualTo("yet again modified name")); Assert.That(changes[0].New.Name, Is.EqualTo("merged name")); }
static void CreateConflictingChange(BlobRepository sut, IObjectRepositoryContainer <BlobRepository> container, Signature signature, string message) { // master: A---B // \ (B & C change same value) // newBranch: C -> A---B---C var a = container.AddRepository(sut, signature, message); // A var updateName = a.With(a, r => r.Blob, new StringBlob("x\nb\nc")); container.Commit(updateName.Repository, signature, message); // B container.Checkout(a.Id, "newBranch", createNewBranch: true, "HEAD~1"); var updates = a.With(a, r => r.Blob, new StringBlob("z\nb\nd")); container.Commit(updates, signature, message); }
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); }
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")); }
public void ObjectDeletionIsAlsoDeletingBlobs(BlobRepository repository, IObjectRepositoryContainer <BlobRepository> container, Signature signature, string message) { // Arrange var a = container.AddRepository(repository, signature, message); // Act var b = container.Commit( repository.With(c => c.Remove(repository, r => r.Cars, repository.Cars[0])), signature, message); // Assert b.Execute(r => { var changes = r.Diff.Compare <TreeChanges>( r.Lookup <Commit>(a.CommitId).Tree, r.Lookup <Commit>(b.CommitId).Tree); Assert.That( changes.Deleted.Select(c => c.Path), Is.EquivalentTo(new[] { $"Cars/{a.Cars[0].Id}/blob{FileSystemStorage.BlobExtension}", $"Cars/{a.Cars[0].Id}/{FileSystemStorage.DataFile}" })); }); }
static IObjectRepositoryCherryPick CreateConflictingCherryPick(ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, Signature signature, string message) { // master: A---B // \ (B & C change same property) // newBranch: C -> A---C---B var a = container.AddRepository(sut, signature, message); // A var b = container.Commit( a.With(a.Applications[0].Pages[0], p => p.Name, "foo").Repository, signature, message); // B a = container.Checkout(a.Id, "newBranch", createNewBranch: true, "HEAD~1"); container.Commit( a.With(c => c .Update(a.Applications[0].Pages[0], p => p.Name, "bar") .Update(a.Applications[0].Pages[0], p => p.Description, "bar") .Update(a.Applications[0].Pages[0].Fields[0], f => f.Name, "bar")), signature, message); return(container.CherryPick(sut.Id, b.CommitId)); }
public void CherryPickChildAddition(IServiceProvider serviceProvider, ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, Signature signature, string message) { // master: A---B---C // \ // newBranch: D -> A---D---C // Arrange var a = container.AddRepository(sut, signature, message); // A // Act var b = container.Commit( a.With(a.Applications[0], app => app.Name, "unpicked modified name").Repository, signature, message); // B var page = new Page(serviceProvider, UniqueId.CreateNew(), "name", "description", new LazyChildren <Field>()); var c = container.Commit( b.With(comp => comp.Add(b.Applications[0], app => app.Pages, page)).Repository, signature, message); // C a = container.Checkout(a.Id, "newBranch", createNewBranch: true, "HEAD~2"); var d = container.Commit( a.With(a.Applications[0], app => app.Name, "modified name").Repository, signature, message); // D var cherryPick = container.CherryPick(sut.Id, c.CommitId); var repository = container.Repositories.Single(); // Assert Assert.That(cherryPick.Status, Is.EqualTo(CherryPickStatus.CherryPicked)); var(commits, tip) = repository.Execute(r => { var commitFilter = new CommitFilter { IncludeReachableFrom = r.Head.Tip, SortBy = CommitSortStrategies.Reverse | CommitSortStrategies.Topological, }; return(r.Commits.QueryBy(commitFilter).Select(commit => commit.Id).ToList(), r.Head.Tip.Id); }); Assert.That(commits, Has.Count.EqualTo(3)); Assert.That(commits[0], Is.EqualTo(a.CommitId)); Assert.That(commits[1], Is.EqualTo(d.CommitId)); Assert.That(commits[2], Is.EqualTo(tip)); Assert.That(repository.CommitId, Is.EqualTo(tip)); Assert.That(repository.Applications[0].Name, Is.EqualTo("modified name")); Assert.That(repository.Applications[0].Pages, Has.Count.EqualTo(a.Applications[0].Pages.Count + 1)); }
public void RebaseFailsWhenUpstreamBranchContainsMigrations(ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, Signature signature, string message, DummyMigration migration) { // master: A---B (B contains a migration) // \ // newBranch: C -> A---C---B // Arrange var a = container.AddRepository(sut, signature, message); // A // Act container.Commit( a.With(c => c.Add(a, r => r.Migrations, migration)).Repository, signature, message); // B a = container.Checkout(a.Id, "newBranch", createNewBranch: true, "HEAD~1"); container.Commit( a.With(a.Applications[0].Pages[0], p => p.Description, "modified description").Repository, signature, message); // C Assert.Throws <NotSupportedException>(() => container.Rebase(sut.Id, "master")); }
public void CherryPickTwoDifferentPropertiesChanged(ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, Signature signature, string message) { // master: A---B---C // \ // newBranch: D -> A---D---C // Arrange var a = container.AddRepository(sut, signature, message); // A // Act var b = container.Commit( a.With(a.Applications[0].Pages[0], p => p.Description, "unpicked modified description").Repository, signature, message); // B var c = container.Commit( b.With(b.Applications[0].Pages[0], p => p.Name, "modified name").Repository, signature, message); // C a = container.Checkout(a.Id, "newBranch", createNewBranch: true, "HEAD~2"); var d = container.Commit( a.With(a.Applications[0].Pages[0], p => p.Description, "modified description").Repository, signature, message); // D var cherryPick = container.CherryPick(sut.Id, c.CommitId); var repository = container.Repositories.Single(); // Assert Assert.That(cherryPick.Status, Is.EqualTo(CherryPickStatus.CherryPicked)); var(commits, tip) = repository.Execute(r => { var commitFilter = new CommitFilter { IncludeReachableFrom = r.Head.Tip, SortBy = CommitSortStrategies.Reverse | CommitSortStrategies.Topological, }; return(r.Commits.QueryBy(commitFilter).Select(commit => commit.Id).ToList(), r.Head.Tip.Id); }); Assert.That(commits[0], Is.EqualTo(a.CommitId)); Assert.That(commits[1], Is.EqualTo(d.CommitId)); Assert.That(commits[2], Is.EqualTo(tip)); Assert.That(repository.CommitId, Is.EqualTo(tip)); Assert.That(repository.Applications[0].Pages[0].Name, Is.EqualTo("modified name")); Assert.That(repository.Applications[0].Pages[0].Description, Is.EqualTo("modified description")); }
public void MergeSamePropertyDetectsConflicts(ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, Signature signature, string message) { // master: A---C---D // \ / // newBranch: B---' // Arrange var a = container.AddRepository(sut, signature, message); // A // Act a = container.Checkout(sut.Id, "newBranch", createNewBranch: true); var updateName = a.With(a.Applications[0].Pages[0], p => p.Name, "modified name"); container.Commit(updateName.Repository, signature, message); // B a = container.Checkout(sut.Id, "master"); var updateNameOther = a.With(a.Applications[0].Pages[0], p => p.Name, "yet again modified name"); container.Commit(updateNameOther.Repository, signature, message); // C Assert.Throws <RemainingConflictsException>(() => container.Merge(sut.Id, "newBranch").Apply(signature)); }
public void CommitPageNameUpdate(ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, Signature signature, string message) { // Act sut = container.AddRepository(sut, signature, message); var modifiedPage = sut.With(sut.Applications[0].Pages[0], p => p.Name, "modified"); var updated = container.Commit(modifiedPage.Repository, signature, message); var retrievedPage = updated.Flatten().OfType <Page>().FirstOrDefault(p => p.Name == "modified"); // Assert Assert.That(retrievedPage.Name, Is.EqualTo("modified")); }
public void RebaseChildAddition(IServiceProvider serviceProvider, ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, Signature signature, string message) { // master: A---B // \ // newBranch: C -> A---C---B // Arrange var a = container.AddRepository(sut, signature, message); // A // Act var updateName = a.With(a.Applications[0], app => app.Name, "modified name"); var b = container.Commit(updateName.Repository, signature, message); // B a = container.Checkout(a.Id, "newBranch", createNewBranch: true, "HEAD~1"); var page = new Page(serviceProvider, UniqueId.CreateNew(), "name", "description", new LazyChildren <Field>()); var addPage = a.With(c => c.Add(a.Applications[0], app => app.Pages, page)); container.Commit(addPage.Repository, signature, message); // C var rebase = container.Rebase(sut.Id, "master"); var repository = container.Repositories.Single(); // Assert Assert.That(rebase.Status, Is.EqualTo(RebaseStatus.Complete)); Assert.That(rebase.TotalStepCount, Is.EqualTo(1)); var(commits, tip) = repository.Execute(r => { var commitFilter = new CommitFilter { IncludeReachableFrom = r.Head.Tip, SortBy = CommitSortStrategies.Reverse | CommitSortStrategies.Topological, }; return(r.Commits.QueryBy(commitFilter).Select(c => c.Id).ToList(), r.Head.Tip.Id); }); Assert.That(commits, Has.Count.EqualTo(3)); Assert.That(commits[0], Is.EqualTo(a.CommitId)); Assert.That(commits[1], Is.EqualTo(b.CommitId)); Assert.That(commits[2], Is.EqualTo(tip)); Assert.That(repository.CommitId, Is.EqualTo(tip)); Assert.That(repository.Applications[0].Name, Is.EqualTo("modified name")); Assert.That(repository.Applications[0].Pages, Has.Count.EqualTo(a.Applications[0].Pages.Count + 1)); }
public void RebaseTwoDifferentPropertiesChanged(ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, Signature signature, string message) { // master: A---B // \ // newBranch: C -> A---C---B // Arrange var a = container.AddRepository(sut, signature, message); // A // Act var updateName = a.With(a.Applications[0].Pages[0], p => p.Name, "modified name"); var b = container.Commit(updateName.Repository, signature, message); // B a = container.Checkout(a.Id, "newBranch", createNewBranch: true, "HEAD~1"); var updateDescription = a.With(a.Applications[0].Pages[0], p => p.Description, "modified description"); container.Commit(updateDescription.Repository, signature, message); // C var rebase = container.Rebase(sut.Id, "master"); var repository = container.Repositories.Single(); // Assert Assert.That(rebase.Status, Is.EqualTo(RebaseStatus.Complete)); Assert.That(rebase.TotalStepCount, Is.EqualTo(1)); var(commits, tip) = repository.Execute(r => { var commitFilter = new CommitFilter { IncludeReachableFrom = r.Head.Tip, SortBy = CommitSortStrategies.Reverse | CommitSortStrategies.Topological, }; return(r.Commits.QueryBy(commitFilter).Select(c => c.Id).ToList(), r.Head.Tip.Id); }); Assert.That(commits[0], Is.EqualTo(a.CommitId)); Assert.That(commits[1], Is.EqualTo(b.CommitId)); Assert.That(commits[2], Is.EqualTo(tip)); Assert.That(repository.CommitId, Is.EqualTo(tip)); Assert.That(repository.Applications[0].Pages[0].Name, Is.EqualTo("modified name")); Assert.That(repository.Applications[0].Pages[0].Description, Is.EqualTo("modified description")); }
public void MergeTwoDifferentPropertiesWithMigrationChanged(ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, IFixture fixture, Signature signature, string message) { // master: A-----D-----E---F // \ / / // \ ,---' / // \ / x / // newBranch: B---C---' (B contains a non-idempotent migration) // Arrange var a = container.AddRepository(sut, signature, message); // A // B, C a = container.Checkout(sut.Id, "newBranch", createNewBranch: true); var updatedInstance = a.With(c => c.Add(a, r => r.Migrations, fixture.Create <DummyMigration>())); var b = container.Commit(updatedInstance, signature, message); // B Assert.That(b.Migrations.Count, Is.GreaterThan(0)); var updateName = b.With(b.Applications[1].Pages[1], p => p.Name, "modified name"); container.Commit(updateName.Repository, signature, message); // C // D a = container.Checkout(sut.Id, "master"); var updateDescription = a.With(a.Applications[0].Pages[0], p => p.Description, "modified description"); container.Commit(updateDescription.Repository, signature, message); // D // E var mergeStep1 = container.Merge(sut.Id, "newBranch"); Assert.That(mergeStep1.IsPartialMerge, Is.True); mergeStep1.Apply(signature); // E // F var mergeStep2 = container.Merge(sut.Id, "newBranch"); Assert.That(mergeStep2.IsPartialMerge, Is.False); mergeStep2.Apply(signature); // F }
static (string, ObjectRepository) PushNewRemoteImpl(ObjectRepository repository, IObjectRepositoryContainer <ObjectRepository> container, Signature signature, string message) { var tempPath = RepositoryFixture.GetAvailableFolderPath(); Repository.Init(tempPath, isBare: true); repository = container.AddRepository(repository, signature, message); repository.Execute(r => r.Network.Remotes.Add("origin", tempPath)); var change = repository.With(repository.Applications[0].Pages[0], p => p.Description, "foo"); repository = container.Commit(change.Repository, signature, message); container.Push(repository.Id, "origin"); return(tempPath, repository); }
public void IndexUpdateWhenPropertyIsBeingChanged(IServiceProvider serviceProvider, ObjectRepository repository, IObjectRepositoryContainer <ObjectRepository> container, Signature signature, string message, string name) { // Arrange repository = repository.With(c => c .Add(repository, r => r.Indexes, new Index(serviceProvider, UniqueId.CreateNew(), name, nameof(IModelObject.Name)))); repository = container.AddRepository(repository, signature, message); ComputeKeysCalls.Clear(); // Act var modified = repository.With(repository.Applications[0].Pages[1], p => p.Description, "modified description"); container.Commit(modified.Repository, signature, message); // Assert Assert.That(ComputeKeysCalls, Has.Count.EqualTo(2)); // Two calls to ComputeKeys for before/after }
public void IndexUpdateWhenBlobIsBeingChanged(IServiceProvider serviceProvider, BlobRepository repository, IObjectRepositoryContainer <BlobRepository> container, Signature signature, string message, string name) { // Arrange repository = repository.With(c => c .Add(repository, r => r.Indexes, new Index(serviceProvider, UniqueId.CreateNew(), name, nameof(Car.Blob)))); repository = container.AddRepository(repository, signature, message); IndexTests.ComputeKeysCalls.Clear(); // Act var modified = repository.With(repository, r => r.Blob, new StringBlob("modified blob")); container.Commit(modified.Repository, signature, message); // Assert Assert.That(IndexTests.ComputeKeysCalls, Has.Count.EqualTo(2)); // Two calls to ComputeKeys for before/after }
public void PostCommitWhenPropertyChangeGetsFired(GitHooks sut, ObjectRepository repository, IObjectRepositoryContainer <ObjectRepository> container, Signature signature, string message) { // Arrange CommitCompletedEventArgs lastEvent = null; sut.CommitCompleted += (_, args) => lastEvent = args; // Act repository = container.AddRepository(repository, signature, message); var modifiedPage = repository.With(repository.Applications[0].Pages[0], p => p.Name, "modified"); var commit = container.Commit(modifiedPage.Repository, signature, message); // Assert Assert.That(lastEvent, Is.Not.Null); Assert.That(lastEvent.CommitId, Is.EqualTo(commit.CommitId)); }
public void MigrationScaffolderDetectsRequiredChanges(ObjectRepository repository, IObjectRepositoryContainer <ObjectRepository> container, IFixture fixture, IServiceProvider serviceProvider, Signature signature, string message) { // Arrange repository = container.AddRepository(repository, signature, message); var updated = repository.With(c => c.Add(repository, r => r.Migrations, fixture.Create <DummyMigration>())); var commit = container.Commit(updated, signature, message); // Act var migrationScaffolder = new MigrationScaffolder(container, repository.RepositoryDescription, serviceProvider.GetRequiredService <IRepositoryProvider>(), serviceProvider.GetRequiredService <ObjectRepositorySerializerFactory>()); var migrators = migrationScaffolder.Scaffold(repository.CommitId, commit.CommitId, MigrationMode.Upgrade); // Assert Assert.That(migrators, Has.Count.EqualTo(1)); Assert.That(migrators[0].CommitId, Is.EqualTo(commit.CommitId)); Assert.That(migrators[0].Mode, Is.EqualTo(MigrationMode.Upgrade)); Assert.That(migrators[0].Migrations, Has.Count.EqualTo(1)); }
public void IndexUpdateWhenObjectIsBeingAdded(IServiceProvider serviceProvider, ObjectRepository repository, IObjectRepositoryContainer <ObjectRepository> container, Signature signature, string message, string name) { // Arrange repository = repository.With(c => c .Add(repository, r => r.Indexes, new Index(serviceProvider, UniqueId.CreateNew(), name, nameof(IModelObject.Name)))); repository = container.AddRepository(repository, signature, message); ComputeKeysCalls.Clear(); var page = new Page(serviceProvider, UniqueId.CreateNew(), "name", "description", new LazyChildren <Field>(ImmutableList.Create( new Field(serviceProvider, UniqueId.CreateNew(), "name", FieldContent.Default)))); // Act var modified = repository.With(c => c.Add(repository.Applications[0], app => app.Pages, page)); container.Commit(modified.Repository, signature, message); // Assert Assert.That(ComputeKeysCalls, Has.Count.EqualTo(2)); }
public void IndexUpdateWhenObjectIsBeingRemoved(IServiceProvider serviceProvider, ObjectRepository repository, IObjectRepositoryContainer <ObjectRepository> container, Signature signature, string message, string name) { // Arrange repository = repository.With(c => c .Add(repository, r => r.Indexes, new Index(serviceProvider, UniqueId.CreateNew(), name, nameof(IModelObject.Name)))); repository = container.AddRepository(repository, signature, message); ComputeKeysCalls.Clear(); // Act var modified = repository.With(c => c.Remove(repository.Applications[0], app => app.Pages, repository.Applications[0].Pages[0])); container.Commit(modified.Repository, signature, message); // Assert var nestedCount = repository.Applications[0].Pages[0].Flatten().Count(); Assert.That(ComputeKeysCalls, Has.Count.EqualTo(nestedCount)); }
public void PushExistingRemote(ObjectRepository sample, IObjectRepositoryContainer <ObjectRepository> container, Signature signature, string message) { // Arrange var(tempPath, repository) = PushNewRemoteImpl(sample, container, signature, message); var change = repository.With(repository.Applications[0].Pages[0], p => p.Description, "bar"); repository = container.Commit(change.Repository, signature, message); // Act container.Push(repository.Id); // Assert using (var repo = new Repository(tempPath)) { var lastCommit = repo.Branches["master"].Tip; Assert.That(lastCommit.Id, Is.EqualTo(repository.CommitId)); } }
public void ResolveDiffsPageNameUpdate(ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, Signature signature, string message, ComputeTreeChangesFactory computeTreeChangesFactory) { // Arrange sut = container.AddRepository(sut, signature, message); var modifiedPage = sut.With(sut.Applications[0].Pages[0], p => p.Name, "modified"); var commit = container.Commit(modifiedPage.Repository, signature, message); // Act var changes = computeTreeChangesFactory(container, sut.RepositoryDescription) .Compare(sut.CommitId, commit.CommitId) .SkipIndexChanges(); // Assert Assert.That(changes, Has.Count.EqualTo(1)); Assert.That(changes[0].Status, Is.EqualTo(ChangeKind.Modified)); Assert.That(changes[0].Old.Name, Is.EqualTo(sut.Applications[0].Pages[0].Name)); Assert.That(changes[0].New.Name, Is.EqualTo(modifiedPage.Name)); }
public void ResolveDiffsBlobUpdate(BlobRepository sut, IObjectRepositoryContainer <BlobRepository> container, Signature signature, string message, ComputeTreeChangesFactory computeTreeChangesFactory) { // Arrange sut = container.AddRepository(sut, signature, message); var modified = sut.With(sut, r => r.Blob, new StringBlob("z\nb\nz")); var commit = container.Commit(modified.Repository, signature, message); // Act var changes = computeTreeChangesFactory(container, sut.RepositoryDescription) .Compare(sut.CommitId, commit.CommitId) .SkipIndexChanges(); // Assert Assert.That(changes, Has.Count.EqualTo(1)); Assert.That(changes[0].Status, Is.EqualTo(ChangeKind.Modified)); Assert.That(((BlobRepository)changes[0].Old).Blob, Is.EqualTo(sut.Blob)); Assert.That(((BlobRepository)changes[0].New).Blob, Is.EqualTo(modified.Blob)); }
public void ResolveDiffsFieldAddition(ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, IServiceProvider serviceProvider, Signature signature, string message, ComputeTreeChangesFactory computeTreeChangesFactory) { // Arrange sut = container.AddRepository(sut, signature, message); var field = new Field(serviceProvider, UniqueId.CreateNew(), "foo", FieldContent.Default); var modifiedPage = sut.With(c => c.Add(sut.Applications[0].Pages[0], p => p.Fields, field)); var commit = container.Commit(modifiedPage, signature, message); // Act var changes = computeTreeChangesFactory(container, sut.RepositoryDescription) .Compare(sut.CommitId, commit.CommitId) .SkipIndexChanges(); // Assert Assert.That(changes, Has.Count.EqualTo(1)); Assert.That(changes[0].Status, Is.EqualTo(ChangeKind.Added)); Assert.That(changes[0].Old, Is.Null); Assert.That(changes[0].New.Name, Is.EqualTo(field.Name)); }
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)); }
public void ResolveDiffsFieldDeletion(ObjectRepository sut, IObjectRepositoryContainer <ObjectRepository> container, Signature signature, string message, ComputeTreeChangesFactory computeTreeChangesFactory) { // Arrange sut = container.AddRepository(sut, signature, message); var page = sut.Applications[0].Pages[0]; var field = page.Fields[5]; var modifiedPage = sut.With(c => c.Remove(page, p => p.Fields, field)); var commit = container.Commit(modifiedPage, signature, message); // Act var changes = computeTreeChangesFactory(container, sut.RepositoryDescription) .Compare(sut.CommitId, commit.CommitId) .SkipIndexChanges(); // Assert Assert.That(changes, Has.Count.EqualTo(1)); Assert.That(changes[0].Status, Is.EqualTo(ChangeKind.Deleted)); Assert.That(changes[0].New, Is.Null); Assert.That(changes[0].Old.Name, Is.EqualTo(field.Name)); }