0

I am building a system using Web API and Raven DB.

I am writing integration tests against the external boundary of this system.

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); } } 

When I submit an entry, the Controller interacts with a DocumentStore because that is how it works in production.

The trouble I am having is that the data produced in the test is never cleaned up.

Based on what I have been reading, I should use the EmbeddableDocumentStore for the purposes of my acceptance tests.

How might I use the DocumentStore normally but the EmbeddableDocumentStore when executing boundary tests like this one?

1 Answer 1

1

How do you "interact with DocumentStore" in your controller? The controller really only need to "interact" with the IDocumentSession that could be injected by the WebAPI infrastructure and in your integration test you register IDocumentStore to be implemented by EmbeddableDocumentStore (providing you use some kind of IoC container).

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.