Exemplo n.º 1
0
 public void SutIsSpecimenBuilder()
 {
     // Fixture setup
     // Exercise system
     var sut = new CollectionRelay();
     // Verify outcome
     Assert.IsAssignableFrom<ISpecimenBuilder>(sut);
     // Teardown
 }
Exemplo n.º 2
0
 public void CreateWithNullContextThrows()
 {
     // Fixture setup
     var sut = new CollectionRelay();
     var dummyRequest = new object();
     // Exercise system and verify outcome
     Assert.Throws<ArgumentNullException>(() =>
         sut.Create(dummyRequest, null));
     // Teardown
 }
Exemplo n.º 3
0
        public void CreateWithNonCollectionRequestReturnsCorrectResult(object request)
        {
            // Fixture setup
            var sut = new CollectionRelay();
            // 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
        }
Exemplo n.º 4
0
        public void CreateWithListRequestReturnsCorrectResult(Type request, Type itemType)
        {
            // Fixture setup
            var expectedRequest = typeof(List<>).MakeGenericType(itemType);
            object contextResult = typeof(List<>).MakeGenericType(itemType).GetConstructor(Type.EmptyTypes).Invoke(new object[0]);
#pragma warning disable 618
            var context = new DelegatingSpecimenContext { OnResolve = r => expectedRequest.Equals(r) ? contextResult : new NoSpecimen(r) };
#pragma warning restore 618

            var sut = new CollectionRelay();
            // Exercise system
            var result = sut.Create(request, context);
            // Verify outcome
            Assert.Equal(contextResult, result);
            // Teardown
        }