Exemplo n.º 1
0
        public async Task StartAsync_CancelBeforeStart()
        {
            var connectionService = new FakeIWebSocketConnectionsService();
            var service           = new HeartbeatService(connectionService);

            CancellationTokenSource source = new CancellationTokenSource();
            CancellationToken       token  = source.Token;

            source.Cancel();
            await service.StartAsync(token);

            Assert.AreEqual(0, connectionService.FakeSendToAllAsync.Count);
        }
Exemplo n.º 2
0
        public async Task StartAsyncStop()
        {
            var connectionService = new FakeIWebSocketConnectionsService();
            var service           = new HeartbeatService(connectionService);

            CancellationTokenSource source = new CancellationTokenSource();
            CancellationToken       token  = source.Token;

            await service.StartAsync(token);

            await service.StopAsync(token);

            Assert.IsTrue(connectionService.FakeSendToAllAsync.LastOrDefault()?.Contains("dateTime"));
        }