コード例 #1
0
        public void UmbracoMapper_MapFromIPublishedContent_MapsNativePropertiesWithStringFormatter()
        {
            // Arrange
            var model = new SimpleViewModel();
            var content = new StubPublishedContent();
            var mapper = GetMapper();

            // Act
            mapper.Map(content, model, new Dictionary<string, PropertyMapping> { { "Name", new PropertyMapping { StringValueFormatter = x => { return x.ToUpper(); }, } } });

            // Assert
            Assert.AreEqual("TEST CONTENT", model.Name);
        }
コード例 #2
0
        public void UmbracoMapper_MapFromIPublishedContent_MapsNativePropertiesWithMatchingNames()
        {
            // Arrange
            var model = new SimpleViewModel();
            var content = new StubPublishedContent();
            var mapper = GetMapper();

            // Act
            mapper.Map(content, model);

            // Assert
            Assert.AreEqual(1000, model.Id);
            Assert.AreEqual("Test content", model.Name);
        }
コード例 #3
0
 public SimpleViewModel2bWithAttribute()
 {
     Parent = new SimpleViewModel();
 }
コード例 #4
0
        public void UmbracoMapper_MapFromJson_MapsFromChildProperty()
        {
            // Arrange
            var model = new SimpleViewModel();
            var json = GetJsonForSingle4();
            var mapper = GetMapper();

            // Act
            mapper.Map(json, model, new Dictionary<string, PropertyMapping> { { "Name", new PropertyMapping { SourceChildProperty = "fullName" } } });

            // Assert
            Assert.AreEqual(1, model.Id);
            Assert.AreEqual("Test name", model.Name);
        }
コード例 #5
0
        public void UmbracoMapper_MapFromIPublishedContent_DoesNotMapIgnoredNativePropertiesUsingDictionary()
        {
            // Arrange
            var model = new SimpleViewModel();
            var content = new StubPublishedContent();
            var mapper = GetMapper();

            // Act
            mapper.Map(content, model, new Dictionary<string, PropertyMapping> { { "Name", new PropertyMapping { Ignore = true, } } });

            // Assert
            Assert.AreEqual(1000, model.Id);
            Assert.IsNull(model.Name);
        }
コード例 #6
0
 public SimpleViewModel2bWithAttribute()
 {
     Parent = new SimpleViewModel();
 }