Beispiel #1
0
        public async Task ShouldNotifyEndpointMiscEvents()
        {
            HttpRequestMessage message = null;

            _httpHandler.When(h => h.RealSendAsync(Arg.Any <HttpRequestMessage>(), Arg.Any <CancellationToken>()))
            .Do(ci =>
            {
                message = ci.Arg <HttpRequestMessage>();
            });

            _service.NotifyMisc(new Endpoint {
                Name = "A"
            }, NotificationType.EndpointAdded);
            Assert.AreEqual(@"{""text"":""The endpoint 'A' has been added.""}", await message.Content.ReadAsStringAsync());

            _service.NotifyMisc(new Endpoint {
                Name = "A"
            }, NotificationType.EndpointRemoved);
            Assert.AreEqual(@"{""text"":""The endpoint 'A' has been removed.""}", await message.Content.ReadAsStringAsync());

            _service.NotifyMisc(new Endpoint {
                Name = "A"
            }, NotificationType.EndpointEnabled);
            Assert.AreEqual(@"{""text"":""The endpoint 'A' has been enabled.""}", await message.Content.ReadAsStringAsync());

            _service.NotifyMisc(new Endpoint {
                Name = "A"
            }, NotificationType.EndpointDisabled);
            Assert.AreEqual(@"{""text"":""The endpoint 'A' has been disabled.""}", await message.Content.ReadAsStringAsync());

            _service.NotifyMisc(new Endpoint {
                Name = "A"
            }, NotificationType.EndpointReconfigured);
            Assert.AreEqual(@"{""text"":""The endpoint 'A' has been reconfigured.""}", await message.Content.ReadAsStringAsync());
        }