Created
August 1, 2012 10:52
-
-
Save antonydenyer/3225770 to your computer and use it in GitHub Desktop.
should be able to unit test Nest.ElasticClient
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var settings = A.Fake<IConnectionSettings>(); | |
var connection = A.Fake<IConnection>(); | |
A.CallTo(() => settings.DefaultIndex).Returns("nest_test_data"); | |
var value = new ConnectionStatus(File.ReadAllText(@"InversionOfControl.json")); | |
A.CallTo(() => | |
connection.PostSync( | |
A<string>.That.Contains("nest_test_data/elasticsearchprojects/_search"), | |
A<string>.That.Contains("value\": \"searchTerm"))). | |
Returns(value); | |
var client = new ElasticClient(settings, connection); | |
var items = client.Search<ElasticSearchProject>(s => | |
s.Index("nest_test_data") | |
.Query( | |
q => q.Term(f => f.Name, "searchTerm")) | |
); | |
Assert.That(items.Documents.Count(),Is.EqualTo(10)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment