Exemplo n.º 1
0
        public void MapToProperty_ConfigurationIsLazy_CallsCreateClassOnServiceWithIsLazy()
        {
            //Assign
            var contentService = new ContentService(_unitOfWork, _repoFactory);
            var content        = contentService.GetById(new Guid("{C382AE57-D325-4357-A32A-0A959BBD4101}"));
            var service        = Substitute.For <IUmbracoService>();

            service.ContentService.Returns(contentService);
            var context = new UmbracoDataMappingContext(null, content, service);

            var config = new UmbracoParentConfiguration();

            config.PropertyInfo = typeof(Stub).GetProperty("Property");
            config.IsLazy       = true;

            var mapper = new UmbracoParentMapper();

            mapper.Setup(new DataMapperResolverArgs(null, config));

            //Act
            mapper.MapToProperty(context);

            //Assert
            //ME - I am not sure why I have to use the Arg.Is but just using item.Parent as the argument fails.
            service.Received().CreateType(config.PropertyInfo.PropertyType, Arg.Is <IContent>(x => x.Id == content.ParentId), true, false);
        }
Exemplo n.º 2
0
        public void MapToCms_ThrowsException()
        {
            //Assign
            var mapper = new UmbracoParentMapper();

            //Act
            mapper.MapToCms(null);
        }
Exemplo n.º 3
0
        public void ReadOnly_ReturnsTrue()
        {
            //Assign
            var mapper = new UmbracoParentMapper();

            //Act
            var result = mapper.ReadOnly;

            //Assert
            Assert.IsTrue(result);
        }
Exemplo n.º 4
0
        public void CanHandle_ConfigurationIsUmbracoInfo_ReturnsFalse()
        {
            //Assign
            var config = new UmbracoInfoConfiguration();
            var mapper = new UmbracoParentMapper();

            //Act
            var result = mapper.CanHandle(config, null);

            //Assert
            Assert.IsFalse(result);
        }