public void TestMethod_TestOneTarget() { int bufferLimit = 1, logsCount = 10000; TestTarget testTarget = new TestTarget(); StringBuilder stringBuilder = new StringBuilder(); ILoggerTarget[] logTarget = new ILoggerTarget[] { testTarget }; var controller = new LogsCreator(new Logger(bufferLimit, logTarget)); controller.CreateLogs(logsCount, LogLevel.Info); for (int i = 0; i < logsCount; i++) { stringBuilder.Append(i); } CollectionAssert.AreEqual(Encoding.Default.GetBytes(stringBuilder.ToString()), testTarget.GetMessage()); testTarget.Close(); }
public void TestMethod_TestUdpTarget() { int bufferLimit = 5, logsCount = 100; TestUdpServer udpServer = new TestUdpServer("127.0.0.1", 9000); LoggerTargetUdp targetUdp = new LoggerTargetUdp("127.0.0.1", 9000, "127.0.0.1", 10000); StringBuilder stringBuilder = new StringBuilder(); ILoggerTarget[] logTarget = new ILoggerTarget[] { targetUdp }; udpServer.StartReceive(); var logsCreator = new LogsCreator(new Logger(bufferLimit, logTarget)); logsCreator.CreateLogs(logsCount, LogLevel.Debug); for (int i = 0; i < logsCount; i++) { stringBuilder.Append(i); } udpServer.Synchronize(); udpServer.Close(); CollectionAssert.AreEqual(Encoding.Default.GetBytes(stringBuilder.ToString()), udpServer.GetMessage()); }
public void TestMethod_TestTwoTargets() { int bufferLimit = 5, logsCount = 10000; TestTarget firstTestTarget = new TestTarget(); TestTarget secondTestTarget = new TestTarget(); StringBuilder stringBuilder = new StringBuilder(); ILoggerTarget[] logTarget = new ILoggerTarget[] { firstTestTarget, secondTestTarget }; var logsCreator = new LogsCreator(new Logger(bufferLimit, logTarget)); logsCreator.CreateLogs(logsCount, LogLevel.Debug); for (int i = 0; i < logsCount; i++) { stringBuilder.Append(i); } CollectionAssert.AreEqual(Encoding.Default.GetBytes(stringBuilder.ToString()), firstTestTarget.GetMessage()); firstTestTarget.Close(); CollectionAssert.AreEqual(Encoding.Default.GetBytes(stringBuilder.ToString()), secondTestTarget.GetMessage()); secondTestTarget.Close(); }