public void CustomerPictureModelBinder_Returns_CustomerPicture_Without_Photo_When_Photo_Isnt_HttpPostedFile()
        {
            //Arrange
            int customerId = 15;

            SValueProviderResult photoResult = new SValueProviderResult(null, "AAA", null);

            photoResult.ConvertToTypeCultureInfo = (type, culture) => null;
            IValueProvider provider = new SIValueProvider()
            {
                ContainsPrefixString = x => x.StartsWith("CustomerPicture.Photo") || x.StartsWith("CustomerPicture.CustomerId") || x.Equals("CustomerPicture"),
                GetValueString       = x =>
                {
                    switch (x)
                    {
                    case "CustomerPicture.Photo":
                        return(photoResult);

                    case "CustomerPicture.CustomerId":
                        return(new ValueProviderResult(15, "15", null));

                    default:
                        return(null);
                    }
                }
            };

            ModelMetadata metadata             = ModelMetadataProviders.Current.GetMetadataForType(null, typeof(CustomerPicture));
            CustomerPictureModelBinder binder  = new CustomerPictureModelBinder();
            ControllerContext          context = new ControllerContext();

            ModelBindingContext bindingContext = new ModelBindingContext()
            {
                ModelName     = "CustomerPicture",
                ValueProvider = provider,
                ModelMetadata = metadata
            };

            //Act
            CustomerPicture result = binder.BindModel(context, bindingContext) as CustomerPicture;


            //Assert
            Assert.AreEqual(customerId, result.CustomerId);
            Assert.IsNull(result.Customer);
            Assert.IsNull(result.Photo);
        }
        public void CustomerPictureModelBinder_Returns_CustomerPicture_Without_Photo_When_Photo_Isnt_HttpPostedFile()
        {
            //Arrange
            int customerId = 15;

            SValueProviderResult photoResult = new SValueProviderResult(null, "AAA", null);
            photoResult.ConvertToTypeCultureInfo = (type, culture) => null;
            IValueProvider provider = new SIValueProvider()
            {
                
                ContainsPrefixString = x => x.StartsWith("CustomerPicture.Photo") || x.StartsWith("CustomerPicture.CustomerId") || x.Equals("CustomerPicture"),
                GetValueString = x =>
                {
                    switch (x)
                    {
                        case "CustomerPicture.Photo":
                            return photoResult;
                        case "CustomerPicture.CustomerId":
                            return new ValueProviderResult(15, "15", null);
                        default:
                            return null;
                    }
                }
            };
            
            ModelMetadata metadata = ModelMetadataProviders.Current.GetMetadataForType(null, typeof(CustomerPicture));
            CustomerPictureModelBinder binder = new CustomerPictureModelBinder();
            ControllerContext context = new ControllerContext();

            ModelBindingContext bindingContext = new ModelBindingContext()
            {
                ModelName = "CustomerPicture",
                ValueProvider = provider,
                ModelMetadata = metadata
            };

            //Act
            CustomerPicture result = binder.BindModel(context, bindingContext) as CustomerPicture;


            //Assert
            Assert.AreEqual(customerId, result.CustomerId);
            Assert.IsNull(result.Customer);
            Assert.IsNull(result.Photo);
        }