0
我正在構建一個使用Web API和Raven DB的系統。邊界測試Raven Db
我正在寫這個系統的外部邊界的集成測試。
public void GetAfterPostingPollReturnsPoll()
{
using (var client = HttpClientFactory.Create())
{
var poll = new
{
Question = "What is the answer?",
Options = new[] { "Yes", "No", "Maybe" }
};
var postResponse = client.PostAsJsonAsync("", poll).Result;
var pollLocation = postResponse.Headers.Location;
var getResponse = client.GetAsync(pollLocation).Result;
var actual = JsonConvert.DeserializeObject<Poll>(
getResponse.Content
.ReadAsStringAsync()
.Result);
Assert.Equal(poll.Question, actual.Question);
Assert.Equal(poll.Options, actual.Options);
}
}
當我提交的條目,則Controller
用DocumentStore
交互,因爲這是它如何工作的生產。
我遇到的麻煩是測試中產生的數據永遠不會被清理。
基於我一直在閱讀的內容,我應該使用EmbeddableDocumentStore
來進行驗收測試。
在執行像這樣的邊界測試時,我該如何使用DocumentStore
而不是EmbeddableDocumentStore
?