コード例 #1
0
        public void CreateWithNullContextThrows()
        {
            // Arrange
            var sut          = new DictionaryRelay();
            var dummyRequest = new object();

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

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

            Assert.Equal(expectedResult, result);
        }
コード例 #4
0
        public void CreateWithNonDictionaryRequestReturnsCorrectResult(object request)
        {
            // Fixture setup
            var sut = new DictionaryRelay();
            // Exercise system
            var dummyContext = new DelegatingSpecimenContext();
            var result       = sut.Create(request, dummyContext);
            // Verify outcome
            var expectedResult = new NoSpecimen(request);

            Assert.Equal(expectedResult, result);
            // Teardown
        }
コード例 #5
0
        public void CreateWithListRequestReturnsCorrectResult(Type request, Type keyType, Type itemType)
        {
            // Arrange
            var    expectedRequest = typeof(Dictionary <,>).MakeGenericType(keyType, itemType);
            object contextResult   = typeof(Dictionary <,>).MakeGenericType(keyType, itemType).GetTypeInfo().GetConstructor(Type.EmptyTypes).Invoke(new object[0]);
            var    context         = new DelegatingSpecimenContext {
                OnResolve = r => expectedRequest.Equals(r) ? contextResult : new NoSpecimen()
            };

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

            // Assert
            Assert.Equal(contextResult, result);
        }
コード例 #6
0
        public void CreateWithListRequestReturnsCorrectResult(Type request, Type keyType, Type itemType)
        {
            // Fixture setup
            var    expectedRequest = typeof(Dictionary <,>).MakeGenericType(keyType, itemType);
            object contextResult   = typeof(Dictionary <,>).MakeGenericType(keyType, itemType).GetConstructor(Type.EmptyTypes).Invoke(new object[0]);
            var    context         = new DelegatingSpecimenContext {
                OnResolve = r => expectedRequest.Equals(r) ? contextResult : new NoSpecimen(r)
            };

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

            // Verify outcome
            Assert.Equal(contextResult, result);
            // Teardown
        }