Esempio n. 1
0
        public async Task BindModelAsync_DataFormatIsInvalid_ContextResultModelIsNull()
        {
            // Arrange
            _mockValueProvider.Setup(m => m.GetValue("order")).Returns(new ValueProviderResult("size"));

            var context = CreateModelBindingContext(_mockValueProvider.Object);
            var binder  = new OrderCriteriaModelBinder();

            // Act
            await binder.BindModelAsync(context);

            // Assert
            var resultModel = context.Result.Model as Order;

            Assert.Null(resultModel);
        }
Esempio n. 2
0
        public async Task BindModelAsync_DataFormatIsEmpty_ContextResultModelHasDefaulOrder()
        {
            // Arrange
            _mockValueProvider.Setup(m => m.GetValue("order")).Returns(new ValueProviderResult(""));

            var context = CreateModelBindingContext(_mockValueProvider.Object);
            var binder  = new OrderCriteriaModelBinder();

            // Act
            await binder.BindModelAsync(context);

            // Assert
            var resultModel = context.Result.Model as Order;

            Assert.Equal("Name", resultModel?.Field);
            Assert.Equal(false, resultModel?.IsDesc);
        }