public void CreateWithNullContextThrows()
        {
            // Arrange
            var sut          = new LazyRelay();
            var dummyRequest = new object();

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

            // Exercise system and verify outcome
            Assert.Throws <ArgumentNullException>(() =>
                                                  sut.Create(dummyRequest, null));
            // Teardown
        }
        public void CreateWithNonTypeRequestReturnsNoSpecimen(object request)
        {
            // Arrange
            var sut          = new LazyRelay();
            var dummyContext = new DelegatingSpecimenContext();
            // Act
            var actual = sut.Create(request, dummyContext);
            // Assert
            var expected = new NoSpecimen();

            Assert.Equal(expected, actual);
        }
Beispiel #4
0
        public void CreateWithNonTypeRequestReturnsNoSpecimen(object request)
        {
            // Fixture setup
            var sut          = new LazyRelay();
            var dummyContext = new DelegatingSpecimenContext();
            // Exercise system
            var actual = sut.Create(request, dummyContext);
            // Verify outcome
            var expected = new NoSpecimen();

            Assert.Equal(expected, actual);
            // Teardown
        }
Beispiel #5
0
        public void CreateWithNonLazyRequestReturnsNoSpecimen(
            Type request)
        {
            // Fixture setup
            var sut          = new LazyRelay();
            var dummyContext = new DelegatingSpecimenContext();
            // Exercise system
            var actual = sut.Create(request, dummyContext);

            // Verify outcome
#pragma warning disable 618
            var expected = new NoSpecimen(request);
#pragma warning restore 618
            Assert.Equal(expected, actual);
            // Teardown
        }
        public void CreateWithLazyRequestReturnsCorrectResult()
        {
            // Arrange
            var sut         = new LazyRelay();
            var @delegate   = new Func <T>(() => default(T));
            var contextStub =
                new DelegatingSpecimenContext {
                OnResolve = t => @delegate
            };
            // Act
            var result = sut.Create(typeof(Lazy <T>), contextStub);
            var actual = Assert.IsAssignableFrom <Lazy <T> >(result);
            // Assert
            var expected = new Lazy <T>(@delegate);

            Assert.Equal(expected.Value, actual.Value);
        }
Beispiel #7
0
        public void CreateWithLazyRequestReturnsCorrectResult()
        {
            // Fixture setup
            var sut         = new LazyRelay();
            var @delegate   = new Func <T>(() => default(T));
            var contextStub =
                new DelegatingSpecimenContext {
                OnResolve = t => @delegate
            };
            // Exercise system
            var result = sut.Create(typeof(Lazy <T>), contextStub);
            var actual = Assert.IsAssignableFrom <Lazy <T> >(result);
            // Verify outcome
            var expected = new Lazy <T>(@delegate);

            Assert.Equal(expected.Value, actual.Value);
            // Teardown
        }