public void ExpressionSupportsConversionOfDictionariesIntoObjectLiterals() { var dictionary = new Dictionary <string, int> { { "One", 1 }, { "Two", 2 } }; var expression1 = Expression.FromObject(dictionary); Assert.AreEqual("{One:1,Two:2};", expression1.ToString()); const string text = "The brown for jumps over the lazy dog."; Dictionary <string, int> words = text.Split(' ').ToDictionary( item => item, item => item.Length); var expression2 = Expression.FromObject(words); Assert.AreEqual("{The:3,brown:5,for:3,jumps:5,over:4,the:3,lazy:4,\"dog.\":4};", expression2.ToString()); FakeDictionary <string, bool> fake = new FakeDictionary <string, bool> { { "yes", true }, { "no", false } }; var expression3 = Expression.FromObject(fake); Assert.AreEqual("{yes:true,no:false};", expression3.ToString()); }
public List <ReplaceUnit> this[string prefabPath] { get { FakeDictionary entry = fakePrefabsUpdatedReferences.Find(item => item.prefabPath == prefabPath); if (entry == null) { string guid = AssetDatabase.AssetPathToGUID(prefabPath); if (guid == null) { Debug.LogError($"Incorrect asset path: {prefabPath}"); } entry = new FakeDictionary(prefabPath); fakePrefabsUpdatedReferences.Add(entry); return(entry.updatedReferences); } else { return(entry.updatedReferences); } } }
public void ExpressionSupportsConversionOfDictionariesIntoObjectLiterals() { var dictionary = new Dictionary<string, int> {{"One", 1}, {"Two", 2}}; var expression1 = Expression.FromObject(dictionary); Assert.AreEqual("{One:1,Two:2};", expression1.ToString()); const string text = "The brown for jumps over the lazy dog."; Dictionary<string, int> words = text.Split(' ').ToDictionary( item => item, item => item.Length); var expression2 = Expression.FromObject(words); Assert.AreEqual("{The:3,brown:5,for:3,jumps:5,over:4,the:3,lazy:4,\"dog.\":4};", expression2.ToString()); FakeDictionary<string, bool> fake = new FakeDictionary<string, bool> { { "yes", true }, { "no", false } }; var expression3 = Expression.FromObject(fake); Assert.AreEqual("{yes:true,no:false};", expression3.ToString()); }