Exemplo n.º 1
0
        public void LazyChildrenThrowsErrorIfLambdaReturnsNull(IMetadataObject parent)
        {
            // Act
            var sut = new LazyChildren <IMetadataObject>(_ => null);

            sut.AttachToParent(parent);

            // Assert
            Assert.Throws <NotSupportedException>(() => sut.GetEnumerator());
        }
Exemplo n.º 2
0
        public void LazyChildrenForceVisitIsFalseByDefault(IList <IMetadataObject> values, IMetadataObject parent)
        {
            // Act
            var sut = new LazyChildren <IMetadataObject>(values.ToImmutableList());

            sut.AttachToParent(parent);

            // Assert
            Assert.That(sut.ForceVisit, Is.False);
        }
Exemplo n.º 3
0
        public void LazyChildrenThrowsErrorWhenDeleteGetsCalledDirectly(IList <IMetadataObject> values, IMetadataObject parent)
        {
            // Act
            var sut = new LazyChildren <IMetadataObject>(values.ToImmutableList());

            sut.AttachToParent(parent);

            // Assert
            Assert.Throws <NotSupportedException>(() => sut.Delete(values[0]));
        }
Exemplo n.º 4
0
        public void LazyChildrenCloneDoesNotContainDeletedValues(IList <IMetadataObject> values, IMetadataObject parent)
        {
            // Act
            var sut = new LazyChildren <IMetadataObject>(values.ToImmutableList());

            sut.AttachToParent(parent);
            var clone = (LazyChildren <IMetadataObject>)sut.Clone(true, o => o, deleted: new[] { values[0] });

            // Assert
            clone.AttachToParent(parent);
            Assert.That(clone.Count, Is.EqualTo(values.Count - 1));
            Assert.That(clone, Does.Not.Contain(values[0]));
        }
Exemplo n.º 5
0
        public void LazyChildrenCloneContainsAddedValues(IList <IMetadataObject> values, IMetadataObject parent, IMetadataObject added)
        {
            // Act
            var sut = new LazyChildren <IMetadataObject>(values.ToImmutableList());

            sut.AttachToParent(parent);
            var clone = (LazyChildren <IMetadataObject>)sut.Clone(true, o => o, added: new[] { added });

            // Assert
            clone.AttachToParent(parent);
            Assert.That(clone.Count, Is.EqualTo(values.Count + 1));
            Assert.That(clone, Does.Contain(added));
        }
Exemplo n.º 6
0
        public void LazyChildrenReturnUnchangedEntryChildrenIfProvided(IList <IMetadataObject> values, IMetadataObject parent)
        {
            // Act
            var sut = new LazyChildren <IMetadataObject>(values.ToImmutableList());

            sut.AttachToParent(parent);

            // Assert
            Assert.That(sut.Parent, Is.SameAs(parent));
            Assert.That(sut.AreChildrenLoaded, Is.True);
            Assert.That(sut.Count, Is.EqualTo(values.Count));
            Assert.That(sut, Is.EquivalentTo(values));
            Assert.That(sut.ForceVisit, Is.False);
        }
Exemplo n.º 7
0
        public void LazyChildrenCloneCallsUpdateLambda(IFixture fixture, IList <IMetadataObject> values, IMetadataObject parent)
        {
            // Act
            var sut = new LazyChildren <IMetadataObject>(values.ToImmutableList());

            sut.AttachToParent(parent);
            var newValues = new List <IMetadataObject>();
            var clone     = (LazyChildren <IMetadataObject>)sut.Clone(true, _ =>
            {
                var o = fixture.Create <IMetadataObject>();
                newValues.Add(o);
                return(o);
            });

            // Assert
            Assert.That(clone.Parent, Is.Null);
            Assert.That(clone.ForceVisit, Is.True);
            clone.AttachToParent(parent);
            Assert.That(clone.Count, Is.EqualTo(values.Count));
            Assert.That(clone, Is.EquivalentTo(newValues));
        }