我有以下测试但不起作用,
[Test]
public async Task Get_Portfolio_ReturnsValuesCorrectly()
{
var testServer = TestHelpers.CreateTestServer();
var client = testServer.CreateClient();
var portfolio= new Portfolio
{
PortfolioId = this.portfolio.Id,
YearCurve = "Test",
InflationCurve = "Test",
PortfolioName = this.portfolio.Name
};
await client.PutAsJsonAsync("api/Portfolios/", this.portfolio).ConfigureAwait(false);
var route = "api/Portfolio/" + portfolio.PortfolioId;
using (var response = await client.GetAsync(route).ConfigureAwait(false))
////using (var stream = await client.GetStreamAsync(route).ConfigureAwait(false))
{
var retrievedString= await response.Content.ReadAsStringAsync();
Portfolio retrievedPortfolio = JsonConvert.DeserializeObject<Portfolio>(retrievedString);
////var retrievedCurveType = Serializer.Deserialize<Portfolio>(stream);
Assert.That(retrievedPortfolio.Id, Is.EqualTo(this.portfolio.Id));
Assert.That(retrievedPortfolio.PortfolioName, Is.EqualTo(this.portfolio.Name));
}
}
测试在所有值中返回空值 json 看起来像那样
"{\"ItemsToSerialize\":{\"PortfolioId\":\"TEST PORTFOLIO_20150131\",\"Id\":\"TEST PORTFOLIO_20150131\",\"YearCurve\":\"Test\",\"InflationCurve\":\"Test\",\"PortfolioName\":\"TEST PORTFOLIO\"}}"
无论我尝试检索为流还是字符串,都失败了
提前致谢