예제 #1
0
        public void CreateWithNullContextThrows()
        {
            // Arrange
            var sut          = new ArrayRelay();
            var dummyRequest = new object();

            // Act & assert
            Assert.Throws <ArgumentNullException>(() =>
                                                  sut.Create(dummyRequest, null));
        }
예제 #2
0
        public void CreateWithNullContextThrows()
        {
            // Fixture setup
            var sut          = new ArrayRelay();
            var dummyRequest = new object();

            // Exercise system and verify outcome
            Assert.Throws <ArgumentNullException>(() =>
                                                  sut.Create(dummyRequest, null));
            // Teardown
        }
예제 #3
0
        public void CreateWithNoneArrayRequestReturnsCorrectResult(object request)
        {
            // Arrange
            var sut = new ArrayRelay();
            // Act
            var dummyContext = new DelegatingSpecimenContext();
            var result       = sut.Create(request, dummyContext);
            // Assert
            var expectedResult = new NoSpecimen();

            Assert.Equal(expectedResult, result);
        }
예제 #4
0
        public void CreateWithNoneArrayRequestReturnsCorrectResult(object request)
        {
            // Fixture setup
            var sut = new ArrayRelay();
            // Exercise system
            var dummyContext = new DelegatingSpecimenContext();
            var result       = sut.Create(request, dummyContext);
            // Verify outcome
            var expectedResult = new NoSpecimen();

            Assert.Equal(expectedResult, result);
            // Teardown
        }
예제 #5
0
        public void CreateReturnsCorrectResultWhenContextReturnsNonEnumerableResult(object response)
        {
            // Arrange
            var request = typeof(object[]);
            var context = new DelegatingSpecimenContext {
                OnResolve = r => response
            };
            var sut = new ArrayRelay();
            // Act
            var result = sut.Create(request, context);
            // Assert
            var expectedResult = new NoSpecimen();

            Assert.Equal(expectedResult, result);
        }
예제 #6
0
        public void CreateWithArrayRequestReturnsCorrectResult(Type request, Type itemType)
        {
            // Arrange
            var    expectedRequest = new MultipleRequest(itemType);
            object expectedResult  = Array.CreateInstance(itemType, 0);
            var    context         = new DelegatingSpecimenContext {
                OnResolve = r => expectedRequest.Equals(r) ? expectedResult : new NoSpecimen()
            };

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

            // Assert
            Assert.Equal(expectedResult, result);
        }
예제 #7
0
        public void CreateReturnsCorrectResultWhenContextReturnsNonEnumerableResult(object response)
        {
            // Fixture setup
            var request = typeof(object[]);
            var context = new DelegatingSpecimenContext {
                OnResolve = r => response
            };
            var sut = new ArrayRelay();
            // Exercise system
            var result = sut.Create(request, context);
            // Verify outcome
            var expectedResult = new NoSpecimen();

            Assert.Equal(expectedResult, result);
            // Teardown
        }
예제 #8
0
        public void CreateWithArrayRequestReturnsCorrectResult(Type request, Type itemType)
        {
            // Fixture setup
            var    expectedRequest = new MultipleRequest(itemType);
            object expectedResult  = Array.CreateInstance(itemType, 0);
            var    context         = new DelegatingSpecimenContext {
                OnResolve = r => expectedRequest.Equals(r) ? expectedResult : new NoSpecimen()
            };

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

            // Verify outcome
            Assert.Equal(expectedResult, result);
            // Teardown
        }
예제 #9
0
        public void CreateConvertsEnumerableToArray()
        {
            // Arrange
            var request         = typeof(int[]);
            var expectedRequest = new MultipleRequest(typeof(int));
            var enumerable      = Enumerable.Range(1, 3);
            var context         = new DelegatingSpecimenContext {
                OnResolve = r => expectedRequest.Equals(r) ? (object)enumerable : new NoSpecimen()
            };

            var sut = new ArrayRelay();
            // Act
            var result = sut.Create(request, context);
            // Assert
            var a = Assert.IsAssignableFrom <int[]>(result);

            Assert.True(enumerable.SequenceEqual(a));
        }
예제 #10
0
        public void CreateConvertsEnumerableToArray()
        {
            // Fixture setup
            var request         = typeof(int[]);
            var expectedRequest = new MultipleRequest(typeof(int));
            var enumerable      = Enumerable.Range(1, 3);

#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 ArrayRelay();
            // Exercise system
            var result = sut.Create(request, context);
            // Verify outcome
            var a = Assert.IsAssignableFrom <int[]>(result);
            Assert.True(enumerable.SequenceEqual(a));
            // Teardown
        }