public async Task ContainsPrefixAsync_WithNonEmptyCollection_ReturnsTrueForKnownPrefixes() { // Arrange var valueProvider = new ReadableStringCollectionValueProvider <TestValueProviderMetadata>(_backingStore, null); // Act & Assert Assert.True(await valueProvider.ContainsPrefixAsync("foo")); Assert.True(await valueProvider.ContainsPrefixAsync("bar")); Assert.True(await valueProvider.ContainsPrefixAsync("bar.baz")); }
public async Task ContainsPrefixAsync_WithNonEmptyCollection_ReturnsTrueForKnownPrefixes() { // Arrange var valueProvider = new ReadableStringCollectionValueProvider(BindingSource.Query, _backingStore, null); // Act & Assert Assert.True(await valueProvider.ContainsPrefixAsync("foo")); Assert.True(await valueProvider.ContainsPrefixAsync("bar")); Assert.True(await valueProvider.ContainsPrefixAsync("bar.baz")); }
public async Task ContainsPrefixAsync_WithNonEmptyCollection_ReturnsTrueForEmptyPrefix() { // Arrange var valueProvider = new ReadableStringCollectionValueProvider(_backingStore, null); // Act var result = await valueProvider.ContainsPrefixAsync(""); // Assert Assert.True(result); }
public async Task ContainsPrefixAsync_WithNonEmptyCollection_ReturnsTrueForEmptyPrefix() { // Arrange var valueProvider = new ReadableStringCollectionValueProvider(BindingSource.Query, _backingStore, null); // Act var result = await valueProvider.ContainsPrefixAsync(""); // Assert Assert.True(result); }
public async Task ContainsPrefixAsync_WithNonEmptyCollection_ReturnsFalseForUnknownPrefix() { // Arrange var valueProvider = new ReadableStringCollectionValueProvider <TestValueProviderMetadata>(_backingStore, null); // Act var result = await valueProvider.ContainsPrefixAsync("biff"); // Assert Assert.False(result); }
public async Task GetValueAsync_ReturnsNullIfKeyNotFound() { // Arrange var valueProvider = new ReadableStringCollectionValueProvider <TestValueProviderMetadata>(_backingStore, null); // Act var vpResult = await valueProvider.GetValueAsync("bar"); // Assert Assert.Null(vpResult); }
public async Task GetKeysFromPrefixAsync_UnknownPrefix_ReturnsEmptyDictionary() { // Arrange var valueProvider = new ReadableStringCollectionValueProvider <TestValueProviderMetadata>(_backingStore, null); // Act var result = await valueProvider.GetKeysFromPrefixAsync("abc"); // Assert Assert.Empty(result); }
public async Task ContainsPrefixAsync_WithNonEmptyCollection_ReturnsFalseForUnknownPrefix() { // Arrange var valueProvider = new ReadableStringCollectionValueProvider(BindingSource.Query, _backingStore, null); // Act var result = await valueProvider.ContainsPrefixAsync("biff"); // Assert Assert.False(result); }
public async Task ContainsPrefixAsync_WithEmptyCollection_ReturnsFalseForEmptyPrefix() { // Arrange var backingStore = new ReadableStringCollection(new Dictionary <string, string[]>()); var valueProvider = new ReadableStringCollectionValueProvider <TestValueProviderMetadata>(backingStore, null); // Act var result = await valueProvider.ContainsPrefixAsync(""); // Assert Assert.False(result); }
public void FilterReturnsItself_ForAnyClassRegisteredAsGenericParam(IValueProviderMetadata metadata) { // Arrange var valueProvider = new ReadableStringCollectionValueProvider <TestValueProviderMetadata>(_backingStore, null); // Act var result = valueProvider.Filter(metadata); // Assert Assert.NotNull(result); Assert.IsType <ReadableStringCollectionValueProvider <TestValueProviderMetadata> >(result); }
public async Task GetValue_NullValue(string key) { // Arrange var culture = new CultureInfo("fr-FR"); var valueProvider = new ReadableStringCollectionValueProvider <TestValueProviderMetadata>(_backingStore, culture); // Act var result = await valueProvider.GetValueAsync(key); // Assert Assert.Null(result); }
public async Task ContainsPrefixAsync_WithEmptyCollection_ReturnsFalseForEmptyPrefix() { // Arrange var backingStore = new ReadableStringCollection(new Dictionary<string, string[]>()); var valueProvider = new ReadableStringCollectionValueProvider(BindingSource.Query, backingStore, null); // Act var result = await valueProvider.ContainsPrefixAsync(""); // Assert Assert.False(result); }
public async Task GetKeysFromPrefixAsync_KnownPrefix_ReturnsMatchingItems() { // Arrange var valueProvider = new ReadableStringCollectionValueProvider <TestValueProviderMetadata>(_backingStore, null); // Act var result = await valueProvider.GetKeysFromPrefixAsync("bar"); // Assert var kvp = Assert.Single(result); Assert.Equal("baz", kvp.Key); Assert.Equal("bar.baz", kvp.Value); }
public async Task GetValueAsync_MultiValue() { // Arrange var culture = new CultureInfo("fr-FR"); var valueProvider = new ReadableStringCollectionValueProvider <TestValueProviderMetadata>(_backingStore, culture); // Act var vpResult = await valueProvider.GetValueAsync("foo"); // Assert Assert.NotNull(vpResult); Assert.Equal(new[] { "fooValue1", "fooValue2" }, (IList <string>)vpResult.RawValue); Assert.Equal("fooValue1,fooValue2", vpResult.AttemptedValue); Assert.Equal(culture, vpResult.Culture); }
public async Task GetValueAsync_SingleValue() { // Arrange var culture = new CultureInfo("fr-FR"); var valueProvider = new ReadableStringCollectionValueProvider <TestValueProviderMetadata>(_backingStore, culture); // Act var vpResult = await valueProvider.GetValueAsync("bar.baz"); // Assert Assert.NotNull(vpResult); Assert.Equal("someOtherValue", vpResult.RawValue); Assert.Equal("someOtherValue", vpResult.AttemptedValue); Assert.Equal(culture, vpResult.Culture); }
public void FilterExclude() { // Arrange var provider = new ReadableStringCollectionValueProvider(BindingSource.Query, _backingStore, null); var bindingSource = new BindingSource( "Test", displayName: null, isGreedy: true, isFromRequest: true); // Act var result = provider.Filter(bindingSource); // Assert Assert.Null(result); }
public async Task GetKeysFromPrefixAsync_EmptyPrefix_ReturnsAllPrefixes() { // Arrange var expected = new Dictionary <string, string> { { "bar", "bar" }, { "foo", "foo" }, { "null_value", "null_value" }, { "prefix", "prefix" } }; var valueProvider = new ReadableStringCollectionValueProvider <TestValueProviderMetadata>(_backingStore, culture: null); // Act var result = await valueProvider.GetKeysFromPrefixAsync(""); // Assert Assert.Equal(expected, result.OrderBy(kvp => kvp.Key)); }
public async Task GetValueAsync_NullMultipleValue() { // Arrange var backingStore = new ReadableStringCollection( new Dictionary <string, string[]> { { "key", new string[] { null, null, "value" } } }); var culture = new CultureInfo("fr-FR"); var valueProvider = new ReadableStringCollectionValueProvider <TestValueProviderMetadata>(backingStore, culture); // Act var vpResult = await valueProvider.GetValueAsync("key"); // Assert Assert.Equal(new[] { null, null, "value" }, vpResult.RawValue as IEnumerable <string>); Assert.Equal(",,value", vpResult.AttemptedValue); }
public async Task GetKeysFromPrefixAsync_UnknownPrefix_ReturnsEmptyDictionary() { // Arrange var valueProvider = new ReadableStringCollectionValueProvider(BindingSource.Query, _backingStore, null); // Act var result = await valueProvider.GetKeysFromPrefixAsync("abc"); // Assert Assert.Empty(result); }
public async Task GetKeysFromPrefixAsync_EmptyPrefix_ReturnsAllPrefixes() { // Arrange var expected = new Dictionary<string, string> { { "bar", "bar" }, { "foo", "foo" }, { "null_value", "null_value" }, { "prefix", "prefix" } }; var valueProvider = new ReadableStringCollectionValueProvider(BindingSource.Query, _backingStore, culture: null); // Act var result = await valueProvider.GetKeysFromPrefixAsync(""); // Assert Assert.Equal(expected, result.OrderBy(kvp => kvp.Key)); }
public void FilterExclude() { // Arrange var provider = new ReadableStringCollectionValueProvider(BindingSource.Query, _backingStore, null); var bindingSource = new BindingSource( "Test", displayName: null, isGreedy: true, isFromRequest: true); // Act var result = provider.Filter(bindingSource); // Assert Assert.Null(result); }
public async Task GetKeysFromPrefixAsync_KnownPrefix_ReturnsMatchingItems() { // Arrange var valueProvider = new ReadableStringCollectionValueProvider(BindingSource.Query, _backingStore, null); // Act var result = await valueProvider.GetKeysFromPrefixAsync("bar"); // Assert var kvp = Assert.Single(result); Assert.Equal("baz", kvp.Key); Assert.Equal("bar.baz", kvp.Value); }
public async Task GetValueAsync_ReturnsNullIfKeyNotFound() { // Arrange var valueProvider = new ReadableStringCollectionValueProvider(BindingSource.Query, _backingStore, null); // Act var vpResult = await valueProvider.GetValueAsync("bar"); // Assert Assert.Null(vpResult); }
public async Task GetValueAsync_NullMultipleValue() { // Arrange var backingStore = new ReadableStringCollection( new Dictionary<string, string[]> { { "key", new string[] { null, null, "value" } } }); var culture = new CultureInfo("fr-FR"); var valueProvider = new ReadableStringCollectionValueProvider(BindingSource.Query, backingStore, culture); // Act var vpResult = await valueProvider.GetValueAsync("key"); // Assert Assert.Equal(new[] { null, null, "value" }, vpResult.RawValue as IEnumerable<string>); Assert.Equal(",,value", vpResult.AttemptedValue); }
public async Task GetValue_NullValue(string key) { // Arrange var culture = new CultureInfo("fr-FR"); var valueProvider = new ReadableStringCollectionValueProvider(BindingSource.Query, _backingStore, culture); // Act var result = await valueProvider.GetValueAsync(key); // Assert Assert.Null(result); }
public async Task GetValueAsync_MultiValue() { // Arrange var culture = new CultureInfo("fr-FR"); var valueProvider = new ReadableStringCollectionValueProvider(BindingSource.Query, _backingStore, culture); // Act var vpResult = await valueProvider.GetValueAsync("foo"); // Assert Assert.NotNull(vpResult); Assert.Equal(new[] { "fooValue1", "fooValue2" }, (IList<string>)vpResult.RawValue); Assert.Equal("fooValue1,fooValue2", vpResult.AttemptedValue); Assert.Equal(culture, vpResult.Culture); }
public async Task GetValueAsync_SingleValue() { // Arrange var culture = new CultureInfo("fr-FR"); var valueProvider = new ReadableStringCollectionValueProvider(BindingSource.Query, _backingStore, culture); // Act var vpResult = await valueProvider.GetValueAsync("bar.baz"); // Assert Assert.NotNull(vpResult); Assert.Equal("someOtherValue", vpResult.RawValue); Assert.Equal("someOtherValue", vpResult.AttemptedValue); Assert.Equal(culture, vpResult.Culture); }