コード例 #1
0
                public bool Matches(ITestActualEvaluation <TFrom> actualFactory)
                {
                    var      real  = TestMatcherName.FromType(_real.GetType());
                    Func <T> thunk = () => {
                        try {
                            var actual = actualFactory.Value;
                            return((T)(object)actual);
                        } catch (InvalidCastException e) {
                            throw SpecFailure.CastRequiredByMatcherFailure(e, real);
                        }
                    };

                    return(_real.Matches(TestActual.Of(thunk)));
                }
コード例 #2
0
                public bool Matches(ITestActualEvaluation <IEnumerable> actualFactory)
                {
                    // When the matcher can already handle the input, no need to apply
                    // adapter logic
                    if (_real is ITestMatcher <IEnumerable> fast)
                    {
                        return(fast.Matches(actualFactory));
                    }

                    var real = TestMatcherName.FromType(_real.GetType());
                    Func <IEnumerable <object> > thunk = () => (
                        actualFactory.Value.Cast <object>()
                        );

                    return(_real.Matches(TestActual.Of(thunk)));
                }
コード例 #3
0
 public void FromType_gets_type_names(Type type, string expected)
 {
     Assert.Equal(
         expected, TestMatcherName.FromType(type).Name
         );
 }