/// <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 ); })); }
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); }
/// <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)); }
/// <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)); }
public MaxCommand(IMax cmd) { this.cmd = cmd; }