Exemple #1
0
        public void SutIsSpecimenBuilder()
        {
            // Arrange
            // Act
            var sut = new EnumerableRelay();

            // Assert
            Assert.IsAssignableFrom <ISpecimenBuilder>(sut);
        }
 public void SutIsSpecimenBuilder()
 {
     // Fixture setup
     // Exercise system
     var sut = new EnumerableRelay();
     // Verify outcome
     Assert.IsAssignableFrom<ISpecimenBuilder>(sut);
     // Teardown
 }
 public void CreateWithNullContextThrows()
 {
     // Fixture setup
     var sut = new EnumerableRelay();
     var dummyRequest = new object();
     // Exercise system and verify outcome
     Assert.Throws<ArgumentNullException>(() =>
         sut.Create(dummyRequest, null));
     // Teardown
 }
Exemple #4
0
        public void CreateWithNullContextThrows()
        {
            // Arrange
            var sut          = new EnumerableRelay();
            var dummyRequest = new object();

            // Act & assert
            Assert.Throws <ArgumentNullException>(() =>
                                                  sut.Create(dummyRequest, null));
        }
        public void SutIsSpecimenBuilder()
        {
            // Fixture setup
            // Exercise system
            var sut = new EnumerableRelay();

            // Verify outcome
            Assert.IsAssignableFrom <ISpecimenBuilder>(sut);
            // Teardown
        }
        public void CreateWithNullContextThrows()
        {
            // Fixture setup
            var sut          = new EnumerableRelay();
            var dummyRequest = new object();

            // Exercise system and verify outcome
            Assert.Throws <ArgumentNullException>(() =>
                                                  sut.Create(dummyRequest, null));
            // Teardown
        }
 public void CreateWithNoneEnumerableRequestReturnsCorrectResult(object request)
 {
     // Fixture setup
     var sut = new EnumerableRelay();
     // Exercise system
     var dummyContext = new DelegatingSpecimenContext { OnResolve = r => Enumerable.Empty<object>() };
     var result = sut.Create(request, dummyContext);
     // Verify outcome
     var expectedResult = new NoSpecimen(request);
     Assert.Equal(expectedResult, result);
     // Teardown
 }
        public void CreateWithEnumerableRequestReturnsCorrectResult(Type request, Type itemType)
        {
            // Fixture setup
            var expectedRequest = new MultipleRequest(itemType);
            object contextResult = Enumerable.Empty<object>();
            var context = new DelegatingSpecimenContext { OnResolve = r => expectedRequest.Equals(r) ? contextResult : new NoSpecimen(r) };

            var sut = new EnumerableRelay();
            // Exercise system
            var result = sut.Create(request, context);
            // Verify outcome
            Assert.NotNull(result);
            // Teardown
        }
Exemple #9
0
        public void CreateWithNoneEnumerableRequestReturnsCorrectResult(object request)
        {
            // Arrange
            var sut = new EnumerableRelay();
            // Act
            var dummyContext = new DelegatingSpecimenContext {
                OnResolve = r => Enumerable.Empty <object>()
            };
            var result = sut.Create(request, dummyContext);
            // Assert
            var expectedResult = new NoSpecimen();

            Assert.Equal(expectedResult, result);
        }
        public void CreateWithNoneEnumerableRequestReturnsCorrectResult(object request)
        {
            // Fixture setup
            var sut = new EnumerableRelay();
            // Exercise system
            var dummyContext = new DelegatingSpecimenContext {
                OnResolve = r => Enumerable.Empty <object>()
            };
            var result = sut.Create(request, dummyContext);
            // Verify outcome
            var expectedResult = new NoSpecimen();

            Assert.Equal(expectedResult, result);
            // Teardown
        }
Exemple #11
0
        public void CreateReturnsCorrectResultWhenContextReturnsNonEnumerableResult(object response)
        {
            // Arrange
            var request = typeof(IEnumerable <object>);
            var context = new DelegatingSpecimenContext {
                OnResolve = r => response
            };
            var sut = new EnumerableRelay();
            // Act
            var result = sut.Create(request, context);
            // Assert
            var expectedResult = new NoSpecimen();

            Assert.Equal(expectedResult, result);
        }
        public void CreateReturnsCorrectResultWhenContextReturnsNonEnumerableResult(object response)
        {
            // Fixture setup
            var request = typeof(IEnumerable <object>);
            var context = new DelegatingSpecimenContext {
                OnResolve = r => response
            };
            var sut = new EnumerableRelay();
            // Exercise system
            var result = sut.Create(request, context);
            // Verify outcome
            var expectedResult = new NoSpecimen();

            Assert.Equal(expectedResult, result);
            // Teardown
        }
Exemple #13
0
        public void CreateWithEnumerableRequestReturnsCorrectResult(Type request, Type itemType)
        {
            // Arrange
            var    expectedRequest = new MultipleRequest(itemType);
            object contextResult   = Enumerable.Empty <object>();
            var    context         = new DelegatingSpecimenContext {
                OnResolve = r => expectedRequest.Equals(r) ? contextResult : new NoSpecimen()
            };

            var sut = new EnumerableRelay();
            // Act
            var result = sut.Create(request, context);

            // Assert
            Assert.NotNull(result);
        }
        public void CreateWithEnumerableRequestReturnsCorrectResult(Type request, Type itemType)
        {
            // Fixture setup
            var    expectedRequest = new MultipleRequest(itemType);
            object contextResult   = Enumerable.Empty <object>();
            var    context         = new DelegatingSpecimenContext {
                OnResolve = r => expectedRequest.Equals(r) ? contextResult : new NoSpecimen()
            };

            var sut = new EnumerableRelay();
            // Exercise system
            var result = sut.Create(request, context);

            // Verify outcome
            Assert.NotNull(result);
            // Teardown
        }
Exemple #15
0
        public void CreateConvertsEnumerableToCorrectGenericType()
        {
            // Arrange
            var request         = typeof(IEnumerable <int>);
            var expectedRequest = new MultipleRequest(typeof(int));
            var enumerable      = Enumerable.Range(1, 3).Cast <object>();
            var context         = new DelegatingSpecimenContext {
                OnResolve = r => expectedRequest.Equals(r) ? (object)enumerable : new NoSpecimen()
            };

            var sut = new EnumerableRelay();
            // Act
            var result = sut.Create(request, context);
            // Assert
            var e = Assert.IsAssignableFrom <IEnumerable <int> >(result);

            Assert.True(enumerable.Cast <int>().SequenceEqual(e));
        }
        public void CreateConvertsEnumerableToCorrectGenericType()
        {
            // Fixture setup
            var request         = typeof(IEnumerable <int>);
            var expectedRequest = new MultipleRequest(typeof(int));
            var enumerable      = Enumerable.Range(1, 3).Cast <object>();

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

            var sut = new EnumerableRelay();
            // Exercise system
            var result = sut.Create(request, context);
            // Verify outcome
            var e = Assert.IsAssignableFrom <IEnumerable <int> >(result);
            Assert.True(enumerable.Cast <int>().SequenceEqual(e));
            // Teardown
        }
        public void CreateFiltersOmitSpecimenInstances()
        {
            // Fixture setup
            var request = typeof(IEnumerable<int>);
            var expectedRequest = new MultipleRequest(typeof(int));

            var enumerable = new object[]
            {
                1,
                new OmitSpecimen(),
                3
            };
            var context = new DelegatingSpecimenContext
            {
                OnResolve = r => expectedRequest.Equals(r) ? (object)enumerable : new NoSpecimen(r)
            };

            var sut = new EnumerableRelay();
            // Exercise system
            var actual = sut.Create(request, context);
            // Verify outcome
            var iter = Assert.IsAssignableFrom<IEnumerable<int>>(actual);
            Assert.True(
                enumerable.OfType<int>().SequenceEqual(iter),
                "Actual sequence is not equal to expected sequence.");
            // Teardown
        }
 public void CreateReturnsCorrectResultWhenContextReturnsNonEnumerableResult(object response)
 {
     // Fixture setup
     var request = typeof(IEnumerable<object>);
     var context = new DelegatingSpecimenContext { OnResolve = r => response };
     var sut = new EnumerableRelay();
     // Exercise system
     var result = sut.Create(request, context);
     // Verify outcome
     var expectedResult = new NoSpecimen(request);
     Assert.Equal(expectedResult, result);
     // Teardown
 }
        public void CreateConvertsEnumerableToCorrectGenericType()
        {
            // Fixture setup
            var request = typeof(IEnumerable<int>);
            var expectedRequest = new MultipleRequest(typeof(int));
            var enumerable = Enumerable.Range(1, 3).Cast<object>();
            var context = new DelegatingSpecimenContext { OnResolve = r => expectedRequest.Equals(r) ? (object)enumerable : new NoSpecimen(r) };

            var sut = new EnumerableRelay();
            // Exercise system
            var result = sut.Create(request, context);
            // Verify outcome
            var e = Assert.IsAssignableFrom<IEnumerable<int>>(result);
            Assert.True(enumerable.Cast<int>().SequenceEqual(e));
            // Teardown
        }