public void CallbackTestErrorTest() { MsalLogger logger = new MsalLogger(Guid.Empty, null); var counter = 0; Logger.Level = LogLevel.Error; _callback.When(x => x(LogLevel.Error, Arg.Any <string>(), false)).Do(x => counter++); logger.Error("test message"); Assert.AreEqual(1, counter); _callback.Received().Invoke(Arg.Is(LogLevel.Error), Arg.Any <string>(), Arg.Is(false)); _callback.When(x => x(LogLevel.Warning, Arg.Any <string>(), false)).Do(x => counter++); logger.Warning("test message"); Assert.AreEqual(1, counter); _callback.Received().Invoke(Arg.Is(LogLevel.Error), Arg.Any <string>(), Arg.Is(false)); _callback.When(x => x(LogLevel.Info, Arg.Any <string>(), false)).Do(x => counter++); logger.Info("test message"); Assert.AreEqual(1, counter); _callback.When(x => x(LogLevel.Verbose, Arg.Any <string>(), false)).Do(x => counter++); logger.Verbose("test message"); Assert.AreEqual(1, counter); }
public void CallbackLoggerTest(LogLevel level) { MsalLogger logger = CreateLogger(level); var counter = 0; var validationCounter = 1; var levelToValidate = LogLevel.Always; Action incrementCounter = () => { if (level > levelToValidate) { validationCounter++; } levelToValidate++; }; _callback.When(x => x(LogLevel.Always, Arg.Any <string>(), false)).Do(x => counter++); logger.Always(TestConstants.TestMessage); Assert.AreEqual(validationCounter, counter); _callback.Received().Invoke(Arg.Is((LogLevel)validationCounter - 2), Arg.Any <string>(), Arg.Is(false)); incrementCounter.Invoke(); _callback.When(x => x(LogLevel.Error, Arg.Any <string>(), false)).Do(x => counter++); logger.Error(TestConstants.TestMessage); Assert.AreEqual(validationCounter, counter); _callback.Received().Invoke(Arg.Is((LogLevel)validationCounter - 2), Arg.Any <string>(), Arg.Is(false)); incrementCounter.Invoke(); _callback.When(x => x(LogLevel.Warning, Arg.Any <string>(), false)).Do(x => counter++); logger.Warning(TestConstants.TestMessage); Assert.AreEqual(validationCounter, counter); _callback.Received().Invoke(Arg.Is((LogLevel)validationCounter - 2), Arg.Any <string>(), Arg.Is(false)); incrementCounter.Invoke(); _callback.When(x => x(LogLevel.Info, Arg.Any <string>(), false)).Do(x => counter++); logger.Info(TestConstants.TestMessage); Assert.AreEqual(validationCounter, counter); incrementCounter.Invoke(); _callback.When(x => x(LogLevel.Verbose, Arg.Any <string>(), false)).Do(x => counter++); logger.Verbose(TestConstants.TestMessage); Assert.AreEqual(validationCounter, counter); }
public void CallbackTestInfo() { MsalLogger logger = CreateLogger(LogLevel.Info); var counter = 0; _callback.When(x => x(LogLevel.Error, Arg.Any <string>(), false)).Do(x => counter++); logger.ErrorPii(new ArgumentException(TestConstants.TestMessage)); Assert.AreEqual(1, counter); _callback.When(x => x(LogLevel.Warning, Arg.Any <string>(), false)).Do(x => counter++); logger.Warning(TestConstants.TestMessage); Assert.AreEqual(2, counter); _callback.When(x => x(LogLevel.Info, Arg.Any <string>(), false)).Do(x => counter++); logger.Info(TestConstants.TestMessage); Assert.AreEqual(3, counter); _callback.When(x => x(LogLevel.Verbose, Arg.Any <string>(), false)).Do(x => counter++); logger.Verbose(TestConstants.TestMessage); Assert.AreEqual(3, counter); }
public void CallbackTestErrorTest() { MsalLogger logger = CreateLogger(LogLevel.Error); var counter = 0; _callback.When(x => x(LogLevel.Error, Arg.Any <string>(), false)).Do(x => counter++); logger.Error(TestConstants.TestMessage); Assert.AreEqual(1, counter); _callback.Received().Invoke(Arg.Is(LogLevel.Error), Arg.Any <string>(), Arg.Is(false)); _callback.When(x => x(LogLevel.Warning, Arg.Any <string>(), false)).Do(x => counter++); logger.Warning(TestConstants.TestMessage); Assert.AreEqual(1, counter); _callback.Received().Invoke(Arg.Is(LogLevel.Error), Arg.Any <string>(), Arg.Is(false)); _callback.When(x => x(LogLevel.Info, Arg.Any <string>(), false)).Do(x => counter++); logger.Info(TestConstants.TestMessage); Assert.AreEqual(1, counter); _callback.When(x => x(LogLevel.Verbose, Arg.Any <string>(), false)).Do(x => counter++); logger.Verbose(TestConstants.TestMessage); Assert.AreEqual(1, counter); }
public void CallbackTestWarning() { MsalLogger logger = new MsalLogger(Guid.Empty, null); var counter = 0; Logger.Level = LogLevel.Warning; _callback.When(x => x(LogLevel.Error, Arg.Any <string>(), false)). Do(x => counter++); logger.ErrorPii(new ArgumentException("test message")); Assert.AreEqual(1, counter); _callback.When(x => x(LogLevel.Warning, Arg.Any <string>(), false)).Do(x => counter++); logger.Warning("test message"); Assert.AreEqual(2, counter); _callback.When(x => x(LogLevel.Info, Arg.Any <string>(), false)).Do(x => counter++); logger.Info("test message"); Assert.AreEqual(2, counter); _callback.When(x => x(LogLevel.Verbose, Arg.Any <string>(), false)).Do(x => counter++); logger.Verbose("test message"); Assert.AreEqual(2, counter); }