public void Response_Parse() { var response = ProfileResponse.Parse("OK: HELLO WORLD!"); Assert.True(response.Success); Assert.Equal("HELLO WORLD!", response.Value); Assert.Null(response.JObject); Assert.Equal("OK: HELLO WORLD!", response.ToString()); }
public void Response_ParseError() { var response = ProfileResponse.Parse($"ERROR[{ProfileStatus.BadRequest}]: HELLO WORLD!"); Assert.False(response.Success); Assert.Null(response.Value); Assert.Null(response.JObject); Assert.Equal("HELLO WORLD!", response.Error); Assert.Equal($"ERROR[{ProfileStatus.BadRequest}]: HELLO WORLD!", response.ToString()); }
public void Response_ParseJson() { var response = ProfileResponse.Parse("OK-JSON: {\"hello\":\"world!\"}"); Assert.True(response.Success); Assert.Equal(ProfileStatus.OK, response.Status); Assert.Null(response.Value); Assert.Single(response.JObject.Properties()); Assert.Equal("world!", response.JObject["hello"]); Assert.Equal("OK-JSON: {\"hello\":\"world!\"}", response.ToString()); }
public void Response_ParseFailure() { Assert.Throws <ArgumentNullException>(() => ProfileResponse.Parse(null)); Assert.Throws <ArgumentNullException>(() => ProfileResponse.Parse(string.Empty)); Assert.Throws <FormatException>(() => ProfileResponse.Parse("NOT-OK")); Assert.Throws <FormatException>(() => ProfileResponse.Parse("NOT-OK")); Assert.Throws <FormatException>(() => ProfileResponse.Parse("ERROR:")); Assert.Throws <FormatException>(() => ProfileResponse.Parse("ERROR[:")); Assert.Throws <FormatException>(() => ProfileResponse.Parse("ERROR]:")); Assert.Throws <FormatException>(() => ProfileResponse.Parse("ERROR[]:")); Assert.Throws <FormatException>(() => ProfileResponse.Parse("OK-JSON: { BAD JSON }")); }