public void DeserializeSuccessfulListTollFreeResponse() { var fakeResponse = @"<?xml version=""1.0"" encoding=""UTF-8""?> <content> <status>ok</status> <numbers> <did>5555555555</did> <did>6666666666</did> <did>7777777777</did> </numbers> </content>"; var expected = new ListTollFreeResponse { Status = "ok", Numbers = new List <string> { "5555555555", "6666666666", "7777777777" } }; var sut = new ResponseDeserializer(); var actual = sut.DeserializeListTollFreeResponse(fakeResponse); Assert.NotNull(actual.Numbers); expected.Numbers.Sort(); actual.Numbers.Sort(); Assert.IsType(typeof(ListTollFreeResponse), actual); Assert.Equal(expected.Status, actual.Status); Assert.True(expected.Numbers.SequenceEqual(actual.Numbers)); }
public async Task <ListTollFreeResponse> ListTollFreeNumbers() { var result = await _cmd.ListTollFree(); if (!result.Succeeded) { return(null); } return(_deserializer.DeserializeListTollFreeResponse(result.Content)); }
public void DeserializeListTollFreeResponseWithError() { var fakeResponse = @"<?xml version=""1.0"" encoding=""UTF-8""?> <content> <status>fail</status> <error>missing</error> </content>"; var expected = new ListTollFreeResponse { Status = "fail", Error = "missing" }; var sut = new ResponseDeserializer(); var actual = sut.DeserializeListTollFreeResponse(fakeResponse); Assert.IsType(typeof(ListTollFreeResponse), actual); Assert.Equal(expected.Status, actual.Status); Assert.Equal(expected.Error, actual.Error); }