public void LogShouldAppendTheTextWhenCalledTwoTimesInARow() { ILogger logger = new MemoryLogger(); logger.Log("test"); logger.Log("тест"); Assert.AreEqual("testтест", logger.ToString()); }
public void LogShouldAppendTheTextWhenCalledTwoTimesInARow() { ILogger logger = new MemoryLogger(); logger.Log("test"); logger.Log("тест"); Assert.Equal("testтест", logger.ToString()); }
public void ShouldLog() { MemoryLogger logger; logger = new MemoryLogger(); logger.Log(1, "Component", "Method", LogLevels.Debug, "Message 1"); Assert.AreEqual(1, logger.Count); Assert.AreEqual("Message 1", logger.Logs.ElementAt(0).Message); logger.Log(1, "Component", "Method", LogLevels.Debug, "Message 2"); Assert.AreEqual(2, logger.Count); Assert.AreEqual("Message 2", logger.Logs.ElementAt(1).Message); logger.Log(new Log(DateTime.Now, 1, "Component", "Method", LogLevels.Debug, "Message 3")); Assert.AreEqual(3, logger.Count); Assert.AreEqual("Message 3", logger.Logs.ElementAt(2).Message); }
public void Log_should_not_keep_track_of_discarded_messages() { var logger = new MemoryLogger(LogLevel.Error); logger.Log(LogLevel.Warning, "discarded"); logger.All.Should().BeEmpty(); }
public Robot CreateRobot <T>() where T : Robot { var robot = (T)Activator.CreateInstance(typeof(T)); if (robot.State == RobotState.Disconnected || robot.State == RobotState.Alive) { MemoryLogger.Log("Could not add robot. An existing state was found."); // TODO: throw exception? return(null); } robot.Inventory = new Inventory(robot); var threadStart = new ParameterizedThreadStart(r => { var thisRobot = (Robot)r; while (!game.IsPaused && thisRobot.State == RobotState.Alive) { UpdateRobot(thisRobot); Thread.Sleep(25); } }); var thread = new Thread(threadStart) { IsBackground = true }; thread.Start(robot); robots.Add(robot, thread); return(robot); }
public void LogLineShouldAppendLineBetweenTwoLogCalls() { const string FirstMessage = "test"; const string SecondMessage = "тест"; ILogger logger = new MemoryLogger(); logger.LogLine(FirstMessage); logger.Log(SecondMessage); Assert.AreEqual(FirstMessage + Environment.NewLine + SecondMessage, logger.ToString()); }
public override async Task OnConnectedAsync() { var clientId = this.Context.GetHttpContext().TryGetQueryParameterValue(ReportLogConst.ArgsClientId, ""); Logger.Log($"OnConnectedAsync: {clientId}"); try { var logger = _serviceProvider.GetService <ILogger <LogHub> >(); ShowEnabled(logger); } catch (Exception e) { Logger.Log($"OnConnectedAsync Ex: {e.Message}"); } await base.OnConnectedAsync().ConfigureAwait(false); }
public void LogLineShouldAppendLineBetweenTwoLogCalls() { const string FirstMessage = "test"; const string SecondMessage = "тест"; ILogger logger = new MemoryLogger(); logger.LogLine(FirstMessage); logger.Log(SecondMessage); Assert.Equal(FirstMessage + Environment.NewLine + SecondMessage, logger.ToString()); }
private static MemoryLogger CreateLoggerWithOneOfEachLevel() { var logger = new MemoryLogger(); foreach (LogLevel logLevel in Enum.GetValues(typeof(LogLevel))) { logger.Log(logLevel, "{0}", (int)logLevel); } return(logger); }
private void UpdateRobot(Robot robot) { try { robot.Update(this); } catch (Exception exception) { MemoryLogger.Log(exception.Message); } }