public void SutIsSpecimenBuilder()
 {
     // Fixture setup
     // Exercise system
     var sut = new StableFiniteSequenceRelay();
     // Verify outcome
     Assert.IsAssignableFrom<ISpecimenBuilder>(sut);
     // Teardown
 }
 public void CreateWithNullContextThrows()
 {
     // Fixture setup
     var sut = new StableFiniteSequenceRelay();
     var dummyRequest = new object();
     // Exercise system and verify outcome
     Assert.Throws<ArgumentNullException>(() =>
         sut.Create(dummyRequest, null));
     // Teardown
 }
 public void CreateWithInvalidRequestReturnsCorrectResult(object request)
 {
     // Fixture setup
     var sut = new StableFiniteSequenceRelay();
     // Exercise system
     var dummyContext = new DelegatingSpecimenContext();
     var result = sut.Create(request, dummyContext);
     // Verify outcome
     var expectedResult = new NoSpecimen(request);
     Assert.Equal(expectedResult, result);
     // Teardown
 }
        public void CreateWithAnonymousRequestReturnsCorrectResult()
        {
            // Fixture setup
            var sut = new StableFiniteSequenceRelay();
            var request = new object();
            // Exercise system
            var dummyContext = new DelegatingSpecimenContext();
            var result = sut.Create(request, dummyContext);
            // Verify outcome
#pragma warning disable 618
            var expectedResult = new NoSpecimen(request);
#pragma warning restore 618
            Assert.Equal(expectedResult, result);
            // Teardown
        }
        public void CreateWithFiniteSequenceRequestReturnsCorrectResult()
        {
            // Fixture setup
            var request = new object();
            var count = 3;
            var manyRequest = new FiniteSequenceRequest(request, count);

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

            var sut = new StableFiniteSequenceRelay();
            // Exercise system
            var result = sut.Create(manyRequest, context);
            // Verify outcome
            var actual = Assert.IsAssignableFrom<IEnumerable<object>>(result);
            Assert.True(actual.All(expectedResult.Equals));
            // Teardown
        }
        public void CreateReturnsStableSequence()
        {
            // Fixture setup
            var request = new object();
            var count = 3;
            var manyRequest = new FiniteSequenceRequest(request, count);

#pragma warning disable 618
            var context = new DelegatingSpecimenContext { OnResolve = r => request.Equals(r) ? new object() : new NoSpecimen(r) };
#pragma warning restore 618

            var sut = new StableFiniteSequenceRelay();
            // Exercise system
            var result = sut.Create(manyRequest, context);
            // Verify outcome
            var expected = Assert.IsAssignableFrom<IEnumerable<object>>(result);
            Assert.True(expected.SequenceEqual(expected));
            // Teardown
        }
        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
            {
#pragma warning disable 618
                OnResolve = r => request.Equals(r) ? q.Dequeue() : new NoSpecimen(r)
#pragma warning restore 618
            };

            var sut = new StableFiniteSequenceRelay();
            // 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),
                "Actual sequence is not equal to expected sequence.");
            // Teardown
        }
 public void Customize(IFixture fixture)
 {
     var stableRelay = 
         new StableFiniteSequenceRelay();
     fixture.Customizations.Add(stableRelay);
 }
        public void ManyIsStableWithCustomization()
        {
            var fixture = new Fixture();
            var stableRelay = new StableFiniteSequenceRelay();
            fixture.Customizations.Add(stableRelay);

            var expected =
                fixture.CreateMany<string>();
            Assert.True(expected.SequenceEqual(expected));
        }