Beispiel #1
0
        public static Dictionary WasEmittedWithArgs(Object emitter, string signal, Array arguments, string context)
        {
            var passed     = $"Signal {signal} was emitted from {emitter} with arguments {arguments}";
            var failed     = $"Signal {signal} was not emitted from {emitter} with arguments {arguments}";
            var altFailure = $"Signal {signal} was not emitted from {emitter}";

            var success = false;
            var result  = "";
            var watcher = (Reference)emitter.GetMeta("watcher");
            var data    = (IDictionary)watcher.Call("get_data", signal);

            if ((int)data["emit_count"] <= 0)
            {
                success = false;
                result  = altFailure;
            }
            else if (FoundMatchingCall(arguments, (IEnumerable)data["calls"]))
            {
                success = true;
                result  = passed;
            }
            else
            {
                success = false;
                result  = failed;
            }

            return(Result(success, passed, result, context));
        }
Beispiel #2
0
        public static Dictionary WasEmittedXTimes(Object emitter, string signal, int times, string context)
        {
            var passed = $"Signal {signal} was emitted {times} times from {emitter}";
            var failed = $"Signal {signal} was not emitted {times} times from {emitter}";

            var watcher = (Reference)emitter.GetMeta("watcher");
            var success = (int)watcher.Call("get_emit_count", signal) == times;
            var result  = success ? passed : failed;

            return(Result(success, passed, result, context));
        }
Beispiel #3
0
        public static object WasNotEmitted(Object emitter, string signal, string context)
        {
            var passed = $"Signal {signal} was not emitted from {emitter}";
            var failed = $"Signal {signal} was emitted from {emitter}";

            var watcher = (Object)emitter.GetMeta("watcher");
            var success = (int)watcher.Call("get_emit_count", signal) <= 0;
            var result  = success ? passed : failed;

            return(Result(success, passed, result, context));
        }