public void CreateFiltersOmitSpecimenInstances()
        {
            // Fixture setup
            var request     = new object();
            var count       = 3;
            var manyRequest = new FiniteSequenceRequest(request, count);

            var results = new object[]
            {
                new object(),
                new OmitSpecimen(),
                new object()
            };
            var q       = new Queue <object>(results);
            var context = new DelegatingSpecimenContext
            {
                OnResolve = r => request.Equals(r) ? q.Dequeue() : new NoSpecimen(r)
            };

            var sut = new FiniteSequenceRelay();
            // Exercise system
            var actual = sut.Create(manyRequest, context);
            // Verify outcome
            var iter = Assert.IsAssignableFrom <IEnumerable <object> >(actual);

            Assert.True(
                results.Where(x => !(x is OmitSpecimen)).SequenceEqual(iter));
            // Teardown
        }
Exemplo n.º 2
0
        public void SutIsSpecimenBuilder()
        {
            // Arrange
            // Act
            var sut = new FiniteSequenceRelay();

            // Assert
            Assert.IsAssignableFrom <ISpecimenBuilder>(sut);
        }
        public void SutIsSpecimenBuilder()
        {
            // Fixture setup
            // Exercise system
            var sut = new FiniteSequenceRelay();

            // Verify outcome
            Assert.IsAssignableFrom <ISpecimenBuilder>(sut);
            // Teardown
        }
Exemplo n.º 4
0
        public void CreateWithNullContainerThrows()
        {
            // Arrange
            var sut          = new FiniteSequenceRelay();
            var dummyRequest = new object();

            // Act & assert
            Assert.Throws <ArgumentNullException>(() =>
                                                  sut.Create(dummyRequest, null));
        }
        public void CreateWithNullContainerThrows()
        {
            // Fixture setup
            var sut          = new FiniteSequenceRelay();
            var dummyRequest = new object();

            // Exercise system and verify outcome
            Assert.Throws <ArgumentNullException>(() =>
                                                  sut.Create(dummyRequest, null));
            // Teardown
        }
Exemplo n.º 6
0
        public void CreateWithInvalidRequestReturnsCorrectResult(object request)
        {
            // Arrange
            var sut = new FiniteSequenceRelay();
            // Act
            var dummyContainer = new DelegatingSpecimenContext();
            var result         = sut.Create(request, dummyContainer);
            // Assert
            var expectedResult = new NoSpecimen();

            Assert.Equal(expectedResult, result);
        }
        public void CreateWithInvalidRequestReturnsCorrectResult(object request)
        {
            // Fixture setup
            var sut = new FiniteSequenceRelay();
            // Exercise system
            var dummyContainer = new DelegatingSpecimenContext();
            var result         = sut.Create(request, dummyContainer);
            // Verify outcome
            var expectedResult = new NoSpecimen(request);

            Assert.Equal(expectedResult, result);
            // Teardown
        }
Exemplo n.º 8
0
        public void CreateWithAnonymousRequestReturnsCorrectResult()
        {
            // Fixture setup
            var sut     = new FiniteSequenceRelay();
            var request = new object();
            // Exercise system
            var dummyContainer = new DelegatingSpecimenContext();
            var result         = sut.Create(request, dummyContainer);

            // Verify outcome
#pragma warning disable 618
            var expectedResult = new NoSpecimen(request);
#pragma warning restore 618
            Assert.Equal(expectedResult, result);
            // Teardown
        }
Exemplo n.º 9
0
        public void CreateWithFiniteSequenceRequestReturnsCorrectResult()
        {
            // Arrange
            var request     = new object();
            var count       = 3;
            var manyRequest = new FiniteSequenceRequest(request, count);

            var expectedResult = new object();
            var container      = new DelegatingSpecimenContext {
                OnResolve = r => request.Equals(r) ? expectedResult : new NoSpecimen()
            };

            var sut = new FiniteSequenceRelay();
            // Act
            var result = sut.Create(manyRequest, container);
            // Assert
            var actual = Assert.IsAssignableFrom <IEnumerable <object> >(result);

            Assert.True(actual.All(expectedResult.Equals));
        }