コード例 #1
0
        /// <summary>
        /// Tests if the cookie has the Age flag
        /// </summary>
        /// <param name="more"></param>
        /// <param name="expectedAge"></param>
        /// <param name="customMessageGenerator"></param>
        /// <returns></returns>
        public static IMore <Cookie> Age(
            this IMax <Cookie> more,
            int expectedAge,
            Func <string> customMessageGenerator
            )
        {
            return(more.AddMatcher(actual =>
            {
                var passed = false;
                var hasMaxAge = actual.TryGetMetadata <int>("MaxAge", out var maxAge);
                if (hasMaxAge)
                {
                    passed = maxAge == expectedAge;
                }

                return new MatcherResult(
                    passed,
                    () =>
                    hasMaxAge
                            ? $"Expected {actual.Name()} {passed.AsNot()}to have Max-Age '{expectedAge}' (found {maxAge})"
                            : $"Expected {actual.Name()} {passed.AsNot()}to have Max-Age set",
                    customMessageGenerator
                    );
            }));
        }
コード例 #2
0
        public String Statistic(String cmdType, String arg1, String arg2)
        {
            ICommand cmd;

            if (cmdType == "Sum")
            {
                ISum sum = SumFactory.GetCommand(arg1, arg2);
                cmd = new SumCommand(sum);
            }
            else if (cmdType == "Average")
            {
                IAverage average = AverageFactory.GetCommand(arg1, arg2);
                cmd = new AverageCommand(average);
            }
            else if (cmdType == "Max")
            {
                IMax max = MaxFactory.GetCommand(arg1, arg2);
                cmd = new MaxCommand(max);
            }
            else
            {
                IMin min = MinFactory.GetCommand(arg1, arg2);
                cmd = new MinCommand(min);
            }

            String res = CommandInvoker.DoCommand(cmd);

            return(res);
        }
コード例 #3
0
 /// <summary>
 /// Tests if the cookie has the Age flag
 /// </summary>
 /// <param name="more"></param>
 /// <param name="expectedAge"></param>
 /// <returns></returns>
 public static IMore <Cookie> Age(
     this IMax <Cookie> more,
     int expectedAge
     )
 {
     return(more.Age(expectedAge, NULL_STRING));
 }
コード例 #4
0
 /// <summary>
 /// Tests if the cookie has the Age flag
 /// </summary>
 /// <param name="more"></param>
 /// <param name="expectedAge"></param>
 /// <param name="customMessage"></param>
 /// <returns></returns>
 public static IMore <Cookie> Age(
     this IMax <Cookie> more,
     int expectedAge,
     string customMessage
     )
 {
     return(more.Age(expectedAge, () => customMessage));
 }
コード例 #5
0
 public MaxCommand(IMax cmd)
 {
     this.cmd = cmd;
 }