Esempio n. 1
0
        public void CreateContentBlockController_CallTheIndexAction_EnsuresTheModelIsProperlyCreated()
        {
            // Arrange: Create a dummy controller and set fake property values
            using (new ObjectFactoryContainerRegion())
            {
                this.RegisterResourceClasses();

                using (var controller = new DummyContentBlockController())
                {
                    controller.Content             = "Fake controller";
                    controller.ProviderName        = "Fake provider";
                    controller.SharedContentID     = Guid.NewGuid();
                    controller.EnableSocialSharing = true;

                    // Act: Call the Index action and get the model from the ActionResult
                    var res               = controller.Index() as ViewResult;
                    var model             = res.Model;
                    var contentBlockModel = model as IContentBlockModel;

                    // Assert: ensures the model is properly created and all its properties are properly populated
                    Assert.IsNotNull(contentBlockModel, "The model is null or its not implementing the IContentBlockInterface");
                    Assert.AreEqual(controller.Content, contentBlockModel.Content, "The Content property of the model is not properly set");
                    Assert.AreEqual(controller.ProviderName, contentBlockModel.ProviderName, "The provider name is not properly set");
                    Assert.AreEqual(controller.SharedContentID, contentBlockModel.SharedContentID, "The Id of the shared content item is not properly set");
                    Assert.AreEqual(controller.EnableSocialSharing, contentBlockModel.EnableSocialSharing, "The indicator which shows if the content block allows the social share options is not properly set");
                }
            }
        }
Esempio n. 2
0
        public void CreateContentBlockController_IndexAction_EnsuresTheActionUsesTheRightViewName()
        {
            // Arrange: Create a dummy controller and set fake property values
            using (new ObjectFactoryContainerRegion())
            {
                this.RegisterResourceClasses();
                using (var controller = new DummyContentBlockController())
                {
                    controller.Content             = "Fake controller";
                    controller.ProviderName        = "Fake provider";
                    controller.SharedContentID     = Guid.NewGuid();
                    controller.EnableSocialSharing = true;

                    // Act: Call the Index action and get the model from the ActionResult
                    var res      = controller.Index() as ViewResult;
                    var viewName = res.ViewName;

                    // Assert: the action uses the right view name
                    Assert.AreEqual(viewName, "Default", "The requested view does not have the right name");
                }
            }
        }