refactor(HistoryTests): Vereinfachung von HistoryTests durch direkte Einbindung von IMediator
- Entfernen der benutzerdefinierten Hilfsmethode Send<T> - Einführung der Mediator-Eigenschaft, die aus dem DI-Container aufgelöst wird - Ersetzen aller Send(request)-Aufrufe durch Mediator.Send(request) - Reduzierung unnötiger Indirektionen, wodurch Tests übersichtlicher und leichter lesbar werden
This commit is contained in:
parent
dc42a76f31
commit
14a565d202
@ -16,7 +16,7 @@ public class HistoryTests
|
|||||||
{
|
{
|
||||||
private IHost _host;
|
private IHost _host;
|
||||||
|
|
||||||
private IServiceProvider Provider => _host.Services;
|
private IMediator Mediator => _host.Services.GetRequiredService<IMediator>();
|
||||||
|
|
||||||
[SetUp]
|
[SetUp]
|
||||||
public void Setup()
|
public void Setup()
|
||||||
@ -50,12 +50,6 @@ public class HistoryTests
|
|||||||
_host.Dispose();
|
_host.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task<TResponse> Send<TResponse>(IRequest<TResponse> request)
|
|
||||||
{
|
|
||||||
var mediator = Provider.GetRequiredService<IMediator>();
|
|
||||||
return await mediator.Send(request);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public async Task CreateHistory_And_ReadHistory_Should_Work()
|
public async Task CreateHistory_And_ReadHistory_Should_Work()
|
||||||
{
|
{
|
||||||
@ -69,14 +63,14 @@ public class HistoryTests
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var id = await Send(createCmd);
|
var id = await Mediator.Send(createCmd);
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.That(id, Is.Not.Null);
|
Assert.That(id, Is.Not.Null);
|
||||||
|
|
||||||
// ReadHistory sorgusu
|
// ReadHistory sorgusu
|
||||||
var query = new ReadHistoryQuery(1);
|
var query = new ReadHistoryQuery(1);
|
||||||
var result = await Send(query);
|
var result = await Mediator.Send(query);
|
||||||
|
|
||||||
Assert.That(result, Is.Not.Empty);
|
Assert.That(result, Is.Not.Empty);
|
||||||
}
|
}
|
||||||
@ -99,11 +93,11 @@ public class HistoryTests
|
|||||||
Status = Constants.EnvelopeStatus.EnvelopePartlySigned
|
Status = Constants.EnvelopeStatus.EnvelopePartlySigned
|
||||||
};
|
};
|
||||||
|
|
||||||
await Send(createCmd1);
|
await Mediator.Send(createCmd1);
|
||||||
await Send(createCmd2);
|
await Mediator.Send(createCmd2);
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var result = await Send(new ReadHistoryQuery(2, Constants.EnvelopeStatus.EnvelopePartlySigned));
|
var result = await Mediator.Send(new ReadHistoryQuery(2, Constants.EnvelopeStatus.EnvelopePartlySigned));
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.That(result, Has.Exactly(1).Items);
|
Assert.That(result, Has.Exactly(1).Items);
|
||||||
@ -115,7 +109,7 @@ public class HistoryTests
|
|||||||
public async Task ReadHistory_Should_Return_Empty_When_No_Record()
|
public async Task ReadHistory_Should_Return_Empty_When_No_Record()
|
||||||
{
|
{
|
||||||
// Act
|
// Act
|
||||||
var result = await Send(new ReadHistoryQuery(999));
|
var result = await Mediator.Send(new ReadHistoryQuery(999));
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.That(result, Is.Empty);
|
Assert.That(result, Is.Empty);
|
||||||
|
|||||||
@ -5,8 +5,6 @@ VisualStudioVersion = 17.5.33516.290
|
|||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "EnvelopeGenerator.BBTests", "EnvelopeGenerator.BBTests\EnvelopeGenerator.BBTests.vbproj", "{089D5634-FB6B-42D0-B912-7AA7457044E7}"
|
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "EnvelopeGenerator.BBTests", "EnvelopeGenerator.BBTests\EnvelopeGenerator.BBTests.vbproj", "{089D5634-FB6B-42D0-B912-7AA7457044E7}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "EnvelopeGenerator.Form", "EnvelopeGenerator.Form\EnvelopeGenerator.Form.vbproj", "{6D56C01F-D6CB-4D8A-BD3D-4FD34326998C}"
|
|
||||||
EndProject
|
|
||||||
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "EnvelopeGenerator.CommonServices", "EnvelopeGenerator.CommonServices\EnvelopeGenerator.CommonServices.vbproj", "{6EA0C51F-C2B1-4462-8198-3DE0B32B74F8}"
|
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "EnvelopeGenerator.CommonServices", "EnvelopeGenerator.CommonServices\EnvelopeGenerator.CommonServices.vbproj", "{6EA0C51F-C2B1-4462-8198-3DE0B32B74F8}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EnvelopeGenerator.Web", "EnvelopeGenerator.Web\EnvelopeGenerator.Web.csproj", "{5E0E17C0-FF5A-4246-BF87-1ADD85376A27}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EnvelopeGenerator.Web", "EnvelopeGenerator.Web\EnvelopeGenerator.Web.csproj", "{5E0E17C0-FF5A-4246-BF87-1ADD85376A27}"
|
||||||
@ -45,10 +43,6 @@ Global
|
|||||||
{089D5634-FB6B-42D0-B912-7AA7457044E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{089D5634-FB6B-42D0-B912-7AA7457044E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{089D5634-FB6B-42D0-B912-7AA7457044E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{089D5634-FB6B-42D0-B912-7AA7457044E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{089D5634-FB6B-42D0-B912-7AA7457044E7}.Release|Any CPU.Build.0 = Release|Any CPU
|
{089D5634-FB6B-42D0-B912-7AA7457044E7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{6D56C01F-D6CB-4D8A-BD3D-4FD34326998C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{6D56C01F-D6CB-4D8A-BD3D-4FD34326998C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{6D56C01F-D6CB-4D8A-BD3D-4FD34326998C}.Release|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{6D56C01F-D6CB-4D8A-BD3D-4FD34326998C}.Release|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{6EA0C51F-C2B1-4462-8198-3DE0B32B74F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{6EA0C51F-C2B1-4462-8198-3DE0B32B74F8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{6EA0C51F-C2B1-4462-8198-3DE0B32B74F8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{6EA0C51F-C2B1-4462-8198-3DE0B32B74F8}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{6EA0C51F-C2B1-4462-8198-3DE0B32B74F8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{6EA0C51F-C2B1-4462-8198-3DE0B32B74F8}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
@ -91,7 +85,6 @@ Global
|
|||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(NestedProjects) = preSolution
|
GlobalSection(NestedProjects) = preSolution
|
||||||
{089D5634-FB6B-42D0-B912-7AA7457044E7} = {0CBC2432-A561-4440-89BC-671B66A24146}
|
{089D5634-FB6B-42D0-B912-7AA7457044E7} = {0CBC2432-A561-4440-89BC-671B66A24146}
|
||||||
{6D56C01F-D6CB-4D8A-BD3D-4FD34326998C} = {E3C758DC-914D-4B7E-8457-0813F1FDB0CB}
|
|
||||||
{6EA0C51F-C2B1-4462-8198-3DE0B32B74F8} = {9943209E-1744-4944-B1BA-4F87FC1A0EEB}
|
{6EA0C51F-C2B1-4462-8198-3DE0B32B74F8} = {9943209E-1744-4944-B1BA-4F87FC1A0EEB}
|
||||||
{5E0E17C0-FF5A-4246-BF87-1ADD85376A27} = {E3C758DC-914D-4B7E-8457-0813F1FDB0CB}
|
{5E0E17C0-FF5A-4246-BF87-1ADD85376A27} = {E3C758DC-914D-4B7E-8457-0813F1FDB0CB}
|
||||||
{83ED2617-B398-4859-8F59-B38F8807E83E} = {9943209E-1744-4944-B1BA-4F87FC1A0EEB}
|
{83ED2617-B398-4859-8F59-B38F8807E83E} = {9943209E-1744-4944-B1BA-4F87FC1A0EEB}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user