public async Task ShouldConvertHttpMessageToGetStashTabsResponse() { var service = Substitute.For <IPoeApiService>(); var request = new GetStashTabs.Request { AccountName = "SomeAccountName", PoeSessionId = "someId" }; var expectedResponse = new GetStashTabs.Response { Tabs = new List <Tab> { new Tab { Name = "some name", Index = 0, Type = "some type" } } }; service.GetStashTabs(request).Returns(CreateGetStashTabsHttpResponseMessage(expectedResponse)); var sut = new GetStashTabs.Handler(service); var response = await sut.Handle(request); response.Should().BeEquivalentTo(expectedResponse); }
private HttpResponseMessage CreateGetStashTabsHttpResponseMessage(GetStashTabs.Response expectedResponse) { var jsonString = JsonSerializer.Serialize(expectedResponse); return(new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(jsonString, Encoding.UTF8, "application/json") }); }