public void Should_Return_Valid_Dictionary_Parser_For_Plain_Object() { var plainObject = new FlatObject { Int = 1, Str = "str", Time = DateTime.UtcNow }; var parser = ObjectToDictionaryConverter.GetConverter(plainObject.GetType()); var dictionary = parser.ConvertFromObject(plainObject); Assert.AreEqual(plainObject.Int, (int)dictionary[nameof(plainObject.Int)]); Assert.AreEqual(plainObject.Str, (string)dictionary[nameof(plainObject.Str)]); Assert.AreEqual(plainObject.Time, (DateTime)dictionary[nameof(plainObject.Time)]); }
public void Should_Return_Same_Object_From_Cache_For_Plain_Object() { var firstAnonymousObject = new FlatObject { Int = 1, Str = "str", Time = DateTime.UtcNow }; var first = ObjectToDictionaryConverter.GetConverter(firstAnonymousObject.GetType()); var secondAnonymousObject = new FlatObject { Int = 2, Str = "str2", Time = DateTime.Now }; var second = ObjectToDictionaryConverter.GetConverter(secondAnonymousObject.GetType()); Assert.AreSame(first, second); }