public async Task ServiceModelBinder_ReturnsNoResult_ForNonServiceBindingSource() { // Arrange var type = typeof(IService); var binder = new ServicesModelBinder(); var modelBindingContext = GetBindingContext(type); modelBindingContext.BindingSource = BindingSource.Body; // Act var result = await binder.BindModelAsync(modelBindingContext); // Assert Assert.Equal(ModelBindingResult.NoResult, result); }
public async Task ServiceModelBinder_BindsService() { // Arrange var type = typeof(IService); var binder = new ServicesModelBinder(); var modelBindingContext = GetBindingContext(type); // Act var result = await binder.BindModelAsync(modelBindingContext); // Assert Assert.NotEqual(ModelBindingResult.NoResult, result); Assert.True(result.IsModelSet); Assert.NotNull(result.Model); Assert.Equal("modelName", result.Key); var entry = modelBindingContext.ValidationState[result.Model]; Assert.True(entry.SuppressValidation); Assert.Null(entry.Key); Assert.Null(entry.Metadata); }