示例#1
0
        public async Task CanInitialize()
        {
            var notifier          = new FakeNotifier();
            var fakeIrcMiddleware = new FakeIrcMiddleware <TwitchChatConnectionParameters>();

            using var subject = new ReconnectMiddleware(fakeIrcMiddleware);
            var result = await subject.InitializeAsync(notifier,
                                                       new TwitchChatConnectionParameters("example.com", 6667, false, "bob", "bob"));

            result.ShouldBeTrue();
            fakeIrcMiddleware.InitializeCount.ShouldBe(1);
        }
示例#2
0
        public async Task WillAttemptReconnect()
        {
            var notifier          = new FakeNotifier();
            var fakeIrcMiddleware = new FakeIrcMiddleware <TwitchChatConnectionParameters>();

            using var subject = new ReconnectMiddleware(fakeIrcMiddleware);
            var result = await subject.InitializeAsync(notifier,
                                                       new TwitchChatConnectionParameters("example.com", 6667, false, "bob", "bob"));

            fakeIrcMiddleware.RegisterWaitForInitialize();
            await subject.HandleErrorAsync(new IOException("Test error", new SocketException((int)SocketError.ConnectionAborted)));

            fakeIrcMiddleware.WaitForInitialize(TimeSpan.FromSeconds(1));
            fakeIrcMiddleware.ShutdownCount.ShouldBe(1);
            fakeIrcMiddleware.InitializeCount.ShouldBe(2);
        }