Exemple #1
0
        private void EnsureNoErrors()
        {
            progress.DidNotReceiveWithAnyArgs().Error(null, null);
            progress.DidNotReceiveWithAnyArgs().Exception(null, null);
            progress.DidNotReceiveWithAnyArgs().Exception(null, null, null);

            logger.AssertNoWarning();
            logger.AssertNoError();
            logger.AssertNoException();
        }
Exemple #2
0
        public void TestRunTestCases__AllPassing()
        {
            UrlDir.UrlFile file1 = UrlBuilder.CreateFile("abc/blah1.cfg", databaseRoot);
            UrlDir.UrlFile file2 = UrlBuilder.CreateFile("abc/blah2.cfg", databaseRoot);

            ConfigNode testNode1 = new TestConfigNode("NODE1")
            {
                { "key1", "value1" },
                { "key2", "value2" },
                new TestConfigNode("NODE2")
                {
                    { "key3", "value3" },
                },
            };

            ConfigNode testNode2 = new TestConfigNode("NODE3")
            {
                { "key4", "value4" },
            };

            ConfigNode testNode3 = new TestConfigNode("NODE4")
            {
                { "key5", "value5" },
            };

            UrlBuilder.CreateConfig(testNode1, file1);
            UrlBuilder.CreateConfig(testNode2, file1);
            UrlBuilder.CreateConfig(new TestConfigNode("MMTEST_EXPECT")
            {
                testNode1.CreateCopy(),
                testNode2.CreateCopy(),
            }, file1);

            UrlBuilder.CreateConfig(testNode3, file2);
            UrlBuilder.CreateConfig(new TestConfigNode("MMTEST_EXPECT")
            {
                testNode3.CreateCopy(),
            }, file2);

            testRunner.RunTestCases(databaseRoot);

            Received.InOrder(delegate
            {
                logger.AssertInfo("Running tests...");
                logger.AssertInfo("tests complete.");
            });

            logger.AssertNoError();

            Assert.Empty(file1.configs);
            Assert.Empty(file2.configs);
        }
        public void TestApplyPatches()
        {
            IBasicLogger   logger       = Substitute.For <IBasicLogger>();
            IPatchProgress progress     = Substitute.For <IPatchProgress>();
            PatchApplier   patchApplier = new PatchApplier(progress, logger);
            IPass          pass1        = Substitute.For <IPass>();
            IPass          pass2        = Substitute.For <IPass>();
            IPass          pass3        = Substitute.For <IPass>();

            pass1.Name.Returns(":PASS1");
            pass2.Name.Returns(":PASS2");
            pass3.Name.Returns(":PASS3");

            UrlDir.UrlConfig[] patchUrlConfigs = new UrlDir.UrlConfig[9];
            IPatch[]           patches         = new IPatch[9];
            for (int i = 0; i < patches.Length; i++)
            {
                patches[i] = Substitute.For <IPatch>();
            }

            patches[0].CountsAsPatch.Returns(false);
            patches[1].CountsAsPatch.Returns(false);
            patches[2].CountsAsPatch.Returns(false);
            patches[3].CountsAsPatch.Returns(true);
            patches[4].CountsAsPatch.Returns(true);
            patches[5].CountsAsPatch.Returns(true);
            patches[6].CountsAsPatch.Returns(true);
            patches[7].CountsAsPatch.Returns(true);
            patches[8].CountsAsPatch.Returns(true);

            pass1.GetEnumerator().Returns(new ArrayEnumerator <IPatch>(patches[0], patches[1], patches[2]));
            pass2.GetEnumerator().Returns(new ArrayEnumerator <IPatch>(patches[3], patches[4], patches[5]));
            pass3.GetEnumerator().Returns(new ArrayEnumerator <IPatch>(patches[6], patches[7], patches[8]));

            IPass[] patchList = new IPass[] { pass1, pass2, pass3 };

            LinkedList <IProtoUrlConfig> databaseConfigs = Assert.IsType <LinkedList <IProtoUrlConfig> >(patchApplier.ApplyPatches(new[] { pass1, pass2, pass3 }));

            progress.DidNotReceiveWithAnyArgs().Error(null, null);
            progress.DidNotReceiveWithAnyArgs().Exception(null, null);
            progress.DidNotReceiveWithAnyArgs().Exception(null, null, null);

            logger.AssertNoWarning();
            logger.AssertNoError();
            logger.AssertNoException();

            Received.InOrder(delegate
            {
                progress.PassStarted(pass1);
                patches[0].Apply(databaseConfigs, progress, logger);
                patches[1].Apply(databaseConfigs, progress, logger);
                patches[2].Apply(databaseConfigs, progress, logger);
                progress.PassStarted(pass2);
                patches[3].Apply(databaseConfigs, progress, logger);
                progress.PatchApplied();
                patches[4].Apply(databaseConfigs, progress, logger);
                progress.PatchApplied();
                patches[5].Apply(databaseConfigs, progress, logger);
                progress.PatchApplied();
                progress.PassStarted(pass3);
                patches[6].Apply(databaseConfigs, progress, logger);
                progress.PatchApplied();
                patches[7].Apply(databaseConfigs, progress, logger);
                progress.PatchApplied();
                patches[8].Apply(databaseConfigs, progress, logger);
                progress.PatchApplied();
            });
        }