コード例 #1
0
 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));
 }
コード例 #2
0
 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));
 }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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"));
        }