Exemplo n.º 1
0
        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
        }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        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));
        }