Exemple #1
0
        public void TestLoadAndRunDynamicSecondImpl()
        {
            var cities = new Cities();

            cities.ReadCities(CitiesTestFile);

            ILinks links = LinksFactory.Create(cities,
                                               "Fhnw.Ecnf.RoutePlanner.RoutePlannerTest.TestLinksValidConstructor");

            Assert.AreEqual(42, links.ReadLinks("nonsense"));

            ILinks links2 = LinksFactory.Create(cities, "Fhnw.Ecnf.RoutePlanner.RoutePlannerLib.Links");

            Assert.AreNotEqual(links.GetType(), links2.GetType());

            try
            {
                LinksFactory.Create(cities,
                                    "Fhnw.Ecnf.RoutePlanner.RoutePlannerTest.Lab5Test.TestLinksInvalidConstructor");
                Assert.Fail("Should throw a NotSupportedException, because it doesn't have the right constructor");
            }
            catch (NotSupportedException)
            {
            }

            try
            {
                LinksFactory.Create(cities, "Fhnw.Ecnf.RoutePlanner.RoutePlannerTest.Lab10Test.TestLinksNoInterface");
                Assert.Fail("Should throw a NotSupportedException, because ILinks is not implemented");
            }
            catch (NotSupportedException)
            {
            }
        }