2014-12-23 6 views
0

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

ControllerDocumentStore와 상호 작용합니다.

내가 겪고있는 문제는 테스트에서 생성 된 데이터가 정리되지 않는다는 것입니다.

내가 읽은 바를 토대로 수락 테스트를 위해 EmbeddableDocumentStore을 사용해야합니다.

DocumentStore은 일반적으로 사용하지만 EmbeddableDocumentStore과 같이 경계 테스트를 수행 할 때 어떻게 사용할 수 있습니까?

답변

1

컨트롤러에서 "DocumentStore와 어떻게 상호 작용합니까"? 컨트롤러는 실제로 WebAPI 인프라 스트럭쳐에 의해 주입 될 수있는 IDocumentSession과 "상호 작용"할 필요가 있으며 통합 테스트에서는 EmbeddableDocumentStore (IOC 컨테이너를 사용하는 경우)에 의해 구현 될 IDocumentStore를 등록합니다.