public void HelperGetPropertyTest() { var ctx = UmbracoUnitTestHelper.GetUmbracoContext(); var contentId = 2; //get a mocked IPublishedContent var contentMock = UmbracoUnitTestHelper.GetPublishedContentMock(properties: new[] { UmbracoUnitTestHelper.GetPublishedProperty(value: "testValue", alias: "testProp") }); var mockedTypedQuery = new Mock <ITypedPublishedContentQuery>(); mockedTypedQuery.Setup(s => s.TypedContent(contentId)).Returns(contentMock.Object); //give our dynamic query mock to the longer version of the UmbracoHelper constructor var helper = UmbracoUnitTestHelper.GetUmbracoHelper(ctx, typedQuery: mockedTypedQuery.Object); var controller = new BasicTestSurfaceController(ctx, helper); var res = controller.BasicGetPropertyAction(contentId, contentMock.Object.Properties.First().PropertyTypeAlias); var model = (string)res.Model; Assert.AreEqual(contentMock.Object.Properties.First().Value, model); }
public void EngineApiGetPropertyTest() { var value = "testValue"; var alias = "testAlias"; var content = _unitTestEngine.WithPublishedContentPage(properties: new[] { UmbracoUnitTestHelper.GetPublishedProperty(value: value, alias: alias) }); var controller = new BasicUmbracoApiController(_unitTestEngine.UmbracoContext, _unitTestEngine.UmbracoHelper); var res = controller.BasicGetPropertyAction(content.Id, content.Properties.First().PropertyTypeAlias); Assert.AreEqual(content.Properties.First().Value, res); }
public void EngineGetPropertyValueTypeTest() { var value = "testValue"; var alias = "testAlias"; var content = _unitTestEngine.WithPublishedContentPage(properties: new[] { UmbracoUnitTestHelper.GetPublishedProperty(value: value, alias: alias) }); var controller = new BasicTestSurfaceController(_unitTestEngine.UmbracoContext, _unitTestEngine.UmbracoHelper); var res = controller.BasicGetPropertyValueTypeAction(content.Id, content.Properties.First().PropertyTypeAlias); var model = (string)res.Model; Assert.AreEqual(content.Properties.First().Value, model); }