Skip to content

Commit

Permalink
Update GivenMeteredDataForMeasurementPointTests.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
lasrinnil committed Dec 23, 2024
1 parent adc8e18 commit 1d3c3f4
Showing 1 changed file with 14 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,51 +12,32 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using System.Diagnostics.CodeAnalysis;
using System.Text;
using Energinet.DataHub.EDI.BuildingBlocks.Domain.Models;
using Energinet.DataHub.EDI.IntegrationTests.Fixtures;
using Energinet.DataHub.EDI.OutgoingMessages.IntegrationTests.DocumentAsserters;
using Energinet.DataHub.EDI.OutgoingMessages.Interfaces.Models.Peek;
using Energinet.DataHub.EDI.Tests.Infrastructure.OutgoingMessages.RSM012;
using FluentAssertions;
using FluentAssertions.Execution;
using NodaTime;
using NodaTime.Text;
using Xunit;
using Xunit.Abstractions;

namespace Energinet.DataHub.EDI.IntegrationTests.Behaviours.IncomingRequests;

[SuppressMessage(
"StyleCop.CSharp.ReadabilityRules",
"SA1118:Parameter should not span multiple lines",
Justification = "Readability")]
public sealed class GivenMeteredDataForMeasurementPointTests(
IntegrationTestFixture integrationTestFixture,
ITestOutputHelper testOutputHelper)
: MeteredDataForMeasurementPointBehaviourTestBase(integrationTestFixture, testOutputHelper)
{
public static TheoryData<DocumentFormat, DocumentFormat> RequestAndPeekFormatPairs
{
get
{
var data = new TheoryData<DocumentFormat, DocumentFormat>();
foreach (var requestFormat in (DocumentFormat[])[DocumentFormat.Json, DocumentFormat.Xml])
{
foreach (var peekFormat in (DocumentFormat[])[DocumentFormat.Json, DocumentFormat.Xml])
{
data.Add(requestFormat, peekFormat);
}
}

return data;
}
}
public static TheoryData<DocumentFormat> SupportedDocumentFormats =>
[
DocumentFormat.Json,
DocumentFormat.Xml,
];

[Theory]
[MemberData(nameof(RequestAndPeekFormatPairs))]
public async Task When_ActorPeeksAllMessages_Then_ReceivesOneDocumentWithCorrectContent(DocumentFormat requestFormat, DocumentFormat peekFormat)
[MemberData(nameof(SupportedDocumentFormats))]
public async Task When_ActorPeeksAllMessages_Then_ReceivesOneDocumentWithCorrectContent(DocumentFormat documentFormat)
{
// Arrange
var senderSpy = CreateServiceBusSenderSpy();
Expand All @@ -71,7 +52,7 @@ public async Task When_ActorPeeksAllMessages_Then_ReceivesOneDocumentWithCorrect
var transactionId2 = $"{transactionIdPrefix}-2";

await GivenReceivedMeteredDataForMeasurementPoint(
documentFormat: requestFormat,
documentFormat: documentFormat,
senderActorNumber: currentActor.ActorNumber,
[
(transactionId1,
Expand All @@ -92,7 +73,7 @@ await GivenReceivedMeteredDataForMeasurementPoint(
var peekResults = await WhenActorPeeksAllMessages(
ActorNumber.Create("8100000000115"),
ActorRole.EnergySupplier,
peekFormat);
documentFormat);

// Assert
peekResults.Should().HaveCount(2);
Expand All @@ -107,7 +88,7 @@ await GivenReceivedMeteredDataForMeasurementPoint(

await ThenNotifyValidatedMeasureDataDocumentIsCorrect(
peekResultDto.Bundle,
peekFormat,
documentFormat,
new NotifyValidatedMeasureDataDocumentAssertionInput(
new RequiredHeaderDocumentFields(
"E23",
Expand Down Expand Up @@ -161,10 +142,9 @@ await ThenNotifyValidatedMeasureDataDocumentIsCorrect(
}

[Theory]
[MemberData(nameof(RequestAndPeekFormatPairs))]
[MemberData(nameof(SupportedDocumentFormats))]
public async Task AndGiven_MessageIsEmpty_When_ActorPeeksAllMessages_Then_ReceivesNoMessages(
DocumentFormat requestFormat,
DocumentFormat peekFormat)
DocumentFormat documentFormat)
{
// Arrange
var senderSpy = CreateServiceBusSenderSpy();
Expand All @@ -174,7 +154,7 @@ public async Task AndGiven_MessageIsEmpty_When_ActorPeeksAllMessages_Then_Receiv
GivenAuthenticatedActorIs(currentActor.ActorNumber, currentActor.ActorRole);

await GivenReceivedMeteredDataForMeasurementPoint(
documentFormat: requestFormat,
documentFormat: documentFormat,
senderActorNumber: currentActor.ActorNumber,
[]);

Expand All @@ -184,7 +164,7 @@ await GivenReceivedMeteredDataForMeasurementPoint(
var peekResults = await WhenActorPeeksAllMessages(
ActorNumber.Create("8100000000115"),
ActorRole.EnergySupplier,
peekFormat);
documentFormat);

// Assert
peekResults.Should().BeEmpty();
Expand Down

0 comments on commit 1d3c3f4

Please sign in to comment.