Beispiel #1
0
        internal static bool GetIsStarting(this RestServer server)
        {
            var memberInfo = server.GetType();
            var field      = memberInfo?.GetField("IsStarting", BindingFlags.Instance | BindingFlags.NonPublic);

            return((bool)field?.GetValue(server));
        }
Beispiel #2
0
        internal static void SetIsStarting(this RestServer server, bool val)
        {
            var memberInfo = server.GetType();
            var field      = memberInfo?.GetField("IsStarting", BindingFlags.Instance | BindingFlags.NonPublic);

            field?.SetValue(server, val);
        }
Beispiel #3
0
            public void ClonesAfterStopHandlersInCorrectOrder()
            {
                var server1 = new RestServer();
                var server2 = new RestServer();
                var order   = new List <string>();

                server1.AfterStopping += rs => { order.Add("1"); };
                server1.AfterStopping += rs => { order.Add("2"); };
                server1.CloneEventHandlers(server2);
                server2.GetType().GetMethod("OnAfterStopping", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(server2, null);

                order.Count.ShouldBe(2);
                order[0].ShouldBe("1");
                order[1].ShouldBe("2");
            }
Beispiel #4
0
            public void ClonesBeforeStartHandlersInCorrectOrder()
            {
                var settings = new ServerSettings();
                var server   = new RestServer();
                var order    = new List <string>();

                settings.BeforeStarting += rs => { order.Add("1"); };
                settings.BeforeStarting += rs => { order.Add("2"); };
                settings.CloneEventHandlers(server);
                server.GetType().GetMethod("OnBeforeStarting", BindingFlags.NonPublic | BindingFlags.Instance).Invoke(server, null);

                order.Count.ShouldBe(2);
                order[0].ShouldBe("1");
                order[1].ShouldBe("2");
            }