Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
robertbasti committed Sep 20, 2024
1 parent 59cd888 commit ad8c313
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public async Task Execute_DeleteTwoMnemonics_ReturnResult()
_witsmlClient.Setup(client => client.DeleteFromStoreAsync(
Match.Create<IWitsmlQueryType>(o =>
((WitsmlLogs)o).Logs.First().UidWell == WellUid &&
((WitsmlLogs)o).Logs.First().UidWellbore == WellboreUid),null))
((WitsmlLogs)o).Logs.First().UidWellbore == WellboreUid), null))
.ReturnsAsync(new QueryResult(true));

(WorkerResult result, RefreshAction refreshAction) = await _worker.Execute(CreateJob(ComponentType.Mnemonic));
Expand All @@ -82,7 +82,7 @@ public async Task Execute_DeleteTwoMnemonics_ReturnResult()
public async Task Execute_DeleteTwoTubularComponents_CorrectQuery()
{
List<IWitsmlQueryType> deleteQueries = new();
_witsmlClient.Setup(client => client.DeleteFromStoreAsync(It.IsAny<IWitsmlQueryType>(),null))
_witsmlClient.Setup(client => client.DeleteFromStoreAsync(It.IsAny<IWitsmlQueryType>(), null))
.Callback<IWitsmlQueryType>(deleteQueries.Add)
.ReturnsAsync(new QueryResult(true));

Expand All @@ -103,7 +103,7 @@ public async Task Execute_DeleteTwoTubularComponents_CorrectQuery()
[Fact]
public async Task Execute_DeleteTwoTubularComponents_ReturnResult()
{
_witsmlClient.Setup(client => client.DeleteFromStoreAsync(It.IsAny<IWitsmlQueryType>(),null))
_witsmlClient.Setup(client => client.DeleteFromStoreAsync(It.IsAny<IWitsmlQueryType>(), null))
.ReturnsAsync(new QueryResult(true));

(WorkerResult result, RefreshAction refreshAction) = await _worker.Execute(CreateJob(ComponentType.TubularComponent));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public async Task JobHasNoIndexRanges_DoNothing()
(WorkerResult result, RefreshAction _) = await _worker.Execute(job);

_witsmlClient.Verify(client => client.GetFromStoreAsync(It.IsAny<WitsmlLogs>(), It.Is<OptionsIn>((ops) => ops.ReturnElements == ReturnElements.HeaderOnly)), Times.Once);
_witsmlClient.Verify(client => client.DeleteFromStoreAsync(It.IsAny<WitsmlLogs>(),null), Times.Never);
_witsmlClient.Verify(client => client.DeleteFromStoreAsync(It.IsAny<WitsmlLogs>(), null), Times.Never);
Assert.True(result.IsSuccess);
}

Expand All @@ -82,7 +82,7 @@ public async Task MnemonicsNotFoundOnLogObject_DoNothing()
(WorkerResult result, RefreshAction _) = await _worker.Execute(job);

_witsmlClient.Verify(client => client.GetFromStoreAsync(It.IsAny<WitsmlLogs>(), It.Is<OptionsIn>((ops) => ops.ReturnElements == ReturnElements.HeaderOnly)), Times.Once);
_witsmlClient.Verify(client => client.DeleteFromStoreAsync(It.IsAny<WitsmlLogs>(),null), Times.Never);
_witsmlClient.Verify(client => client.DeleteFromStoreAsync(It.IsAny<WitsmlLogs>(), null), Times.Never);
Assert.True(result.IsSuccess);
}

Expand All @@ -99,7 +99,7 @@ public async Task LogObjectNotFound_SetNoSuccess()
(WorkerResult result, RefreshAction _) = await _worker.Execute(job);

_witsmlClient.Verify(client => client.GetFromStoreAsync(It.IsAny<WitsmlLogs>(), It.Is<OptionsIn>((ops) => ops.ReturnElements == ReturnElements.HeaderOnly)), Times.Once);
_witsmlClient.Verify(client => client.DeleteFromStoreAsync(It.IsAny<WitsmlLogs>(),null), Times.Never);
_witsmlClient.Verify(client => client.DeleteFromStoreAsync(It.IsAny<WitsmlLogs>(), null), Times.Never);
Assert.False(result.IsSuccess);
}

Expand All @@ -111,7 +111,7 @@ public async Task SingleIndexRange_ShouldRunSingleDeleteQuery()
(WorkerResult result, RefreshAction _) = await _worker.Execute(job);

_witsmlClient.Verify(client => client.GetFromStoreAsync(It.IsAny<WitsmlLogs>(), It.Is<OptionsIn>((ops) => ops.ReturnElements == ReturnElements.HeaderOnly)), Times.Once);
_witsmlClient.Verify(client => client.DeleteFromStoreAsync(It.IsAny<WitsmlLogs>(),null), Times.Once());
_witsmlClient.Verify(client => client.DeleteFromStoreAsync(It.IsAny<WitsmlLogs>(), null), Times.Once());
Assert.True(result.IsSuccess);
}

Expand All @@ -129,7 +129,7 @@ public async Task SingleIndexRangeDecreasing_ShouldRunSingleDeleteQuery()
(WorkerResult result, RefreshAction _) = await _worker.Execute(job);

_witsmlClient.Verify(client => client.GetFromStoreAsync(It.IsAny<WitsmlLogs>(), It.Is<OptionsIn>((ops) => ops.ReturnElements == ReturnElements.HeaderOnly)), Times.Once);
_witsmlClient.Verify(client => client.DeleteFromStoreAsync(It.Is<WitsmlLogs>(logs => logs.Logs.First().StartIndex.Value == "20" && logs.Logs.First().EndIndex.Value == "10"),null), Times.Once());
_witsmlClient.Verify(client => client.DeleteFromStoreAsync(It.Is<WitsmlLogs>(logs => logs.Logs.First().StartIndex.Value == "20" && logs.Logs.First().EndIndex.Value == "10"), null), Times.Once());
Assert.True(result.IsSuccess);
}

Expand All @@ -149,7 +149,7 @@ public async Task TwoIndexRanges_ShouldRunTwoDeleteQueries_DepthIndexed()
(WorkerResult result, RefreshAction _) = await _worker.Execute(job);

_witsmlClient.Verify(client => client.GetFromStoreAsync(It.IsAny<WitsmlLogs>(), It.Is<OptionsIn>((ops) => ops.ReturnElements == ReturnElements.HeaderOnly)), Times.Once);
_witsmlClient.Verify(client => client.DeleteFromStoreAsync(It.IsAny<WitsmlLogs>(),null), Times.Exactly(2));
_witsmlClient.Verify(client => client.DeleteFromStoreAsync(It.IsAny<WitsmlLogs>(), null), Times.Exactly(2));
Assert.True(result.IsSuccess);
}

Expand Down Expand Up @@ -180,7 +180,7 @@ public async Task TwoIndexRanges_ShouldRunTwoDeleteQueries_TimeIndexed()
(WorkerResult result, RefreshAction _) = await _worker.Execute(job);

_witsmlClient.Verify(client => client.GetFromStoreAsync(It.IsAny<WitsmlLogs>(), It.Is<OptionsIn>((ops) => ops.ReturnElements == ReturnElements.HeaderOnly)), Times.Once);
_witsmlClient.Verify(client => client.DeleteFromStoreAsync(It.IsAny<WitsmlLogs>(),null), Times.Exactly(2));
_witsmlClient.Verify(client => client.DeleteFromStoreAsync(It.IsAny<WitsmlLogs>(), null), Times.Exactly(2));
Assert.True(result.IsSuccess);
}

Expand All @@ -203,7 +203,7 @@ public async Task IndexRangeOutsideLogIndex_ShouldNotRunAnyDeleteQueries_DepthIn
(WorkerResult result, RefreshAction _) = await _worker.Execute(job);

_witsmlClient.Verify(client => client.GetFromStoreAsync(It.IsAny<WitsmlLogs>(), It.Is<OptionsIn>((ops) => ops.ReturnElements == ReturnElements.HeaderOnly)), Times.Once);
_witsmlClient.Verify(client => client.DeleteFromStoreAsync(It.IsAny<WitsmlLogs>(),null), Times.Never);
_witsmlClient.Verify(client => client.DeleteFromStoreAsync(It.IsAny<WitsmlLogs>(), null), Times.Never);
Assert.True(result.IsSuccess);
}

Expand All @@ -229,7 +229,7 @@ public async Task IndexRangeOutsideLogIndex_ShouldNotRunAnyDeleteQueries_TimeInd
(WorkerResult result, RefreshAction _) = await _worker.Execute(job);

_witsmlClient.Verify(client => client.GetFromStoreAsync(It.IsAny<WitsmlLogs>(), It.Is<OptionsIn>((ops) => ops.ReturnElements == ReturnElements.HeaderOnly)), Times.Once);
_witsmlClient.Verify(client => client.DeleteFromStoreAsync(It.IsAny<WitsmlLogs>(),null), Times.Never);
_witsmlClient.Verify(client => client.DeleteFromStoreAsync(It.IsAny<WitsmlLogs>(), null), Times.Never);
Assert.True(result.IsSuccess);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Expected Data (indexCurve, curve1):
var (result, refreshAction) = await _worker.Execute(job);

Assert.True(result.IsSuccess);
_witsmlClient.Verify(client => client.DeleteFromStoreAsync(It.IsAny<WitsmlLogs>(),null), Times.Once);
_witsmlClient.Verify(client => client.DeleteFromStoreAsync(It.IsAny<WitsmlLogs>(), null), Times.Once);
_witsmlClient.Verify(client => client.UpdateInStoreAsync(It.Is<WitsmlLogs>(logs => ValidateLogs(logs, expectedData))), Times.Once);
}

Expand Down Expand Up @@ -104,7 +104,7 @@ Expected Data (indexCurve, curve1):
var (result, refreshAction) = await _worker.Execute(job);

Assert.True(result.IsSuccess);
_witsmlClient.Verify(client => client.DeleteFromStoreAsync(It.IsAny<WitsmlLogs>(),null), Times.Once);
_witsmlClient.Verify(client => client.DeleteFromStoreAsync(It.IsAny<WitsmlLogs>(), null), Times.Once);
_witsmlClient.Verify(client => client.UpdateInStoreAsync(It.Is<WitsmlLogs>(logs => ValidateLogs(logs, expectedData))), Times.Once);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private static ReplaceObjectsJob SetUpReplaceObjectsJob()
private void SetUpStoreForDelete(bool queryResult = true)
{
List<IWitsmlQueryType> deleteQueries = new();
_witsmlClient.Setup(client => client.DeleteFromStoreAsync(It.IsAny<IWitsmlQueryType>(),null))
_witsmlClient.Setup(client => client.DeleteFromStoreAsync(It.IsAny<IWitsmlQueryType>(), null))
.Callback<IWitsmlQueryType>(deleteQueries.Add)
.ReturnsAsync(new QueryResult(true));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public async Task JobHasNoIndexes_DoNothing()

await _worker.Execute(job);

_witsmlClient.Verify(client => client.DeleteFromStoreAsync(It.IsAny<WitsmlLogs>(),null), Times.Never);
_witsmlClient.Verify(client => client.DeleteFromStoreAsync(It.IsAny<WitsmlLogs>(), null), Times.Never);
}

[Fact]
Expand All @@ -74,7 +74,7 @@ public async Task JobHasIndexesOutOfScope_DoNothing_DepthIndexed()
};
await _worker.Execute(job);

_witsmlClient.Verify(client => client.DeleteFromStoreAsync(It.IsAny<WitsmlLogs>(),null), Times.Never);
_witsmlClient.Verify(client => client.DeleteFromStoreAsync(It.IsAny<WitsmlLogs>(), null), Times.Never);
}

[Fact]
Expand All @@ -100,7 +100,7 @@ public async Task JobHasIndexesOutOfScope_DoNothing_TimeIndexed()
};
await _worker.Execute(job);

_witsmlClient.Verify(client => client.DeleteFromStoreAsync(It.IsAny<WitsmlLogs>(),null), Times.Never);
_witsmlClient.Verify(client => client.DeleteFromStoreAsync(It.IsAny<WitsmlLogs>(), null), Times.Never);
}

[Fact]
Expand Down

0 comments on commit ad8c313

Please sign in to comment.