Esempio n. 1
0
        public async Task GetValueProvider_ReturnsNull_WhenContentTypeIsNotFormUrlEncoded()
        {
            // Arrange
            var context = CreateContext("some-content-type", formValues: null);
            var factory = new JQueryFormValueProviderFactory();

            // Act
            await factory.CreateValueProviderAsync(context);

            // Assert
            Assert.Empty(context.ValueProviders);
        }
        public async Task GetValueProvider_ReturnsNull_WhenContentTypeIsNotFormUrlEncoded()
        {
            // Arrange
            var context = CreateContext("some-content-type", formValues: null);
            var factory = new JQueryFormValueProviderFactory();

            // Act
            await factory.CreateValueProviderAsync(context);

            // Assert
            Assert.Empty(context.ValueProviders);
        }
        public async Task CreateValueProviderAsync_ReturnsValueProvider_WithCurrentCulture(string contentType)
        {
            // Arrange
            var context = CreateContext(contentType, formValues: null);
            var factory = new JQueryFormValueProviderFactory();

            // Act
            await factory.CreateValueProviderAsync(context);

            // Assert
            var valueProvider = Assert.IsType<JQueryFormValueProvider>(Assert.Single(context.ValueProviders));
            Assert.Equal(CultureInfo.CurrentCulture, valueProvider.Culture);
        }
    public async Task GetValueProviderAsync_ThrowsOriginalException_IfReadingFormThrows()
    {
        // Arrange
        var exception            = new TimeZoneNotFoundException();
        var valueProviderContext = CreateThrowingContext(exception);

        var factory = new JQueryFormValueProviderFactory();

        // Act & Assert
        var ex = await Assert.ThrowsAsync <TimeZoneNotFoundException>(() => factory.CreateValueProviderAsync(valueProviderContext));

        Assert.Same(exception, ex);
    }
    public async Task GetValueProviderAsync_ThrowsValueProviderException_IfReadingFormThrowsInvalidOperationException()
    {
        // Arrange
        var exception            = new IOException();
        var valueProviderContext = CreateThrowingContext(exception);

        var factory = new JQueryFormValueProviderFactory();

        // Act & Assert
        var ex = await Assert.ThrowsAsync <ValueProviderException>(() => factory.CreateValueProviderAsync(valueProviderContext));

        Assert.Same(exception, ex.InnerException);
    }
Esempio n. 6
0
        public async Task CreateValueProviderAsync_ReturnsValueProvider_WithCurrentCulture(string contentType)
        {
            // Arrange
            var context = CreateContext(contentType, formValues: null);
            var factory = new JQueryFormValueProviderFactory();

            // Act
            await factory.CreateValueProviderAsync(context);

            // Assert
            var valueProvider = Assert.IsType <JQueryFormValueProvider>(Assert.Single(context.ValueProviders));

            Assert.Equal(CultureInfo.CurrentCulture, valueProvider.Culture);
        }
Esempio n. 7
0
        public async Task GetValueProvider_ReturnsValueProvider_ContainingExpectedKeys(string key)
        {
            // Arrange
            var context = CreateContext("application/x-www-form-urlencoded", formValues: _backingStore);
            var factory = new JQueryFormValueProviderFactory();

            // Act
            await factory.CreateValueProviderAsync(context);

            // Assert
            var valueProvider = Assert.Single(context.ValueProviders);
            var result        = valueProvider.GetValue(key);

            Assert.Equal("found", (string)result);
        }
    public async Task CreatesValueProvider_WithCurrentCulture()
    {
        // Arrange
        var context = CreateContext("application/x-www-form-urlencoded", formValues: _backingStore);
        var factory = new JQueryFormValueProviderFactory();

        // Act
        await factory.CreateValueProviderAsync(context);

        // Assert
        var valueProvider           = Assert.Single(context.ValueProviders);
        var jqueryFormValueProvider = Assert.IsType <JQueryFormValueProvider>(valueProvider);

        Assert.Equal(CultureInfo.CurrentCulture, jqueryFormValueProvider.Culture);
    }
        public async Task GetValueProvider_ReturnsValueProvider_ContainingExpectedKeys(string key)
        {
            // Arrange
            var context = CreateContext("application/x-www-form-urlencoded", formValues: _backingStore);
            var factory = new JQueryFormValueProviderFactory();

            // Act
            await factory.CreateValueProviderAsync(context);

            // Assert
            var valueProvider = Assert.Single(context.ValueProviders);
            var result = valueProvider.GetValue(key);
            Assert.Equal("found", (string)result);
        }