public void DefaultBooleanValue_Add(bool value, object otherVal, bool throwsException) { DefaultValueProvider <G> valueProvider = new DefaultValueProvider <G>(); DefaultBooleanValue <G> sut = new DefaultBooleanValue <G>(value); IValue <G> newValue = null; Action action = () => { newValue = (IValue <G>)sut.Add(valueProvider.GetAsValue(otherVal), valueProvider); }; if (throwsException) { Assert.Throws <EngineRuntimeException>(action); } else { action(); } if (!throwsException) { switch (otherVal) { case string stringVal: Assert.Equal(value.ToString().ToLower() + stringVal, newValue.GetData()); break; case null: Assert.Equal(sut, newValue); break; } } }
public void DefaultCollectionValue_Get_OnNonMapItemExists(bool create) { DefaultIntValue <G> key = new DefaultIntValue <G>(3); IValuable <G> value = Mock.Of <IValuable <G> >(); DefaultValueProvider <G> valueProvider = new DefaultValueProvider <G>(); Dictionary <IValuable <G>, ValuePointer <G> > values = new Dictionary <IValuable <G>, ValuePointer <G> >() { { new DefaultIntValue <G>(0), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(1), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(2), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { key, new ValuePointer <G> { Value = value } }, { new DefaultIntValue <G>(4), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(5), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } } }; DefaultArrayMapValue <G> sut = new DefaultArrayMapValue <G>(values, valueProvider); EntryValuePointer <G> result = sut.Get(key, create, valueProvider) as EntryValuePointer <G>; Assert.False(sut.IsMap); Assert.Equal(key, result.Key); Assert.Equal(value, result.Value); Assert.Equal(3, result.Index); Assert.True(result.IsSet); }
public void DefaultCollectionValue_Get_OnNonMapItemNotExistsCreateEntry(int keyVal, bool isMap) { DefaultIntValue <G> key = new DefaultIntValue <G>(keyVal); DefaultValueProvider <G> valueProvider = new DefaultValueProvider <G>(); Dictionary <IValuable <G>, ValuePointer <G> > values = new Dictionary <IValuable <G>, ValuePointer <G> >() { { new DefaultIntValue <G>(0), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(1), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(2), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(3), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(4), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(5), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } } }; DefaultArrayMapValue <G> sut = new DefaultArrayMapValue <G>(values, valueProvider); EntryValuePointer <G> result = sut.Get(key, true, valueProvider) as EntryValuePointer <G>; Assert.Equal(isMap, sut.IsMap); Assert.Equal(key, result.Key); Assert.Null(result.Value); Assert.Equal(6, result.Index); Assert.False(result.IsSet); }
public void DefaultCollectionValue_Remove_ValueOnMap() { DefaultValueProvider <G> valueProvider = new DefaultValueProvider <G>(); Dictionary <IValuable <G>, ValuePointer <G> > values = new Dictionary <IValuable <G>, ValuePointer <G> >() { { new DefaultDoubleValue <G>(0), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(1), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultDoubleValue <G>(2), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultLongValue <G>(4), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(5), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultLongValue <G>(3), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } } }; DefaultArrayMapValue <G> sut = new DefaultArrayMapValue <G>(values, valueProvider); sut.Remove(new DefaultLongValue <G>(4), valueProvider); Assert.Equal(values.Values.Take(3).Concat(values.Values.Skip(4).Take(2)).Select(vp => vp.Value), sut.GetValues().Select(vp => vp.Value)); Assert.Equal(values.Keys.Take(3).Concat(values.Keys.Skip(4).Take(2)), sut.GetKeys()); Assert.Equal(Enumerable.Range(0, 5), sut.GetValues().Cast <EntryValuePointer <G> >().Select(v => v.Index)); }
public void DefaultCollectionValue_FinalizeEntry_EntryAdd() { DefaultValueProvider <G> valueProvider = new DefaultValueProvider <G>(); Dictionary <IValuable <G>, ValuePointer <G> > values = new Dictionary <IValuable <G>, ValuePointer <G> >() { { new DefaultDoubleValue <G>(0), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(1), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultDoubleValue <G>(2), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultLongValue <G>(4), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(5), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultLongValue <G>(3), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } } }; DefaultArrayMapValue <G> sut = new DefaultArrayMapValue <G>(values, valueProvider); EntryValuePointer <G> entryPointer = new EntryValuePointer <G>(sut, new DefaultLongValue <G>(34), 6, valueProvider); sut.FinalizeEntry(new DefaultLongValue <G>(34), entryPointer); Assert.Equal(7, sut.Size); KeyValuePair <IValuable <G>, ValuePointer <G> > item = sut.GetEntries()[6]; Assert.Equal(entryPointer.Key, item.Key); Assert.Equal(entryPointer, item.Value); }
public void DefaultCollectionValue_KeyOf_NotPresent() { DefaultValueProvider <G> valueProvider = new DefaultValueProvider <G>(); IValuable <G> value = Mock.Of <IValuable <G> >(); Dictionary <IValuable <G>, ValuePointer <G> > values = new Dictionary <IValuable <G>, ValuePointer <G> >() { { new DefaultDoubleValue <G>(0), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(1), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultDoubleValue <G>(2), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultLongValue <G>(4), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(5), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultLongValue <G>(3), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } } }; DefaultArrayMapValue <G> sut = new DefaultArrayMapValue <G>(values, valueProvider); IValuable <G> result = sut.KeyOf(value, valueProvider); Assert.Null(result); }
public void DefaultCollectionValue_Add_NonMapCollection() { DefaultValueProvider <G> valueProvider = new DefaultValueProvider <G>(); Dictionary <IValuable <G>, ValuePointer <G> > firstValues = new Dictionary <IValuable <G>, ValuePointer <G> >() { { new DefaultIntValue <G>(0), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(1), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(2), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, }; Dictionary <IValuable <G>, ValuePointer <G> > secondValues = new Dictionary <IValuable <G>, ValuePointer <G> >() { { new DefaultIntValue <G>(0), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(1), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(2), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } } }; DefaultCollectionValue <G> otherCollection = new DefaultArrayMapValue <G>(secondValues, valueProvider) as DefaultCollectionValue <G>; DefaultArrayMapValue <G> sut = new DefaultArrayMapValue <G>(firstValues, valueProvider); EngineRuntimeException exception = Assert.Throws <EngineRuntimeException>(() => sut.Add(otherCollection, valueProvider) as DefaultCollectionValue <G>); Assert.Equal("Invalid values for addition", exception.Message); }
public void DefaultCollectionValue_ContainsKey_Unordered(object key, bool contains) { DefaultValueProvider <G> valueProvider = new DefaultValueProvider <G>(); Dictionary <IValuable <G>, ValuePointer <G> > values = new Dictionary <IValuable <G>, ValuePointer <G> >() { { new DefaultDoubleValue <G>(0), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(1), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultDoubleValue <G>(2), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultLongValue <G>(4), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(5), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(3), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } } }; DefaultArrayMapValue <G> sut = new DefaultArrayMapValue <G>(values, valueProvider); bool result = sut.ContainsKey(key.GetAsValue(), valueProvider); Assert.Equal(contains, result); }
public void DefaultCollectionValue_ContainsValue_Present() { DefaultValueProvider <G> valueProvider = new DefaultValueProvider <G>(); IValuable <G> value = Mock.Of <IValuable <G> >(); Dictionary <IValuable <G>, ValuePointer <G> > values = new Dictionary <IValuable <G>, ValuePointer <G> >() { { new DefaultDoubleValue <G>(0), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(1), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultDoubleValue <G>(2), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultLongValue <G>(4), new ValuePointer <G> { Value = value } }, { new DefaultIntValue <G>(5), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultLongValue <G>(3), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } } }; DefaultArrayMapValue <G> sut = new DefaultArrayMapValue <G>(values, valueProvider); bool result = sut.ContainsValue(value, valueProvider); Assert.True(result); }
public void DefaultCollectionValue_GetAt() { DefaultValueProvider <G> valueProvider = new DefaultValueProvider <G>(); IValuable <G> value = Mock.Of <IValuable <G> >(); Dictionary <IValuable <G>, ValuePointer <G> > values = new Dictionary <IValuable <G>, ValuePointer <G> >() { { new DefaultDoubleValue <G>(0), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(1), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultDoubleValue <G>(2), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultLongValue <G>(4), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(5), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultLongValue <G>(3), new ValuePointer <G> { Value = value } } }; DefaultArrayMapValue <G> sut = new DefaultArrayMapValue <G>(values, valueProvider); ValuePointer <G> result = sut.GetAt(new DefaultIntValue <G>(5), valueProvider); Assert.Equal(value, result.Value); }
public void DefaultCollectionValue_GetKeys_Ordered() { DefaultValueProvider <G> valueProvider = new DefaultValueProvider <G>(); Dictionary <IValuable <G>, ValuePointer <G> > values = new Dictionary <IValuable <G>, ValuePointer <G> >() { { new DefaultIntValue <G>(0), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(1), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(2), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(3), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(4), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(5), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } } }; DefaultArrayMapValue <G> sut = new DefaultArrayMapValue <G>(values, valueProvider); List <IValuable <G> > result = sut.GetKeys(); Assert.Equal(values.Keys, result); }
public void DefaultStringValue_Add_MapCollection() { string value = "hello"; DefaultValueProvider <G> valueProvider = new DefaultValueProvider <G>(); Dictionary <IValuable <G>, ValuePointer <G> > collectionValues = new Dictionary <IValuable <G>, ValuePointer <G> >() { { new DefaultIntValue <G>(3), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(4), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(5), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, }; DefaultArrayMapValue <G> collectionValue = new DefaultArrayMapValue <G>(collectionValues, valueProvider); DefaultStringValue <G> sut = new DefaultStringValue <G>(value); Assert.Throws <EngineRuntimeException>(() => { sut.Add(collectionValue, valueProvider); }); }
public void DefaultForTaskOfEnumIsDefaultValue() { var value = new DefaultValueProvider().GetDefault <Task <PlatformID> >(); Assert.NotNull(value); Assert.True(value.IsCompleted); Assert.Equal(default, value.Result);
public async Task DefaultForValueTaskTIsCompleted() { var value = new DefaultValueProvider().GetDefault <ValueTask <bool> >(); Assert.True(value.IsCompleted); Assert.False(await value); }
public void DefaultCollectionValue_GetEntries_FromUnorderedEntriesListConstructor() { DefaultValueProvider <G> valueProvider = new DefaultValueProvider <G>(); Dictionary <IValuable <G>, ValuePointer <G> > values = new Dictionary <IValuable <G>, ValuePointer <G> >() { { new DefaultDoubleValue <G>(0), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(1), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultDoubleValue <G>(2), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultLongValue <G>(4), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(5), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultLongValue <G>(3), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } } }; DefaultArrayMapValue <G> sut = new DefaultArrayMapValue <G>(values, valueProvider); List <KeyValuePair <IValuable <G>, ValuePointer <G> > > result = sut.GetEntries(); Assert.Equal(new object[] { 0.0, 1, 2.0, 4L, 5, 3L }, result.Select(kv => kv.Key).Cast <IValue>().Select(v => v.GetData())); Assert.Equal(values.Values.Select(v => v.Value), result.Select(kv => kv.Value).Select(vp => vp.Value)); Assert.True(sut.IsMap); Assert.Equal(Enumerable.Range(0, 6), result.Select(e => e.Value).Cast <EntryValuePointer <G> >().Select(v => v.Index)); }
public void DefaultCollectionValue_Get_OnNonMapItemNotExistsNoCreate() { DefaultLongValue <G> key = new DefaultLongValue <G>(20); DefaultValueProvider <G> valueProvider = new DefaultValueProvider <G>(); Dictionary <IValuable <G>, ValuePointer <G> > values = new Dictionary <IValuable <G>, ValuePointer <G> >() { { new DefaultIntValue <G>(0), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(1), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(2), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(3), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(4), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(5), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } } }; DefaultArrayMapValue <G> sut = new DefaultArrayMapValue <G>(values, valueProvider); EntryValuePointer <G> result = sut.Get(key, false, valueProvider) as EntryValuePointer <G>; Assert.False(sut.IsMap); Assert.Null(result); }
public void DefaultActionValue_Add(object otherVal, bool throwsException) { G groupState = Mock.Of <G>(); DefaultValueProvider <G> valueProvider = new DefaultValueProvider <G>(); DefaultActionValue <G> sut = new DefaultActionValue <G>(groupState, 10); IValuable <G> newValue = null; Action action = () => { newValue = sut.Add(valueProvider.GetAsValue(otherVal), valueProvider); }; if (throwsException) { Assert.Throws <EngineRuntimeException>(action); } else { action(); } if (!throwsException) { switch (otherVal) { case null: Assert.Equal(sut, newValue); break; } } }
public void DefaultActionValue_Add_NonMapCollection() { int location = 10; G groupState = Mock.Of <G>(); DefaultValueProvider <G> valueProvider = new DefaultValueProvider <G>(); Dictionary <IValuable <G>, ValuePointer <G> > collectionValues = new Dictionary <IValuable <G>, ValuePointer <G> >() { { new DefaultIntValue <G>(0), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(1), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(2), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } } }; ICollectionValue <G> collectionValue = valueProvider.GetCollection(collectionValues, null); DefaultActionValue <G> sut = new DefaultActionValue <G>(groupState, location); DefaultCollectionValue <G> result = (DefaultCollectionValue <G>)sut.Add(collectionValue, valueProvider); List <KeyValuePair <IValuable <G>, ValuePointer <G> > > entries = result.GetEntries(); Assert.Equal(Enumerable.Range(0, 4), entries.Select(kv => kv.Key).Cast <IValue>().Select(v => Convert.ToInt32(v.GetData()))); Assert.Equal(new IValuable <G>[] { sut }.Concat(collectionValues.Values.Select(v => v.Value)), entries.Select(kv => kv.Value).Select(vp => vp.Value)); Assert.False(result.IsMap); Assert.Equal(Enumerable.Range(0, 4), entries.Select(e => e.Value).Cast <EntryValuePointer <G> >().Select(v => v.Index)); }
public void DefaultBooleanValue_IsNotEqualTo(bool value, object otherVal, bool throwsException) { DefaultValueProvider <G> valueProvider = new DefaultValueProvider <G>(); DefaultBooleanValue <G> sut = new DefaultBooleanValue <G>(value); IValue <G> newValue = null; Action action = () => { newValue = (IValue <G>)sut.IsNotEqualTo(valueProvider.GetAsValue(otherVal), valueProvider); }; if (throwsException) { Assert.Throws <EngineRuntimeException>(action); } else { action(); } if (!throwsException) { switch (otherVal) { case bool boolVal: Assert.Equal(value != boolVal, newValue.GetData()); break; } } }
public void DefaultValueProvider_GetCollection_WithList() { ValuePointer <G>[] values = new ValuePointer <G>[] { new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() }, new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() }, new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() }, new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() }, new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() }, new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }; DefaultValueProvider <G> sut = new DefaultValueProvider <G>(); ICollectionValue <G> result = sut.GetCollection(values, null); Assert.Equal(6, result.Size); }
public void DefaultActionValue_Add_MapCollection() { int location = 10; G groupState = Mock.Of <G>(); DefaultValueProvider <G> valueProvider = new DefaultValueProvider <G>(); Dictionary <IValuable <G>, ValuePointer <G> > collectionValues = new Dictionary <IValuable <G>, ValuePointer <G> >() { { new DefaultIntValue <G>(3), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(4), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(5), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, }; DefaultArrayMapValue <G> collectionValue = new DefaultArrayMapValue <G>(collectionValues, valueProvider); DefaultActionValue <G> sut = new DefaultActionValue <G>(groupState, location); Assert.Throws <EngineRuntimeException>(() => { sut.Add(collectionValue, valueProvider); }); }
public void DefaultValueProvider_GetNull() { DefaultValueProvider <G> sut = new DefaultValueProvider <G>(); IValue <G> result = sut.GetNull(); Assert.Null(result.GetData()); }
public void DefaultValueProvider_GetCollection_WithEntries() { Dictionary <IValuable <G>, ValuePointer <G> > values = new Dictionary <IValuable <G>, ValuePointer <G> >() { { new DefaultIntValue <G>(0), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(1), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(2), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(3), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(4), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } }, { new DefaultIntValue <G>(5), new ValuePointer <G> { Value = Mock.Of <IValuable <G> >() } } }; DefaultValueProvider <G> sut = new DefaultValueProvider <G>(); ICollectionValue <G> result = sut.GetCollection(values, null); Assert.Equal(6, result.Size); }
public void DefaultForTaskIsCompleted() { var value = new DefaultValueProvider().GetDefault <Task>(); Assert.NotNull(value); Assert.True(value.IsCompleted); }
public void DefaultValueProvider_GetAsValue(object value) { DefaultValueProvider <G> sut = new DefaultValueProvider <G>(); IValue <G> result = sut.GetAsValue(value); switch (value) { case double _: Assert.IsAssignableFrom <IValue <G, double> >(result); break; case int _: Assert.IsAssignableFrom <IValue <G, int> >(result); break; case long _: Assert.IsAssignableFrom <IValue <G, long> >(result); break; case string _: Assert.IsAssignableFrom <IValue <G, string> >(result); break; case null: Assert.IsAssignableFrom <INullValue <G> >(result); break; } }
public void DefaultGroupValue_Get_NotExisting() { string pointerName = "grouppointername"; DefaultValueProvider <G> valueProvider = new DefaultValueProvider <G>(); DeclaredValuePointer <G> groupPointer = new DeclaredValuePointer <G>("group", valueProvider.Null) { Identifier = pointerName }; List <DeclaredValuePointer <G> > groupPointers = new List <DeclaredValuePointer <G> >() { new DeclaredValuePointer <G>("group"), groupPointer, new DeclaredValuePointer <G>("group") }; Dictionary <string, int> pointerMap = new Dictionary <string, int> { { pointerName, 1 } }; G groupState = Mock.Of <G>(m => m.GroupPointers == groupPointers && m.PointerMap == pointerMap); DefaultStringValue <G> key = new DefaultStringValue <G>("otherpointer"); DefaultGroupValue <G> sut = new DefaultGroupValue <G>(groupState); EngineRuntimeException ex = Assert.Throws <EngineRuntimeException>(() => { sut.Get(key, true, valueProvider); }); Assert.Equal("Cannot create group pointer using accessor", ex.Message); }
public void DefaultForArrayIsEmpty() { var value = new DefaultValueProvider().GetDefault(typeof(object[])); Assert.NotNull(value); Assert.IsType <object[]>(value); Assert.Empty(((Array)value)); }
public void DefaultForValueTupleHasDefaults() { var(providers, formatter, platform) = new DefaultValueProvider().GetDefault <(IServiceProvider[], Task <IFormatProvider>, PlatformID)>(); Assert.Empty(providers); Assert.True(formatter.IsCompleted); Assert.Equal(default(PlatformID), platform); }
public ValueProviderResult GetValue(string key) { if (_actionParameterAlias.ActionParameter.Equals(key, StringComparison.InvariantCultureIgnoreCase)) { return(DefaultValueProvider.GetValue(_actionParameterAlias.Alias)); } return(ValueProviderResult.None); }
public bool ContainsPrefix(string prefix) { if (_actionParameterAlias.ActionParameter.Equals(prefix, StringComparison.InvariantCultureIgnoreCase)) { return(DefaultValueProvider.ContainsPrefix(_actionParameterAlias.Alias)); } return(false); }