public void BindModelThrowsIfBindingContextIsNull() { // Arrange LinqBinaryModelBinder binder = new LinqBinaryModelBinder(); // Act & assert Assert.ThrowsArgumentNull( delegate { binder.BindModel(null, null); }, "bindingContext"); }
public void BindModelThrowsIfBindingContextIsNull() { // Arrange LinqBinaryModelBinder binder = new LinqBinaryModelBinder(); // Act & assert ExceptionHelper.ExpectArgumentNullException( delegate { binder.BindModel(null, null); }, "bindingContext"); }
public void BinderWithEmptyStringValueReturnsNull() { // Arrange ValueProviderDictionary valueProvider = new ValueProviderDictionary(null) { { "foo", new ValueProviderResult(String.Empty, null, null) } }; ModelBindingContext bindingContext = new ModelBindingContext() { ModelName = "foo", ValueProvider = valueProvider }; LinqBinaryModelBinder binder = new LinqBinaryModelBinder(); // Act object binderResult = binder.BindModel(null, bindingContext); // Assert Assert.IsNull(binderResult); }
public void BindModelWithBase64QuotedValueReturnsBinary() { // Arrange string base64Value = ByteArrayModelBinderTest.Base64TestString; ValueProviderDictionary valueProvider = new ValueProviderDictionary(null) { { "foo", new ValueProviderResult("\"" + base64Value + "\"", "\"" + base64Value + "\"", null) } }; ModelBindingContext bindingContext = new ModelBindingContext() { ModelName = "foo", ValueProvider = valueProvider }; LinqBinaryModelBinder binder = new LinqBinaryModelBinder(); // Act Binary boundValue = binder.BindModel(null, bindingContext) as Binary; // Assert Assert.AreEqual(ByteArrayModelBinderTest.Base64TestBytes, boundValue); }
public void BinderWithEmptyStringValueReturnsNull() { // Arrange SimpleValueProvider valueProvider = new SimpleValueProvider() { { "foo", "" } }; ModelBindingContext bindingContext = new ModelBindingContext() { ModelName = "foo", ValueProvider = valueProvider }; LinqBinaryModelBinder binder = new LinqBinaryModelBinder(); // Act object binderResult = binder.BindModel(null, bindingContext); // Assert Assert.Null(binderResult); }
public void BindModelWithBase64UnquotedValueReturnsBinary() { // Arrange string base64Value = ByteArrayModelBinderTest.Base64TestString; SimpleValueProvider valueProvider = new SimpleValueProvider() { { "foo", base64Value } }; ModelBindingContext bindingContext = new ModelBindingContext() { ModelName = "foo", ValueProvider = valueProvider }; LinqBinaryModelBinder binder = new LinqBinaryModelBinder(); // Act Binary boundValue = binder.BindModel(null, bindingContext) as Binary; // Assert Assert.Equal(ByteArrayModelBinderTest.Base64TestBytes, boundValue); }