public async Task CancellationTokenModelBinder_ReturnsNull_ForNonCancellationTokenType(Type t)
        {
            // Arrange
            var bindingContext = GetBindingContext(t);
            var binder = new CancellationTokenModelBinder();

            // Act
            var result = await binder.BindModelAsync(bindingContext);

            // Assert
            Assert.Null(result);
        }
        public async Task CancellationTokenModelBinder_ReturnsFalse_ForNonCancellationTokenType(Type t)
        {
            // Arrange
            var bindingContext = GetBindingContext(t);
            var binder         = new CancellationTokenModelBinder();

            // Act
            var bound = await binder.BindModelAsync(bindingContext);

            // Assert
            Assert.Null(bound);
        }
        public async Task CancellationTokenModelBinder_ReturnsNull_ForNonCancellationTokenType(Type t)
        {
            // Arrange
            var bindingContext = GetBindingContext(t);
            var binder         = new CancellationTokenModelBinder();

            // Act
            var result = await binder.BindModelAsync(bindingContext);

            // Assert
            Assert.Equal(ModelBindingResult.NoResult, result);
        }
Exemple #4
0
    public async Task CancellationTokenModelBinder_ReturnsNonEmptyResult_ForCancellationTokenType()
    {
        // Arrange
        var bindingContext = GetBindingContext(typeof(CancellationToken));
        var binder         = new CancellationTokenModelBinder();

        // Act
        await binder.BindModelAsync(bindingContext);

        // Assert
        Assert.True(bindingContext.Result.IsModelSet);
        Assert.Equal(bindingContext.HttpContext.RequestAborted, bindingContext.Result.Model);
    }
        public async Task CancellationTokenModelBinder_ReturnsTrue_ForCancellationTokenType()
        {
            // Arrange
            var bindingContext = GetBindingContext(typeof(CancellationToken));
            var binder         = new CancellationTokenModelBinder();

            // Act
            var bound = await binder.BindModelAsync(bindingContext);

            // Assert
            Assert.NotNull(bound);
            Assert.Equal(bindingContext.OperationBindingContext.HttpContext.RequestAborted, bound.Model);
        }
        public async Task CancellationTokenModelBinder_ReturnsNotNull_ForCancellationTokenType()
        {
            // Arrange
            var bindingContext = GetBindingContext(typeof(CancellationToken));
            var binder = new CancellationTokenModelBinder();

            // Act
            var bound = await binder.BindModelAsync(bindingContext);

            // Assert
            Assert.NotNull(bound);
            Assert.Equal(bindingContext.OperationBindingContext.HttpContext.RequestAborted, bound.Model);
        }
        public async Task CancellationTokenModelBinder_ReturnsNonEmptyResult_ForCancellationTokenType()
        {
            // Arrange
            var bindingContext = GetBindingContext(typeof(CancellationToken));
            var binder = new CancellationTokenModelBinder();

            // Act
            var result = await binder.BindModelAsync(bindingContext);

            // Assert
            Assert.NotEqual(ModelBindingResult.NoResult, result);
            Assert.True(result.IsModelSet);
            Assert.Equal(bindingContext.OperationBindingContext.HttpContext.RequestAborted, result.Model);
        }
Exemple #8
0
        public async Task CancellationTokenModelBinder_ReturnsNotNull_ForCancellationTokenType()
        {
            // Arrange
            var bindingContext = GetBindingContext(typeof(CancellationToken));
            var binder         = new CancellationTokenModelBinder();

            // Act
            var result = await binder.BindModelAsync(bindingContext);

            // Assert
            Assert.NotNull(result);
            Assert.True(result.IsModelSet);
            Assert.Equal(bindingContext.OperationBindingContext.HttpContext.RequestAborted, result.Model);
            Assert.NotNull(result.ValidationNode);
            Assert.True(result.ValidationNode.SuppressValidation);
        }