Skip to content

Commit ab8bff8

Browse files
committed
Delete stubs and use interfaces for mocks
1 parent 2f830c9 commit ab8bff8

12 files changed

+11
-3085
lines changed

IntegrationEngine.Core.Tests/IntegrationEngine.Core.Tests.csproj

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,6 @@
5858
<Compile Include="Properties\AssemblyInfo.cs" />
5959
<Compile Include="Storage\ElasticsearchRepositoryTest.cs" />
6060
<Compile Include="Mail\MailClientTest.cs" />
61-
<Compile Include="Storage\StubDeleteRequest.cs" />
62-
<Compile Include="Storage\StubElasticClient.cs" />
63-
<Compile Include="Storage\StubElasticsearchResponse.cs" />
64-
<Compile Include="Storage\StubExistsResponse.cs" />
65-
<Compile Include="Storage\StubGetResponse.cs" />
66-
<Compile Include="Storage\StubHit.cs" />
67-
<Compile Include="Storage\StubIndexResponse.cs" />
68-
<Compile Include="Storage\StubPingResponse.cs" />
69-
<Compile Include="Storage\StubSearchResponse.cs" />
70-
<Compile Include="Storage\StubUpdateResponse.cs" />
7161
</ItemGroup>
7262
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
7363
<ItemGroup>

IntegrationEngine.Core.Tests/Storage/ElasticsearchRepositoryTest.cs

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ namespace IntegrationEngine.Core.Tests.Storage
1414
{
1515
public class ElasticsearchRepositoryTest : TestBase<ElasticsearchRepository>
1616
{
17-
Mock<StubElasticClient> ElasticClient { get; set; }
17+
Mock<ElasticClient> ElasticClient { get; set; }
1818
Mock<ILog> Log { get; set; }
1919

2020
[SetUp]
2121
public void Setup()
2222
{
23-
ElasticClient = new Mock<StubElasticClient>();
23+
ElasticClient = new Mock<ElasticClient>();
2424
Subject.ElasticClient = ElasticClient.Object;
2525
Log = new Mock<ILog>();
2626
Subject.Log = Log.Object;
@@ -29,10 +29,10 @@ public void Setup()
2929
[Test]
3030
public void ShouldReturnListOfDocumentsWithIdsFromElasticsearch()
3131
{
32-
var searchResponse = new Mock<StubSearchResponse<CronTrigger>>();
32+
var searchResponse = new Mock<ISearchResponse<CronTrigger>>();
3333
var hits = new List<IHit<CronTrigger>>();
3434
var cronTrigger = new CronTrigger();
35-
var hit = new Mock<StubHit<CronTrigger>>();
35+
var hit = new Mock<Hit<CronTrigger>>();
3636
var expectedId = "1";
3737
hit.SetupGet(x => x.Source).Returns(() => cronTrigger);
3838
hit.SetupGet(x => x.Id).Returns(() => expectedId);
@@ -41,7 +41,6 @@ public void ShouldReturnListOfDocumentsWithIdsFromElasticsearch()
4141
ElasticClient.Setup(x => x.Search<CronTrigger>(It.IsAny<Func<SearchDescriptor<CronTrigger>, SearchDescriptor<CronTrigger>>>()))
4242
.Returns(searchResponse.Object);
4343

44-
4544
var actual = Subject.SelectAll<CronTrigger>();
4645

4746
Assert.That(actual, Is.Not.Empty);
@@ -52,7 +51,7 @@ public void ShouldReturnListOfDocumentsWithIdsFromElasticsearch()
5251
[Test]
5352
public void ShouldReturnNullIfDocumentIsNotFoundById()
5453
{
55-
var getResponse = new Mock<StubGetResponse<CronTrigger>>();
54+
var getResponse = new Mock<IGetResponse<CronTrigger>>();
5655
ElasticClient.Setup(x => x.Get(It.IsAny<Func<GetDescriptor<CronTrigger>, GetDescriptor<CronTrigger>>>()))
5756
.Returns(getResponse.Object);
5857

@@ -64,7 +63,7 @@ public void ShouldReturnNullIfDocumentIsNotFoundById()
6463

6564
void SetupForGetDocument(string id)
6665
{
67-
var getResponse = new Mock<StubGetResponse<CronTrigger>>();
66+
var getResponse = new Mock<IGetResponse<CronTrigger>>();
6867
getResponse.SetupGet(x => x.Id).Returns(() => id);
6968
getResponse.SetupGet(x => x.Source).Returns(() => new CronTrigger());
7069
ElasticClient.Setup(x => x.Get(It.IsAny<Func<GetDescriptor<CronTrigger>, GetDescriptor<CronTrigger>>>()))
@@ -89,7 +88,7 @@ public void ShouldInsertAndReturnDocument()
8988
var expectedId = "1";
9089
SetupForGetDocument(expectedId);
9190
var expected = new CronTrigger() { Id = expectedId };
92-
var indexResponse = new Mock<StubIndexResponse>();
91+
var indexResponse = new Mock<IIndexResponse>();
9392
indexResponse.SetupGet(x => x.Id).Returns(() => expected.Id);
9493
ElasticClient.Setup(x => x.Index(expected, It.IsAny<Func<IndexDescriptor<CronTrigger>, IndexDescriptor<CronTrigger>>>()))
9594
.Returns(indexResponse.Object);
@@ -106,7 +105,7 @@ public void ShouldUpdateAndReturnDocument()
106105
var expectedId = "1";
107106
SetupForGetDocument(expectedId);
108107
var expected = new CronTrigger() { Id = expectedId };
109-
var updateResponse = new Mock<StubUpdateResponse>();
108+
var updateResponse = new Mock<IUpdateResponse>();
110109
updateResponse.SetupGet(x => x.Id).Returns(() => expected.Id);
111110
ElasticClient.Setup(x => x.Update<CronTrigger>(It.IsAny<Func<UpdateDescriptor<CronTrigger, CronTrigger>, UpdateDescriptor<CronTrigger, CronTrigger>>>()))
112111
.Returns(updateResponse.Object);
@@ -132,7 +131,7 @@ public void ShouldDeleteDocument()
132131

133132
void SetupForDocumentExists(bool exists)
134133
{
135-
var existsResponse = new Mock<StubExistsResponse>();
134+
var existsResponse = new Mock<IExistsResponse>();
136135
existsResponse.SetupGet(x => x.Exists).Returns(exists);
137136
ElasticClient.Setup(x => x.DocumentExists(It.IsAny<Func<DocumentExistsDescriptor<CronTrigger>, DocumentExistsDescriptor<CronTrigger>>>()))
138137
.Returns(existsResponse.Object);
@@ -160,9 +159,9 @@ public void ShouldReturnFalseIfDocumentDoesNotExist()
160159

161160
void SetupForIsServerAvailable(bool success)
162161
{
163-
var elasticsearchResponse = new Mock<StubElasticsearchResponse>();
162+
var elasticsearchResponse = new Mock<IElasticsearchResponse>();
164163
elasticsearchResponse.SetupGet(x => x.Success).Returns(() => success);
165-
var pingResponse = new Mock<StubPingResponse>();
164+
var pingResponse = new Mock<IPingResponse>();
166165
pingResponse.SetupGet(x => x.ConnectionStatus).Returns(() => elasticsearchResponse.Object);
167166
ElasticClient.Setup(x => x.Ping(It.IsAny<PingRequest>())).Returns(pingResponse.Object);
168167
}

IntegrationEngine.Core.Tests/Storage/StubDeleteRequest.cs

Lines changed: 0 additions & 81 deletions
This file was deleted.

0 commit comments

Comments
 (0)