Exemplo n.º 1
0
        public void GetValueOrNew_ValueDoesNotExist_AddedIntoDictionary()
        {
            Dictionary <string, int> d = new Dictionary <string, int>();

            d.GetValueOrNew("some key");

            Assert.Contains("some key", d.Keys);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        public void GetValueOrNew_ValueDoesNotExist_DefaultConstructorUsed()
        {
            Dictionary <string, MyType> d = new Dictionary <string, MyType>();

            MyType actual = d.GetValueOrNew("some key");

            Assert.Equal("Default", actual.Value);
        }
Exemplo n.º 4
0
        private string GetStringValueTag(string value)
        {
            if (value.StartsWith("="))
            {
                return($"<f>{value}</f>");
            }

            return(GetValueTag(_sharedStrings.GetValueOrNew(value)));
        }
Exemplo n.º 5
0
 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));
     }
 }
Exemplo n.º 6
0
        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);
        }