public void GetValueOrNew_ValueDoesNotExist_AddedIntoDictionary() { Dictionary <string, int> d = new Dictionary <string, int>(); d.GetValueOrNew("some key"); Assert.Contains("some key", d.Keys); }
public void GetValueOrNew_ValueDoesNotExists_ConstructorFunctionUsed() { Dictionary <string, string> d = new Dictionary <string, string>(); string actual = d.GetValueOrNew("some key", () => "some value"); Assert.Equal("some value", actual); }
public void GetValueOrNew_ValueDoesNotExist_DefaultConstructorUsed() { Dictionary <string, MyType> d = new Dictionary <string, MyType>(); MyType actual = d.GetValueOrNew("some key"); Assert.Equal("Default", actual.Value); }
private string GetStringValueTag(string value) { if (value.StartsWith("=")) { return($"<f>{value}</f>"); } return(GetValueTag(_sharedStrings.GetValueOrNew(value))); }
private void WriteStringValueTag(TextWriter writer, string value) { if (value.StartsWith("=")) { writer.Write("<f>"); writer.Write(value); writer.Write("</f>"); } else { WriteValueTag(writer, _sharedStrings.GetValueOrNew(value)); } }
private static Dictionary <string, Dictionary <C, List <V> > > GetValuesForTable <T, C, V>(ICollection <T> elements, List <PropertyInfo> otherProperties, Func <T, C> columnNameFunc, Func <T, V> valueFunc) { var valueDic = new Dictionary <string, Dictionary <C, List <V> > >(); foreach (T item in elements) { string propKey = GetKey(item, otherProperties); C columnValue = columnNameFunc(item); V value = valueFunc(item); List <V> valueList = valueDic.GetValueOrNew(propKey).GetValueOrNew(columnValue); valueList.Add(value); } return(valueDic); }
public void GetValueOrNew_ValueDoesNotExist_DefaultConstructorUsed() { Dictionary<string, MyType> d = new Dictionary<string, MyType>(); MyType actual = d.GetValueOrNew("some key"); Assert.Equal("Default", actual.Value); }
public void GetValueOrNew_ValueDoesNotExist_AddedIntoDictionary() { Dictionary<string, int> d = new Dictionary<string, int>(); d.GetValueOrNew("some key"); Assert.Contains("some key", d.Keys); }
public void GetValueOrNew_ValueDoesNotExists_ConstructorFunctionUsed() { Dictionary<string, string> d = new Dictionary<string, string>(); string actual = d.GetValueOrNew("some key", () => "some value"); Assert.Equal("some value", actual); }