Example #1
0
        public void Test_IsController()
        {
            ControllerScanner scanner = new ControllerScanner();

            CreateController controller = new CreateController();

            bool isController = scanner.IsController(controller.GetType());

            Assert.IsTrue(isController, "CreateController class is not recognised as a controller as it should be.");
        }
Example #2
0
        public void Test_Create_Parent()
        {
            MockProjection projection = new MockProjection();

            projection.RequireAuthorisation = false;
            projection.Command = new CreateComandInfo(typeof(TestArticlePage).Name);

            TestArticle article = CreateStrategy.New <TestArticle>(false).Create <TestArticle>();

            article.ID    = Guid.NewGuid();
            article.Title = "Test title";

            SaveStrategy.New <TestArticle>(false).Save(article);

            CreateController controller = CreateController.New(projection);

            Assert.IsTrue(controller is CreateSubEntityController, "Invalid controller type: " + controller.GetType().ToString());

            CreateSubEntityController createSubEntityController = (CreateSubEntityController)controller;

            ISubEntity subEntity = (ISubEntity)createSubEntityController.Create(article.ID, String.Empty);

            Assert.IsNotNull(subEntity, "No sub entity returned.");

            Assert.IsTrue((subEntity is TestArticlePage), "Wrong type returned: " + subEntity.GetType().ToString());

            Assert.IsNotNull(subEntity.Parent, "No parent assigned to sub entity.");

            Assert.AreEqual(article.ID.ToString(), subEntity.Parent.ID.ToString(), "Parent ID doesn't match expected.");

            Assert.AreEqual(1, subEntity.Number, "Sub entity has wrong number.");

            SaveStrategy.New(subEntity, false).Save(subEntity);


            ISubEntity subEntity2 = (ISubEntity)createSubEntityController.Create(Guid.Empty, article.UniqueKey);

            Assert.IsNotNull(subEntity2, "No sub entity returned.");

            Assert.IsTrue((subEntity2 is TestArticlePage), "Wrong type returned: " + subEntity.GetType().ToString());

            Assert.IsNotNull(subEntity2.Parent, "No parent assigned to sub entity.");

            Assert.AreEqual(article.ID.ToString(), subEntity2.Parent.ID.ToString(), "Parent ID doesn't match expected.");

            Assert.AreEqual(2, subEntity2.Number, "Sub entity has wrong number.");
        }