public void TestSortAndExtractPatches__Exception() { Exception e = new Exception("an exception was thrown"); progress.WhenForAnyArgs(p => p.Error(null, null)).Throw(e); UrlDir.UrlConfig config1 = CreateConfig("@NODE"); UrlDir.UrlConfig config2 = CreateConfig("@NODE:FIRST:FIRST"); UrlDir.UrlConfig config3 = CreateConfig("@NADE:FIRST"); string[] modList = { "mod1" }; PatchList list = PatchExtractor.SortAndExtractPatches(root, modList, progress); progress.Received().Exception(config2, "Exception while parsing pass for config: abc/def/@NODE:FIRST:FIRST", e); Assert.Equal(new[] { config1 }, list.legacyPatches); Assert.Equal(1, list.firstPatches.Count); AssertUrlCorrect("@NADE", config3, list.firstPatches[0]); progress.Received(2).PatchAdded(); }
public void TestCheckNeeds__ExceptionWhileLoggingException() { string[] modList = { "mod1", "mod2" }; UrlDir.UrlConfig config1 = UrlBuilder.CreateConfig(new ConfigNode("SOME_NODE"), file); UrlDir.UrlConfig config2 = UrlBuilder.CreateConfig(new ConfigNode("SOME_NODE:NEEDS[mod3]"), file); UrlDir.UrlConfig config3 = UrlBuilder.CreateConfig(new ConfigNode("SOME_NODE"), file); Exception e1 = new Exception(); Exception e2 = new Exception(); progress.When(p => p.NeedsUnsatisfiedRoot(config2)).Throw(e1); progress.WhenForAnyArgs(p => p.Exception(null, null, null)).Throw(e2); NeedsChecker.CheckNeeds(root, modList, progress, logger); progress.ReceivedWithAnyArgs().Exception(null, null, null); progress.DidNotReceiveWithAnyArgs().Error(null, null); progress.Received().Exception("Exception while attempting to log an exception", e2); Assert.Equal(new[] { config1, config3 }, root.AllConfigs); }