使用sqlite内存进行集成测试两个api调用

时间:2018-05-19 22:47:41

标签: c# asp.net-core integration-testing web-api-testing

在查询发生数据库在内存中时,我无法进行插入调用(并创建数据库)问题是acada调用数据库死了。能够在我的测试中创建数据库并对其进行操作会很有趣。

// Act
var model = new CreateOrUpdateTagsModel
{
    UserId = 1,
    CatalogItemType = "Movie",
    Owner = 1,
    PinRequired = false,
    ProductId = 1,
    TagType = "Stars",
    TagValue = "5"
};

var jsonSerializerSettings = new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() };
var json = JsonConvert.SerializeObject(model, jsonSerializerSettings);

var response2 = await _client.PutAsync("/v1/tags", new StringContent(json, Encoding.UTF8, "application/json"));
response2.EnsureSuccessStatusCode();

var responseString2 = await response2.Content.ReadAsStringAsync();

var response = await _client.GetAsync("/v1/tags?userId=1");
response.EnsureSuccessStatusCode();

1 个答案:

答案 0 :(得分:0)

我使用IDbConnection解析了AddSingleton的StartupTest.cs,并使用_queryExecutor = _server.Host.Services.GetService(typeof(IQueryExecutor)) as IQueryExecutor; _server TestServer s = 'HBODCSL' x = re.sub(r'([ABCD]+)([EFGHIJKLMNOPQRSTUVWXYZ])',r'\g<1>1\2',s,count=1) print(x) 实例解析了class ImagePlayer extends Component { componentDidMount() { axios.get(`/api/gameRPG/monsterImages/${this.props.encounterId}/pics`) .then((response) => { console.log(response); }) .catch((error) => { console.log(error); }); } render() { return ( <div> <div>Show Encounter Pics</div> <div></div> </div> ); } } export default ImagePlayer;