示例#1
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
 }
示例#2
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(request);
     Assert.Equal(expectedResult, result);
     // Teardown
 }
示例#3
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(r) };

            var sut = new ArrayRelay();
            // Exercise system
            var result = sut.Create(request, context);
            // Verify outcome
            Assert.Equal(expectedResult, result);
            // Teardown
        }
示例#4
0
        public void CreateConvertsEnumerableToArray()
        {
            // Fixture setup
            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(r) };

            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
        }
示例#5
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(request);
     Assert.Equal(expectedResult, result);
     // Teardown
 }