コード例 #1
0
        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);
        }
コード例 #2
0
        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")
            });
        }