Esempio n. 1
0
        public void IndexerTest()
        {
            // not registered.
            var actualTask = tr["TestTask"];
            Assert.IsNull(actualTask);

            var task = new TestTask();
            tr.Register(task);

            // now with the new type.
            actualTask = tr["TestTask"];
            Assert.IsNotNull(actualTask);
            Assert.IsInstanceOfType(typeof(TestTask), actualTask);
            Assert.AreNotEqual(task, actualTask);
            Assert.AreNotSame(task, actualTask);
        }
Esempio n. 2
0
        public void RegisterTest()
        {
            var task = new TestTask();
            Assert.AreEqual("TestTask", task.Name);

            bool expected = true;
            bool actual = tr.Register(task);
            Assert.AreEqual(expected, actual);
            // register again, skip.
            expected = false;
            actual = tr.Register(task);
            Assert.AreEqual(expected, actual);

            var actualTask = tr["TestTask"];
            Assert.IsInstanceOfType(typeof(TestTask), actualTask);

            var expectedRegged = new string[] { "Backup", "TestTask" };
            var actualRegged = tr.GetRegisteredTasks();
            Assert.AreElementsEqualIgnoringOrder(expectedRegged, actualRegged);
        }
Esempio n. 3
0
 public void ResetTest()
 {
     tr.Reset();
     var initRegged = tr.GetRegisteredTasks();
     var task = new TestTask();
     tr.Register(task);
     var newRegged = tr.GetRegisteredTasks();
     Assert.AreElementsNotEqual(initRegged, newRegged);
     tr.Reset();
     var resetRegged = tr.GetRegisteredTasks();
     Assert.AreElementsNotEqual(resetRegged, newRegged);
     Assert.AreElementsEqualIgnoringOrder(initRegged, resetRegged);
 }