public void ShouldSendLongUdpMessage() { var jsonObject = new JObject(); var message = ResourceHelper.GetResource("LongMessage.txt").ReadToEnd(); jsonObject.Add("full_message", JToken.FromObject(message)); var converter = new Mock <IConverter>(); converter.Setup(c => c.GetGelfJson(It.IsAny <LogEventInfo>(), It.IsAny <IConvertOptions>())).Returns(jsonObject).Verifiable(); var transportClient = new Mock <ITransportClient>(); transportClient.Setup(t => t.Send(It.IsAny <byte[]>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <int>())).Verifiable(); var transport = new UdpTransport(transportClient.Object); var target = new GraylogTarget(transport, converter.Object) { HostIp = "127.0.0.1" }; target.WriteLogEventInfo(new LogEventInfo()); transportClient.Verify(t => t.Send(It.IsAny <IEnumerable <byte[]> >(), It.IsAny <string>(), It.IsAny <int>()), Times.Once); converter.Verify(c => c.GetGelfJson(It.IsAny <LogEventInfo>(), It.IsAny <IConvertOptions>()), Times.Once()); }
public void ShouldSendShortUdpMessage() { var transportClient = new Mock <ITransportClient>(); var transport = new UdpTransport(transportClient.Object); var converter = new Mock <IConverter>(); converter.Setup(c => c.GetGelfJson(It.IsAny <LogEventInfo>(), It.IsAny <IConvertOptions>())).Returns(new JObject()); var target = new GraylogTarget(transport, converter.Object) { HostIp = "127.0.0.1" }; var logEventInfo = new LogEventInfo { Message = "Test Message" }; target.WriteLogEventInfo(logEventInfo); transportClient.Verify(t => t.Send(It.IsAny <byte[]>(), It.IsAny <int>(), It.IsAny <string>(), It.IsAny <int>()), Times.Once()); converter.Verify(c => c.GetGelfJson(It.IsAny <LogEventInfo>(), It.IsAny <IConvertOptions>()), Times.Once()); }