Esempio n. 1
0
        public void CreateWithNullContextThrows()
        {
            var sut          = new EnumeratorRelay();
            var dummyRequest = new object();

            Assert.Throws <ArgumentNullException>(() =>
                                                  sut.Create(dummyRequest, null));
        }
Esempio n. 2
0
        public void CreateWithNoEnumeratorRequestReturnsCorrectResult(
            object request)
        {
            var sut          = new EnumeratorRelay();
            var dummyContext = new DelegatingSpecimenContext();

            var result = sut.Create(request, dummyContext);

            var expectedResult = new NoSpecimen(request);

            Assert.Equal(expectedResult, result);
        }
Esempio n. 3
0
        public void CreateReturnsCorrectResultWhenContextReturnsNonEnumerableResult(
            object response)
        {
            var request = typeof(IEnumerator <object>);
            var context = new DelegatingSpecimenContext
            {
                OnResolve = r => response
            };
            var sut = new EnumeratorRelay();

            var result = sut.Create(request, context);

            var expectedResult = new NoSpecimen(request);

            Assert.Equal(expectedResult, result);
        }
Esempio n. 4
0
        public void CreateWithEnumeratorRequestReturnsCorrectResult(
            Type request,
            Type itemType)
        {
            var expectedRequest =
                typeof(IEnumerable <>).MakeGenericType(itemType);
            var enumerable = (IList)Activator.CreateInstance(
                typeof(List <>).MakeGenericType(itemType));
            var context = new DelegatingSpecimenContext
            {
                OnResolve = r => expectedRequest.Equals(r)
                    ? (object)enumerable
                    : new NoSpecimen(r)
            };
            var sut = new EnumeratorRelay();

            var result = sut.Create(request, context);

            var expectedResult = enumerable.GetEnumerator();

            Assert.Equal(expectedResult, result);
        }