public void CreateWhenSpecificationIsSatisfiedReturnsCorrectResult(
            Type request)
        {
            // Fixture setup
            var specificationStub = A.Fake <IRequestSpecification>();

            A.CallTo(() => specificationStub.IsSatisfiedBy(request))
            .Returns(true);

            var expected = typeof(Fake <>)
                           .MakeGenericType(request)
                           .GetConstructor(Type.EmptyTypes)
                           .Invoke(null);
            var contextStub = A.Fake <ISpecimenContext>();

            A.CallTo(() => contextStub.Resolve(typeof(Fake <>).MakeGenericType(request)))
            .Returns(expected);

            var sut = new FakeItEasyRelay(specificationStub);
            // Exercise system
            var actual = sut.Create(request, contextStub);

            // Verify outcome
            Assert.Equal(
                expected.GetType().GetProperty("FakedObject").GetValue(expected, null),
                actual);
            // Teardown
        }
 public void SutIsSpecimenBuilder()
 {
     // Fixture setup
     // Exercise system
     var sut = new FakeItEasyRelay();
     // Verify outcome
     Assert.IsAssignableFrom<ISpecimenBuilder>(sut);
     // Teardown
 }
        public void SutIsSpecimenBuilder()
        {
            // Arrange
            // Act
            var sut = new FakeItEasyRelay();

            // Assert
            Assert.IsAssignableFrom <ISpecimenBuilder>(sut);
        }
        public void SutIsSpecimenBuilder()
        {
            // Fixture setup
            // Exercise system
            var sut = new FakeItEasyRelay();

            // Verify outcome
            Assert.IsAssignableFrom <ISpecimenBuilder>(sut);
            // Teardown
        }
 public void SpecificationIsNotNullWhenInitializedWithDefaultConstructor()
 {
     // Fixture setup
     var sut = new FakeItEasyRelay();
     // Exercise system
     var result = sut.FakeableSpecification;
     // Verify outcome
     Assert.NotNull(result);
     // Teardown
 }
 public void CreateWithNullContextThrows()
 {
     // Fixture setup
     var sut = new FakeItEasyRelay();
     var dummyRequest = new object();
     // Exercise system and verify outcome
     Assert.Throws<ArgumentNullException>(() =>
         sut.Create(dummyRequest, null));
     // Teardown
 }
        public void CreateWithNullContextThrows()
        {
            // Arrange
            var sut          = new FakeItEasyRelay();
            var dummyRequest = new object();

            // Act & Assert
            Assert.Throws <ArgumentNullException>(() =>
                                                  sut.Create(dummyRequest, null));
        }
        public void SpecificationIsNotNullWhenInitializedWithDefaultConstructor()
        {
            // Arrange
            var sut = new FakeItEasyRelay();
            // Act
            var result = sut.FakeableSpecification;

            // Assert
            Assert.NotNull(result);
        }
        public void SpecificationIsCorrectWhenInitializedWithRelay()
        {
            // Arrange
            var expectedRelay = new FakeItEasyRelay();
            var sut           = new AutoFakeItEasyCustomization(expectedRelay);
            // Act
            ISpecimenBuilder result = sut.Relay;

            // Assert
            Assert.Equal(expectedRelay, result);
        }
 public void SpecificationIsCorrectWhenInitializedWithSpecification()
 {
     // Fixture setup
     Func<Type, bool> expectedSpec = t => true;
     var sut = new FakeItEasyRelay(expectedSpec);
     // Exercise system
     Func<Type, bool> result = sut.FakeableSpecification;
     // Verify outcome
     Assert.Equal(expectedSpec, result);
     // Teardown
 }
示例#11
0
 public void SpecificationIsCorrectWhenInitializedWithSpecification()
 {
     // Fixture setup
     var expected = new Fake<IRequestSpecification>().FakedObject;
     var sut = new FakeItEasyRelay(expected);
     // Exercise system
     IRequestSpecification result = sut.FakeableSpecification;
     // Verify outcome
     Assert.Equal(expected, result);
     // Teardown
 }
        public void SpecificationIsCorrectWhenInitializedWithSpecification()
        {
            // Arrange
            var expected = new Fake <IRequestSpecification>().FakedObject;
            var sut      = new FakeItEasyRelay(expected);
            // Act
            IRequestSpecification result = sut.FakeableSpecification;

            // Assert
            Assert.Equal(expected, result);
        }
 public void SpecificationIsCorrectWhenInitializedWithRelay()
 {
     // Fixture setup
     var expectedRelay = new FakeItEasyRelay();
     var sut = new AutoFakeItEasyCustomization(expectedRelay);
     // Exercise system
     ISpecimenBuilder result = sut.Relay;
     // Verify outcome
     Assert.Equal(expectedRelay, result);
     // Teardown
 }
示例#14
0
        public void CreateWithNullContextThrows()
        {
            // Fixture setup
            var sut          = new FakeItEasyRelay();
            var dummyRequest = new object();

            // Exercise system and verify outcome
            Assert.Throws <ArgumentNullException>(() =>
                                                  sut.Create(dummyRequest, null));
            // Teardown
        }
示例#15
0
        public void SpecificationIsNotNullWhenInitializedWithDefaultConstructor()
        {
            // Fixture setup
            var sut = new FakeItEasyRelay();
            // Exercise system
            var result = sut.FakeableSpecification;

            // Verify outcome
            Assert.NotNull(result);
            // Teardown
        }
        public void CreateWithNonAbstractionRequestReturnsCorrectResult(object request)
        {
            // Arrange
            var sut          = new FakeItEasyRelay();
            var dummyContext = new Fake <ISpecimenContext>().FakedObject;
            // Act
            var result = sut.Create(request, dummyContext);
            // Assert
            var expectedResult = new NoSpecimen();

            Assert.Equal(expectedResult, result);
        }
        public void SpecificationIsCorrectWhenInitializedWithSpecification()
        {
            // Fixture setup
            Func <Type, bool> expectedSpec = t => true;
            var sut = new FakeItEasyRelay(expectedSpec);
            // Exercise system
            Func <Type, bool> result = sut.FakeableSpecification;

            // Verify outcome
            Assert.Equal(expectedSpec, result);
            // Teardown
        }
示例#18
0
        public void SpecificationIsCorrectWhenInitializedWithSpecification()
        {
            // Fixture setup
            var expected = new Fake <IRequestSpecification>().FakedObject;
            var sut      = new FakeItEasyRelay(expected);
            // Exercise system
            IRequestSpecification result = sut.FakeableSpecification;

            // Verify outcome
            Assert.Equal(expected, result);
            // Teardown
        }
        public void SpecificationIsCorrectWhenInitializedWithRelay()
        {
            // Fixture setup
            var expectedRelay = new FakeItEasyRelay();
            var sut           = new AutoFakeItEasyCustomization(expectedRelay);
            // Exercise system
            ISpecimenBuilder result = sut.Relay;

            // Verify outcome
            Assert.Equal(expectedRelay, result);
            // Teardown
        }
示例#20
0
 public void CreateWithNonAbstractionRequestReturnsCorrectResult(object request)
 {
     // Fixture setup
     var sut = new FakeItEasyRelay();
     var dummyContext = new Fake<ISpecimenContext>().FakedObject;
     // Exercise system
     var result = sut.Create(request, dummyContext);
     // Verify outcome
     var expectedResult = new NoSpecimen(request);
     Assert.Equal(expectedResult, result);
     // Teardown
 }
        public void SpecificationIsCorrectWhenRelayIsSetViaProperty()
        {
            // Arrange
            var expectedRelay = new FakeItEasyRelay();
            // Act
            var sut = new AutoFakeItEasyCustomization {
                Relay = expectedRelay
            };
            // Assert
            ISpecimenBuilder result = sut.Relay;

            Assert.Equal(expectedRelay, result);
        }
示例#22
0
        public void CreateWithNonAbstractionRequestReturnsCorrectResult(object request)
        {
            // Fixture setup
            var sut          = new FakeItEasyRelay();
            var dummyContext = new Fake <ISpecimenContext>().FakedObject;
            // Exercise system
            var result = sut.Create(request, dummyContext);
            // Verify outcome
            var expectedResult = new NoSpecimen(request);

            Assert.Equal(expectedResult, result);
            // Teardown
        }
        public void CreateCorrectlyInvokesSpecification(Type request)
        {
            // Fixture setup
            var verified = false;
            Func <Type, bool> fakeSpec = t => verified = t == request;
            var sut = new FakeItEasyRelay(fakeSpec);
            // Exercise system
            var contextDummy = new Fake <ISpecimenContext>();

            sut.Create(request, contextDummy.FakedObject);
            // Verify outcome
            Assert.True(verified);
            // Teardown
        }
        public void CreateReturnsCorrectResultWhenContextReturnsNonFake()
        {
            // Arrange
            var request  = typeof(IInterface);
            var fakeType = typeof(Fake <>).MakeGenericType(request);

            var contextStub = new Fake <ISpecimenContext>();

            contextStub.CallsTo(ctx => ctx.Resolve(fakeType)).Returns(new object());

            var sut = new FakeItEasyRelay();
            // Act
            var result = sut.Create(request, contextStub.FakedObject);
            // Assert
            var expectedResult = new NoSpecimen();

            Assert.Equal(expectedResult, result);
        }
        public void CreateWithAbstractionRequestReturnsCorrectResult(Type request)
        {
            // Arrange
            var fakeType = typeof(Fake <>).MakeGenericType(request);

            var fake        = Activator.CreateInstance(fakeType);
            var contextStub = new Fake <ISpecimenContext>();

            contextStub.CallsTo(ctx => ctx.Resolve(fakeType)).Returns(fake);

            var sut = new FakeItEasyRelay();
            // Act
            var result = sut.Create(request, contextStub.FakedObject);
            // Assert
            var expected = fake.GetType().GetProperty("FakedObject").GetValue(fake, null);

            Assert.Equal(expected, result);
        }
        public void CreateWhenSpecificationIsSatisfiedButRequestIsNotTypeReturnsCorrectResult()
        {
            // Arrange
            var specificationStub = A.Fake <IRequestSpecification>();

            A.CallTo(() => specificationStub.IsSatisfiedBy(A <object> .Ignored))
            .Returns(true);

            var sut = new FakeItEasyRelay(specificationStub);

            var request = new object();
            // Act
            var dummyContext = A.Fake <ISpecimenContext>();
            var actual       = sut.Create(request, dummyContext);
            // Assert
            var expected = new NoSpecimen();

            Assert.Equal(expected, actual);
        }
示例#27
0
        public void CreateReturnsCorrectResultWhenContextReturnsNonFake()
        {
            // Fixture setup
            var request  = typeof(IInterface);
            var fakeType = typeof(Fake <>).MakeGenericType(request);

            var contextStub = new Fake <ISpecimenContext>();

            contextStub.CallsTo(ctx => ctx.Resolve(fakeType)).Returns(new object());

            var sut = new FakeItEasyRelay();
            // Exercise system
            var result = sut.Create(request, contextStub.FakedObject);
            // Verify outcome
            var expectedResult = new NoSpecimen(request);

            Assert.Equal(expectedResult, result);
            // Teardown
        }
示例#28
0
        public void CreateWhenSpecificationIsSatisfiedButRequestIsNotTypeReturnsCorrectResult()
        {
            // Fixture setup
            var specificationStub = A.Fake <IRequestSpecification>();

            A.CallTo(() => specificationStub.IsSatisfiedBy(A <object> .Ignored))
            .Returns(true);

            var sut = new FakeItEasyRelay(specificationStub);

            var request = new object();
            // Exercise system
            var dummyContext = A.Fake <ISpecimenContext>();
            var actual       = sut.Create(request, dummyContext);
            // Verify outcome
            var expected = new NoSpecimen(request);

            Assert.Equal(expected, actual);
            // Teardown
        }
示例#29
0
        public void CreateWithAbstractionRequestReturnsCorrectResult(Type request)
        {
            // Fixture setup
            var fakeType = typeof(Fake<>).MakeGenericType(request);

            var fake = Activator.CreateInstance(fakeType);
            var contextStub = new Fake<ISpecimenContext>();
            contextStub.CallsTo(ctx => ctx.Resolve(fakeType)).Returns(fake);

            var sut = new FakeItEasyRelay();
            // Exercise system
            var result = sut.Create(request, contextStub.FakedObject);
            // Verify outcome
            var expected = fake.GetType().GetProperty("FakedObject").GetValue(fake, null);
            Assert.Equal(expected, result);
            // Teardown
        }
 public void CreateCorrectlyInvokesSpecification(Type request)
 {
     // Fixture setup
     var verified = false;
     Func<Type, bool> fakeSpec = t => verified = t == request;
     var sut = new FakeItEasyRelay(fakeSpec);
     // Exercise system
     var contextDummy = new Fake<ISpecimenContext>();
     sut.Create(request, contextDummy.FakedObject);
     // Verify outcome
     Assert.True(verified);
     // Teardown
 }
示例#31
0
        public void CreateWhenSpecificationIsSatisfiedButRequestIsNotTypeReturnsCorrectResult()
        {
            // Fixture setup
            var specificationStub = A.Fake<IRequestSpecification>();
            A.CallTo(() => specificationStub.IsSatisfiedBy(A<object>.Ignored))
                .Returns(true);

            var sut = new FakeItEasyRelay(specificationStub);

            var request = new object();
            // Exercise system
            var dummyContext = A.Fake<ISpecimenContext>();
            var actual = sut.Create(request, dummyContext);
            // Verify outcome
            var expected = new NoSpecimen(request);
            Assert.Equal(expected, actual);
            // Teardown
        }
示例#32
0
        public void CreateWhenSpecificationIsSatisfiedReturnsCorrectResult(
            Type request)
        {
            // Fixture setup
            var specificationStub = A.Fake<IRequestSpecification>();
            A.CallTo(() => specificationStub.IsSatisfiedBy(request))
                .Returns(true);

            var expected = typeof(Fake<>)
                .MakeGenericType(request)
                .GetConstructor(Type.EmptyTypes)
                .Invoke(null);
            var contextStub = A.Fake<ISpecimenContext>();
            A.CallTo(() => contextStub.Resolve(typeof(Fake<>).MakeGenericType(request)))
                .Returns(expected);

            var sut = new FakeItEasyRelay(specificationStub);
            // Exercise system
            var actual = sut.Create(request, contextStub);
            // Verify outcome
            Assert.Equal(
                expected.GetType().GetProperty("FakedObject").GetValue(expected, null),
                actual);
            // Teardown
        }
示例#33
0
        public void CreateReturnsCorrectResultWhenContextReturnsNonFake()
        {
            // Fixture setup
            var request = typeof(IInterface);
            var fakeType = typeof(Fake<>).MakeGenericType(request);

            var contextStub = new Fake<ISpecimenContext>();
            contextStub.CallsTo(ctx => ctx.Resolve(fakeType)).Returns(new object());

            var sut = new FakeItEasyRelay();
            // Exercise system
            var result = sut.Create(request, contextStub.FakedObject);
            // Verify outcome
            var expectedResult = new NoSpecimen(request);
            Assert.Equal(expectedResult, result);
            // Teardown
        }