public void TestLogTo__Info() { NormalMessage message = new NormalMessage(LogType.Log, "everything is ok"); message.LogTo(logger); logger.Received().Log(LogType.Log, "everything is ok"); }
public static void AssertInfo(this IBasicLogger logger, string message) { if (logger == null) { throw new ArgumentNullException(nameof(logger)); } logger.Received().Log(Arg.Is <ILogMessage>(msg => msg.LogType == LogType.Log && msg.Message == message)); }
public static void AssertException(this IBasicLogger logger, Exception exception) { if (logger == null) { throw new ArgumentNullException(nameof(logger)); } logger.Received().Log(Arg.Is <ILogMessage>(msg => msg.LogType == LogType.Exception && msg.Message == exception.ToString())); }
public void TestLog() { IBasicLogger logger1 = Substitute.For <IBasicLogger>(); IBasicLogger logger2 = Substitute.For <IBasicLogger>(); LogSplitter logSplitter = new LogSplitter(logger1, logger2); logSplitter.Log(LogType.Log, "some stuff"); logger1.Received().Log(LogType.Log, "some stuff"); logger2.Received().Log(LogType.Log, "some stuff"); }
public void TestException() { IBasicLogger logger1 = Substitute.For <IBasicLogger>(); IBasicLogger logger2 = Substitute.For <IBasicLogger>(); LogSplitter logSplitter = new LogSplitter(logger1, logger2); Exception ex = new Exception(); logSplitter.Exception("some stuff", ex); logger1.Received().Exception("some stuff", ex); logger2.Received().Exception("some stuff", ex); }
public void TestLogTo() { IBasicLogger logger = Substitute.For <IBasicLogger>(); Exception e = new Exception(); ExceptionMessage message = new ExceptionMessage("An exception was thrown", e); message.LogTo(logger); logger.Received().Exception("An exception was thrown", e); }
public void TestLog() { IBasicLogger logger1 = Substitute.For <IBasicLogger>(); IBasicLogger logger2 = Substitute.For <IBasicLogger>(); LogSplitter logSplitter = new LogSplitter(logger1, logger2); ILogMessage message = Substitute.For <ILogMessage>(); logSplitter.Log(message); logger1.Received().Log(message); logger2.Received().Log(message); }
public void TestLog() { ILogMessage logMessage = Substitute.For<ILogMessage>(); logMessage.LogType.Returns(LogType.Log); logMessage.Message.Returns("well hi there"); logMessage.Timestamp.Returns(new DateTime(2000, 1, 1, 12, 34, 45, 678)); logger.Log(logMessage); innerLogger.Received().Log(Arg.Is<ILogMessage>(msg => msg.LogType == LogType.Log && msg.Timestamp == logMessage.Timestamp && msg.Message == "[MyMod] well hi there" )); }
public void Test__Constructor__Nested() { IBasicLogger logger2 = Substitute.For <IBasicLogger>(); PatchProgress progress2 = new PatchProgress(progress, logger2); Assert.Same(progress.Counter, progress2.Counter); Assert.Equal(0, progress.Counter.patchedNodes); UrlDir.UrlConfig original = UrlBuilder.CreateConfig("abc/def", new ConfigNode("SOME_NODE")); UrlDir.UrlConfig patch1 = UrlBuilder.CreateConfig("ghi/jkl", new ConfigNode("@SOME_NODE")); progress2.ApplyingUpdate(original, patch1); Assert.Equal(1, progress.Counter.patchedNodes); logger.DidNotReceiveWithAnyArgs().Log(LogType.Log, null); logger2.Received().Log(LogType.Log, "Applying update ghi/jkl/@SOME_NODE to abc/def/SOME_NODE"); }
public void TestApplyPatches__Loop() { UrlDir.UrlConfig config1 = UrlBuilder.CreateConfig(new TestConfigNode("PART") { { "name", "000" }, { "aaa", "1" }, }, file); UrlDir.UrlConfig patch1 = new UrlDir.UrlConfig(file, new TestConfigNode("@PART:HAS[~aaa[>10]]") { { "@aaa *", "2" }, { "bbb", "002" }, new ConfigNode("MM_PATCH_LOOP"), }); patchList.firstPatches.Add(patch1); patchApplier.ApplyPatches(); EnsureNoErrors(); progress.Received(1).PatchApplied(); progress.Received(4).ApplyingUpdate(config1, patch1); logger.Received().Log(LogType.Log, "Looping on abc/def/@PART:HAS[~aaa[>10]] to abc/def/PART"); UrlDir.UrlConfig[] allConfigs = databaseRoot.AllConfigs.ToArray(); Assert.Equal(1, allConfigs.Length); AssertNodesEqual(new TestConfigNode("PART") { { "name", "000" }, { "aaa", "16" }, { "bbb", "002" }, { "bbb", "002" }, { "bbb", "002" }, { "bbb", "002" }, }, allConfigs[0].config); }
public void TestApplyingUpdate() { IProtoUrlConfig original = Substitute.For <IProtoUrlConfig>(); original.FullUrl.Returns("abc/def.cfg/SOME_NODE"); UrlDir.UrlConfig patch1 = UrlBuilder.CreateConfig("ghi/jkl", new ConfigNode("@SOME_NODE")); UrlDir.UrlConfig patch2 = UrlBuilder.CreateConfig("pqr/stu", new ConfigNode("@SOME_NODE")); Assert.Equal(0, progress.Counter.patchedNodes); progress.ApplyingUpdate(original, patch1); Assert.Equal(1, progress.Counter.patchedNodes); logger.Received().Log(LogType.Log, "Applying update ghi/jkl/@SOME_NODE to abc/def.cfg/SOME_NODE"); progress.ApplyingUpdate(original, patch2); Assert.Equal(2, progress.Counter.patchedNodes); logger.Received().Log(LogType.Log, "Applying update pqr/stu/@SOME_NODE to abc/def.cfg/SOME_NODE"); }
public void TestApplyingUpdate() { UrlDir.UrlConfig original = UrlBuilder.CreateConfig("abc/def", new ConfigNode("SOME_NODE")); UrlDir.UrlConfig patch1 = UrlBuilder.CreateConfig("ghi/jkl", new ConfigNode("@SOME_NODE")); UrlDir.UrlConfig patch2 = UrlBuilder.CreateConfig("pqr/stu", new ConfigNode("@SOME_NODE")); Assert.Equal(0, progress.Counter.patchedNodes); progress.ApplyingUpdate(original, patch1); Assert.Equal(1, progress.Counter.patchedNodes); logger.Received().Log(LogType.Log, "Applying update ghi/jkl/@SOME_NODE to abc/def/SOME_NODE"); progress.ApplyingUpdate(original, patch2); Assert.Equal(2, progress.Counter.patchedNodes); logger.Received().Log(LogType.Log, "Applying update pqr/stu/@SOME_NODE to abc/def/SOME_NODE"); }
public void TestLog__Info() { logger.Log(LogType.Log, "well hi there"); innerLogger.Received().Log(LogType.Log, "[MyMod] well hi there"); }
public void TestInfo() { logger.Info("well hi there"); logger.Received().Log(LogType.Log, "well hi there"); }