Exemplo n.º 1
0
        public async Task WaitForBundleContentFromSubDomainAsync_NoData_ReturnsNull()
        {
            // Arrange
            var marketOperatorDataStorageServiceMock = new Mock <IMarketOperatorDataStorageService>();
            var dataBundleRequestSenderMock          = new Mock <IDataBundleRequestSender>();
            var target = new BundleContentRequestService(
                new Mock <ILogger>().Object,
                marketOperatorDataStorageServiceMock.Object,
                dataBundleRequestSenderMock.Object,
                new Mock <ICorrelationContext>().Object);

            var bundle = new Bundle(
                new Uuid(Guid.NewGuid()),
                new LegacyActorId(new GlobalLocationNumber("fake_value")),
                DomainOrigin.TimeSeries,
                new ContentType("fake_value"),
                Array.Empty <Uuid>(),
                Enumerable.Empty <string>());

            dataBundleRequestSenderMock
            .Setup(x => x.SendAsync(It.IsAny <DataBundleRequestDto>(), MessageHub.Model.Model.DomainOrigin.TimeSeries))
            .ReturnsAsync((DataBundleResponseDto?)null);

            // Act
            var actual = await target.WaitForBundleContentFromSubDomainAsync(bundle).ConfigureAwait(false);

            // Assert
            Assert.Null(actual);
        }
Exemplo n.º 2
0
        public async Task WaitForBundleContentFromSubDomainAsync_WithData_ReturnsData()
        {
            // Arrange
            var marketOperatorDataStorageServiceMock = new Mock <IMarketOperatorDataStorageService>();
            var dataBundleRequestSenderMock          = new Mock <IDataBundleRequestSender>();
            var target = new BundleContentRequestService(
                new Mock <ILogger>().Object,
                marketOperatorDataStorageServiceMock.Object,
                dataBundleRequestSenderMock.Object,
                new Mock <ICorrelationContext>().Object);

            var bundle = new Bundle(
                new Uuid(Guid.NewGuid()),
                new LegacyActorId(new GlobalLocationNumber("fake_value")),
                DomainOrigin.TimeSeries,
                new ContentType("fake_value"),
                Array.Empty <Uuid>(),
                Enumerable.Empty <string>());

            var contentUri = new Uri("https://test.test.dk");
            var response   = new DataBundleResponseDto(
                Guid.NewGuid(),
                string.Empty,
                contentUri);

            dataBundleRequestSenderMock
            .Setup(x => x.SendAsync(It.IsAny <DataBundleRequestDto>(), MessageHub.Model.Model.DomainOrigin.TimeSeries))
            .ReturnsAsync(response);

            // Act
            var actual = (AzureBlobBundleContent?)await target.WaitForBundleContentFromSubDomainAsync(bundle).ConfigureAwait(false);

            // Assert
            Assert.NotNull(actual);
            Assert.Equal(contentUri, actual !.ContentPath);
        }