public void ShouldNotSetPropertyIfResultNotResolved() { // Arrange AutoFixtureValuesHandler sut = CreateSutWithMockedDependencies(); var target = Substitute.For <IInterfaceWithProperty>(); var call = CallHelper.CreatePropertyGetterCallMock(() => target.Property); sut.ResultResolver.ResolveResult(call).Returns( new CallResultData(Maybe.Nothing <object>(), Enumerable.Empty <CallResultData.ArgumentValue>())); // Act var result = sut.Handle(call); // Assert Assert.False(result.HasReturnValue); }
public void ShouldUsePropertyInfoRequestToResolvePropertyValue() { // Arrange var specimenContext = Substitute.For <ISpecimenContext>(); var sut = new CallResultResolver(specimenContext); var target = Substitute.For <IInterfaceWithProperty>(); var call = CallHelper.CreatePropertyGetterCallMock(() => target.Property); var propertyInfo = typeof(IInterfaceWithProperty).GetProperty(nameof(IInterfaceWithProperty.Property)); var retValue = "returnValue"; specimenContext.Resolve(propertyInfo).Returns(retValue); // Act var result = sut.ResolveResult(call); // Assert Assert.True(result.ReturnValue.HasValue()); Assert.Equal(retValue, result.ReturnValue.ValueOrDefault()); }