Permalink
Browse files

Updated unit tests to take into account ElasticSearch connection vali…

…dation check
  • Loading branch information...
1 parent 5250b22 commit e4109b026546c038e92f3042b7e8f4e96f6f6f5b @AdaTheDev committed Feb 11, 2013
Showing with 23 additions and 0 deletions.
  1. +23 −0 ElasticTweets.Library.UnitTests/ImporterFixture.cs
View
23 ElasticTweets.Library.UnitTests/ImporterFixture.cs
@@ -56,6 +56,8 @@ public void InitialiseImporter(IBulkResponse mockedBulkResponse = null)
else
_mockedClient.Setup(c => c.IndexMany(It.IsAny<IEnumerable<dynamic>>())).Returns(mockedBulkResponse);
+ _mockedClient.Setup(c => c.IsValid).Returns(true);
+
_importer = new Importer(_mockedFileSystem.Object, _mockedFileParser.Object, _mockedClientProvider.Object, _mockedConnectionSettings.Object, TestSourceDirectory);
}
@@ -180,6 +182,27 @@ public void Constructor_SetsSourceDirectory()
#endregion
#region Import Tests
+ [Test]
+ public void Import_ChecksElasticSearchConnectionIsValid()
+ {
+ InitialiseImporter();
+ _mockedFileSystem.Setup(fs => fs.GetFiles(TestSourceDirectory, "*.js")).Returns(new[] { "1.js" });
+
+ _importer.Import();
+
+ _mockedClient.Verify(c => c.IsValid, Times.Once());
+ }
+
+ [Test]
+ [ExpectedException(typeof(ElasticSearchException))]
+ public void Import_ThrowsWhenElasticSearchConnectionIsNotValid()
+ {
+ InitialiseImporter();
+ _mockedClient.Setup(c => c.IsValid).Returns(false);
+
+ _importer.Import();
+ }
+
[Test]
public void Import_RetrievesFileNamesOnceThroughFileSystem()
{

0 comments on commit e4109b0

Please sign in to comment.