public async Task WhenAddingClientWithKnownLastEventId_AllSubsequentEventsShouldBeSendToClient()
        {
            _sut.EnableResend(10);

            await _sut.BroadcastEvent("Ignored 1", id : "1");

            await _sut.BroadcastEvent("M2", id : "2");

            await _sut.BroadcastEvent("M3", id : null);

            await _sut.BroadcastEvent("M4", id : "4");

            var client = new FakeClient()
            {
                LastEventId = "1"
            };

            _sut.Clients.Add(client);

            var body = await client.ReadStreamFromStart();

            body.Should().Be(
                "id:2\ndata:M2\n\n" +
                "data:M3\n\n" +
                "id:4\ndata:M4\n\n");
        }
示例#2
0
        private async Task <string> GetResponseBodyAfterCommentBeingSent(string comment)
        {
            var sut    = new EventTransmitter();
            var client = new FakeClient();

            await sut.SendComment(client, comment);

            return(await client.ReadStreamFromStart());
        }
        public async Task BodyShouldContainRetryFieldWithReconnectionTime()
        {
            var sut    = new EventTransmitter();
            var client = new FakeClient();

            await sut.SendWaitRequest(client, TimeSpan.FromMilliseconds(1000));

            var body = await client.ReadStreamFromStart();

            body.Should().Be("retry:1000\n\n");
        }
        private async Task <string> GetResponseBodyAfterEventBeingSent(
            string data,
            string type = null,
            string id   = null)
        {
            var sut    = new EventTransmitter();
            var client = new FakeClient();

            await sut.SendEvent(client, data, type, id);

            return(await client.ReadStreamFromStart());
        }
        public async Task WhenAddingClientAndResendIsDisabled_NothingShouldBeWrittenToStream()
        {
            _sut.DisableResend(); // Just to be sure

            await _sut.BroadcastEvent("M1", id : "1");

            await _sut.BroadcastEvent("M2", id : "2");

            var client = new FakeClient()
            {
                LastEventId = "1"
            };

            _sut.Clients.Add(client);

            var body = await client.ReadStreamFromStart();

            body.Should().BeEmpty();
        }