public void Null_Or_Empty_Returns_Empty_List(string input) { // Arrange // Act var result = EnumeratedList.Deserialise <Foo>(input); // Assert Assert.Empty(result); }
public void Incorrect_Json_Returns_Empty_List() { // Arrange const string?json = /*lang=json,strict*/ "{\"foo\":\"bar\"}"; // Act var result = EnumeratedList.Deserialise <Foo>(json); // Assert Assert.Empty(result); }
public void Invalid_Json_Returns_Empty_List() { // Arrange var json = Rnd.Str; // Act var result = EnumeratedList.Deserialise <Foo>(json); // Assert Assert.Empty(result); }
public void Correct_Json_Returns_List() { // Arrange var itemA = new Foo(Rnd.Str); var itemB = new Foo(Rnd.Str); var itemC = new Foo(Rnd.Str); var itemD = new Foo(Rnd.Str); var json = $"[\"{itemB}\",\"{itemD}\",\"{itemA}\",\"{itemC}\"]"; // Act var result = EnumeratedList.Deserialise <Foo>(json); // Assert Assert.Collection(result, b => Assert.Equal(itemB, b), d => Assert.Equal(itemD, d), a => Assert.Equal(itemA, a), c => Assert.Equal(itemC, c) ); }
/// <summary> /// Parse from list of string values and convert /// </summary> /// <param name="xml">JSON string</param> protected override EnumeratedList <T> Parse(string xml) => EnumeratedList.Deserialise <T>(xml);