public async Task Dequeue_HasData_ReturnsIsDequeued() { // Arrange var recipientGln = new MockedGln(); var bundleId = Guid.NewGuid().ToString(); await AddDataAvailableNotificationAsync(recipientGln).ConfigureAwait(false); await using var host = await MarketOperatorIntegrationTestHost .InitializeAsync() .ConfigureAwait(false); await using var scope = host.BeginScope(); var mediator = scope.GetInstance <IMediator>(); var peekResponse = await mediator.Send(new PeekCommand(recipientGln, bundleId)).ConfigureAwait(false); var bundleUuid = await ReadBundleIdAsync(peekResponse).ConfigureAwait(false); var dequeueCommand = new DequeueCommand(recipientGln, bundleUuid); // Act var response = await mediator.Send(dequeueCommand).ConfigureAwait(false); // Assert Assert.NotNull(response); Assert.True(response.IsDequeued); }
public async Task InsertDataAvailableNotificationsCommand_WithData_CanBePeekedBack() { // Arrange var recipientGln = new MockedGln(); var bundleId = Guid.NewGuid().ToString(); await using var host = await MarketOperatorIntegrationTestHost .InitializeAsync() .ConfigureAwait(false); await using var scope = host.BeginScope(); var mediator = scope.GetInstance <IMediator>(); var dataAvailableNotification = new DataAvailableNotificationDto( Guid.NewGuid().ToString(), recipientGln, "timeseries", "timeseries", false, 1, 1, "RSM??"); var command = new InsertDataAvailableNotificationsCommand(new[] { dataAvailableNotification }); // Act await mediator.Send(command).ConfigureAwait(false); // Assert var peekResponse = await mediator.Send(new PeekCommand(recipientGln, bundleId)).ConfigureAwait(false); Assert.NotNull(peekResponse); Assert.True(peekResponse.HasContent); }
public async Task PeekMasterDataCommand_SingleNotificationMultiplePeek_ReturnsData() { // Arrange var recipientGln = new MockedGln(); var bundleId = Guid.NewGuid().ToString(); await AddMeteringPointsNotificationAsync(recipientGln).ConfigureAwait(false); await using var host = await MarketOperatorIntegrationTestHost .InitializeAsync() .ConfigureAwait(false); await using var scope = host.BeginScope(); var mediator = scope.GetInstance <IMediator>(); var peekCommand = new PeekMasterDataCommand(recipientGln, bundleId); // Act var responseA = await mediator.Send(peekCommand).ConfigureAwait(false); var responseB = await mediator.Send(peekCommand).ConfigureAwait(false); // Assert Assert.NotNull(responseA); Assert.True(responseA.HasContent); Assert.NotNull(responseB); Assert.True(responseB.HasContent); }
public async Task PeekCommand_Empty_ReturnsNothing() { // Arrange var recipientGln = new MockedGln(); var unrelatedGln = new MockedGln(); var bundleId = Guid.NewGuid().ToString(); await AddTimeSeriesNotificationAsync(unrelatedGln).ConfigureAwait(false); await using var host = await MarketOperatorIntegrationTestHost .InitializeAsync() .ConfigureAwait(false); await using var scope = host.BeginScope(); var mediator = scope.GetInstance <IMediator>(); var peekCommand = new PeekCommand(recipientGln, bundleId); // Act var response = await mediator.Send(peekCommand).ConfigureAwait(false); // Assert Assert.NotNull(response); Assert.False(response.HasContent); }
public async Task InsertDataAvailableNotificationsCommand_PeekInsertDequeueSequence_CanBePeekedBack() { // Arrange var recipientGln = new MockedGln(); var bundleIdA = Guid.NewGuid().ToString(); var bundleIdB = Guid.NewGuid().ToString(); await using var host = await MarketOperatorIntegrationTestHost .InitializeAsync() .ConfigureAwait(false); await using var scope = host.BeginScope(); var mediator = scope.GetInstance <IMediator>(); var dataAvailableNotificationA = new DataAvailableNotificationDto( Guid.NewGuid().ToString(), recipientGln, "MeteringPoints", "MeteringPoints", true, 1, 1, "RSM??"); var dataAvailableNotificationB = new DataAvailableNotificationDto( Guid.NewGuid().ToString(), dataAvailableNotificationA.Recipient, dataAvailableNotificationA.ContentType, dataAvailableNotificationA.Origin, dataAvailableNotificationA.SupportsBundling, dataAvailableNotificationA.Weight, 2, dataAvailableNotificationA.DocumentType); await mediator .Send(new InsertDataAvailableNotificationsCommand(new[] { dataAvailableNotificationA })) .ConfigureAwait(false); // Act await mediator.Send(new PeekCommand(recipientGln, bundleIdA)).ConfigureAwait(false); await mediator .Send(new InsertDataAvailableNotificationsCommand(new[] { dataAvailableNotificationB })) .ConfigureAwait(false); await mediator.Send(new DequeueCommand(recipientGln, bundleIdA)).ConfigureAwait(false); // Assert var peekResponse = await mediator .Send(new PeekCommand(recipientGln, bundleIdB)) .ConfigureAwait(false); Assert.True(peekResponse.HasContent); }
public async Task Dequeue_NoData_ReturnsNotDequeued() { // Arrange var recipientGln = new MockedGln(); var bundleUuid = Guid.NewGuid().ToString(); await using var host = await MarketOperatorIntegrationTestHost .InitializeAsync() .ConfigureAwait(false); await using var scope = host.BeginScope(); var mediator = scope.GetInstance <IMediator>(); var dequeueCommand = new DequeueCommand(recipientGln, bundleUuid); // Act var response = await mediator.Send(dequeueCommand).ConfigureAwait(false); // Assert Assert.NotNull(response); Assert.False(response.IsDequeued); }
public async Task PeekMasterDataCommand_AllNotificationsCanBundle_ReturnsBundle() { // Arrange var recipientGln = new MockedGln(); var expectedGuidA = await AddBundlingNotificationAsync(recipientGln, "MeteringPoints", true).ConfigureAwait(false); var expectedGuidB = await AddBundlingNotificationAsync(recipientGln, "MeteringPoints", true).ConfigureAwait(false); var expectedGuidC = await AddBundlingNotificationAsync(recipientGln, "MeteringPoints", true).ConfigureAwait(false); var bundleId = Guid.NewGuid().ToString(); await using var host = await MarketOperatorIntegrationTestHost .InitializeAsync() .ConfigureAwait(false); await using var scope = host.BeginScope(); var mediator = scope.GetInstance <IMediator>(); var peekCommand = new PeekMasterDataCommand(recipientGln, bundleId); // Act var response = await mediator.Send(peekCommand).ConfigureAwait(false); // Assert Assert.NotNull(response); Assert.True(response.HasContent); var bundleContents = await response.Data.ReadAsDataBundleRequestAsync().ConfigureAwait(false); var dataAvailableNotificationIds = await bundleContents.GetDataAvailableIdsAsync(scope).ConfigureAwait(false); Assert.Equal(3, dataAvailableNotificationIds.Count); Assert.Contains(expectedGuidA, dataAvailableNotificationIds); Assert.Contains(expectedGuidB, dataAvailableNotificationIds); Assert.Contains(expectedGuidC, dataAvailableNotificationIds); }
public async Task PeekAggregationsCommand_NotificationCannotBundle_ReturnsFirstNotification(bool first, bool second, bool third) { // Arrange var recipientGln = new MockedGln(); var expectedGuid = await AddBundlingNotificationAsync(recipientGln, "Aggregations", first).ConfigureAwait(false); var unexpectedGuidA = await AddBundlingNotificationAsync(recipientGln, "Aggregations", second).ConfigureAwait(false); var unexpectedGuidB = await AddBundlingNotificationAsync(recipientGln, "Aggregations", third).ConfigureAwait(false); var bundleId = Guid.NewGuid().ToString(); await using var host = await MarketOperatorIntegrationTestHost .InitializeAsync() .ConfigureAwait(false); await using var scope = host.BeginScope(); var mediator = scope.GetInstance <IMediator>(); var peekCommand = new PeekAggregationsCommand(recipientGln, bundleId); // Act var response = await mediator.Send(peekCommand).ConfigureAwait(false); // Assert Assert.NotNull(response); Assert.True(response.HasContent); var bundleContents = await response.Data.ReadAsDataBundleRequestAsync().ConfigureAwait(false); var dataAvailableNotificationIds = await bundleContents.GetDataAvailableIdsAsync(scope).ConfigureAwait(false); Assert.Single(dataAvailableNotificationIds); Assert.Contains(expectedGuid, dataAvailableNotificationIds); Assert.DoesNotContain(unexpectedGuidA, dataAvailableNotificationIds); Assert.DoesNotContain(unexpectedGuidB, dataAvailableNotificationIds); }