public void Test_Either_of_Property_or_FieldInfo() { var some = new Some(false); var field = some.GetType().GetField("X"); var property = some.GetType().GetProperty("Y"); Assert.NotNull(field); Assert.NotNull(property); Either <PropertyInfo, FieldInfo> info = field; var infoType = info.Is(p => p.PropertyType, f => f.FieldType); Assert.That(infoType, Is.EqualTo(typeof(bool))); }
public void Either_of_three_cases_using_nesting() { var some = new Some(false); var field = some.GetType().GetField("X"); var parameter = some.GetType().GetConstructors()[0].GetParameters()[0]; Assert.NotNull(field); Assert.NotNull(parameter); var info = Either <ParameterInfo, Either <PropertyInfo, FieldInfo> > .Of(parameter); var name = info.Match(_ => _.Name, _ => _.Name, _ => _.Name); Assert.That(name, Is.EqualTo("a")); }
public void CanHandleIMaybeExpectation() { // Arrange IMaybe <Guid> expectation = new Some <Guid>(Guid.NewGuid()); var context = new EquivalencyValidationContext { Expectation = expectation, CompileTimeType = expectation.GetType() }; var config = new EquivalencyAssertionOptions <None <int> >(); var sut = new MaybeEquivalencyStep(); // Act var actual = sut.CanHandle(context, config); // Assert actual.Should().BeTrue(); }