public void MonadType_ImplementsExplicitConversionOperatorToValueType() { Assert.IsNotNull(ClosedMonadType.GetMethodsWithParameters() .Where(x => x.Method.Name == "op_Explicit") .Where(x => x.Parameters.Count == 1) .Where(x => x.Parameters[0].ParameterType == ClosedMonadType) .Single(x => x.Method.ReturnType == ValueType)); }
public void ImplementsInequalityOperator_WithLeftAsValueTypeAndRightAsMonadType() { Assert.IsNotNull(ClosedMonadType.GetMethodsWithParameters() .Where(x => x.Method.Name == "op_Inequality") .Where(x => x.Parameters.Count == 2) .Where(x => x.Parameters[0].ParameterType == ValueType) .Single(x => x.Parameters[1].ParameterType == ClosedMonadType)); }
public void OverridesObjectEquals() { var equals = ClosedMonadType.GetMethodsWithParameters() .Where(x => x.Method.Name == "Equals") .Single(x => x.Parameters.Count == 1 && x.Parameters[0].ParameterType == typeof(object)); Assert.IsTrue(equals.Method.DeclaringType == ClosedMonadType); }
public void OverridesObjectGetHashCode() { var equals = ClosedMonadType.GetMethodsWithParameters() .Where(x => x.Method.Name == "GetHashCode") .Single(x => x.Parameters.Count == 0); Assert.IsTrue(equals.Method.DeclaringType == ClosedMonadType); }
public void NoMethods_OnMonadType_ContainOptionalArguments() { var methods = ClosedMonadType.GetMethodsWithParameters().ToArray(); Assert.IsTrue(methods.Length > 0); var outcome = methods.SelectMany(x => x.Parameters.Select(y => Outcome.FailIf(y.IsDefined(typeof(OptionalAttribute), true), String.Format("{0}.{1}.{2} is optional.", ClosedMonadType.Name, x.Method.Name, y.Name)))) .Combine(); Assert.IsTrue(outcome.WasSuccessful, outcome.Observations.Delimit("\r\n")); }