Beispiel #1
0
        public void SutIsRecursionGuard()
        {
            // Arrange
            // Act
            var sut = new NullRecursionGuard(new DelegatingSpecimenBuilder());

            // Assert
            Assert.IsAssignableFrom <RecursionGuard>(sut);
        }
        public void SutIsRecursionGuard()
        {
            // Fixture setup
            // Exercise system
            var sut = new NullRecursionGuard(new DelegatingSpecimenBuilder());

            // Verify outcome
            Assert.IsAssignableFrom <RecursionGuard>(sut);
            // Teardown
        }
Beispiel #3
0
        public void ComposeRetainsComparer()
        {
            // Arrange
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var expected     = new DelegatingEqualityComparer();
            var sut          = new NullRecursionGuard(dummyBuilder, expected);
            // Act
            var actual = sut.Compose(new ISpecimenBuilder[0]);
            // Assert
            var rg = Assert.IsAssignableFrom <NullRecursionGuard>(actual);

            Assert.Equal(expected, rg.Comparer);
        }
Beispiel #4
0
        public void ComposeSingleItemReturnsCorrectResult()
        {
            // Arrange
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var sut          = new NullRecursionGuard(dummyBuilder);
            // Act
            var expected = new DelegatingSpecimenBuilder();
            var actual   = sut.Compose(new[] { expected });
            // Assert
            var rg = Assert.IsAssignableFrom <NullRecursionGuard>(actual);

            Assert.Equal(expected, rg.Builder);
        }
        public void ComposeRetainsComparer()
        {
            // Fixture setup
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var expected     = new DelegatingEqualityComparer();
            var sut          = new NullRecursionGuard(dummyBuilder, expected);
            // Exercise system
            var actual = sut.Compose(new ISpecimenBuilder[0]);
            // Verify outcome
            var rg = Assert.IsAssignableFrom <NullRecursionGuard>(actual);

            Assert.Equal(expected, rg.Comparer);
            // Teardown
        }
        public void ComposeSingleItemReturnsCorrectResult()
        {
            // Fixture setup
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var sut          = new NullRecursionGuard(dummyBuilder);
            // Exercise system
            var expected = new DelegatingSpecimenBuilder();
            var actual   = sut.Compose(new[] { expected });
            // Verify outcome
            var rg = Assert.IsAssignableFrom <NullRecursionGuard>(actual);

            Assert.Equal(expected, rg.Builder);
            // Teardown
        }
Beispiel #7
0
        public void ReturnsNullAtRecursionPoint()
        {
            // Arrange
            var builder = new DelegatingSpecimenBuilder();

            builder.OnCreate = (r, c) => c.Resolve(r);
            var sut       = new NullRecursionGuard(builder);
            var container = new DelegatingSpecimenContext();

            container.OnResolve = r => sut.Create(r, container); // Provoke recursion

            // Act
            object res = sut.Create(Guid.NewGuid(), container);

            Assert.Null(res);
        }
Beispiel #8
0
        public void ComposeReturnsCorrectResult()
        {
            // Arrange
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var sut          = new NullRecursionGuard(dummyBuilder);
            // Act
            var expectedBuilders = new[]
            {
                new DelegatingSpecimenBuilder(),
                new DelegatingSpecimenBuilder(),
                new DelegatingSpecimenBuilder()
            };
            var actual = sut.Compose(expectedBuilders);
            // Assert
            var rg        = Assert.IsAssignableFrom <NullRecursionGuard>(actual);
            var composite = Assert.IsAssignableFrom <CompositeSpecimenBuilder>(rg.Builder);

            Assert.True(expectedBuilders.SequenceEqual(composite));
        }
        public void ComposeReturnsCorrectResult()
        {
            // Fixture setup
            var dummyBuilder = new DelegatingSpecimenBuilder();
            var sut          = new NullRecursionGuard(dummyBuilder);
            // Exercise system
            var expectedBuilders = new[]
            {
                new DelegatingSpecimenBuilder(),
                new DelegatingSpecimenBuilder(),
                new DelegatingSpecimenBuilder()
            };
            var actual = sut.Compose(expectedBuilders);
            // Verify outcome
            var rg        = Assert.IsAssignableFrom <NullRecursionGuard>(actual);
            var composite = Assert.IsAssignableFrom <CompositeSpecimenBuilder>(rg.Builder);

            Assert.True(expectedBuilders.SequenceEqual(composite));
            // Teardown
        }