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 CreateWithNullContextThrows() { // Arrange var sut = new FakeItEasyRelay(); var dummyRequest = new object(); // Act & Assert Assert.Throws <ArgumentNullException>(() => sut.Create(dummyRequest, null)); }
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() { // 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 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 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 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 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 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 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); }
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 }
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 }
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 }
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 }
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 }
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 }