public async Task CanShutdown()
        {
            var notifier = new FakeNotifier();

            using var subject = CreateSubject();
            var pipe = new System.IO.Pipelines.Pipe();
            await subject.InitializeAsync(notifier, pipe.Reader.AsStream());

            await subject.ShutdownAsync();
        }
Exemplo n.º 2
0
        public async Task WriteLoop()
        {
            var notifier = new FakeNotifier();

            using var subject = CreateSubject();
            var pipe = new System.IO.Pipelines.Pipe();
            await subject.InitializeAsync(notifier, pipe.Writer.AsStream());

            await subject.WriteMessageAsync(new IrcMessage("TEST"));

            using var reader = new StreamReader(pipe.Reader.AsStream());
            var s = await reader.ReadLineAsync();

            s.ShouldBe("TEST");
            notifier.ExceptionList.Count.ShouldBe(0);
        }
        public async Task CanReadMessage()
        {
            var notifier = new FakeNotifier();

            using var subject = CreateSubject();
            var pipe = new System.IO.Pipelines.Pipe();
            await subject.InitializeAsync(notifier, pipe.Reader.AsStream());

            await pipe.Writer.WriteAsync(new Memory <byte>(Encoding.UTF8.GetBytes(":tmi.twitch.tv 001 drangrybot :Welcome, GLHF!\r\n")));

            var message = notifier.WaitForMessages(1).First();

            message.Command.ShouldBe("001");
            message.Parameters.Count.ShouldBe(2);
            message.Parameters[0].ShouldBe("drangrybot");
            message.Parameters[1].ShouldBe("Welcome, GLHF!");
            notifier.ExceptionList.Count.ShouldBe(0);
        }