Esempio n. 1
0
        public void ServiceLayer_DeleteQueues_DataLayerException_ShouldRethrow(Mock <IQueueManager> queueManagerMock, string exceptionMessage)
        {
            // Setup
            ServiceLayer serviceLayer = new ServiceLayer(
                _eventGridManager,
                queueManagerMock.Object,
                _tableManager,
                _log);

            DataCleanupParameters parameters = TestValues.GetDataCleanupParameters();
            Func <Task>           act        = async() => await serviceLayer.DeleteQueues(parameters);

            // Act
            act.Should().Throw <RequestFailedException>().WithMessage(exceptionMessage);

            // Verify
            _log.Messages.Should().HaveCount(2);
            _log.Messages[0].Message.Should().Be("Queue deletion starting.");
            _log.Messages[1].Message.Should().Be("Exception encountered in DeleteQueues method.");
        }
Esempio n. 2
0
        public async Task ServiceLayer_DeleteQueues_UsingMoq_ShouldWork(List <string> queueList)
        {
            // Setup
            (Mock <IQueueManager> queueManagerMock, List <string> deletedQueueList) = GetMockQueueManager(queueList);

            ServiceLayer serviceLayer = new ServiceLayer(
                _eventGridManager,
                queueManagerMock.Object,
                _tableManager,
                _log);

            DataCleanupParameters parameters = TestValues.GetDataCleanupParameters();

            // Act
            await serviceLayer.DeleteQueues(parameters);

            // Verify
            queueManagerMock.Verify();
            deletedQueueList.Count.Should().Be(queueList?.Count ?? 0);
            deletedQueueList.Should().BeEquivalentTo(queueList ?? new List <string>());
            _log.Messages.Should().HaveCount(2);
            _log.Messages[0].Message.Should().Be("Queue deletion starting.");
            _log.Messages[1].Message.Should().Be($"Queue deletion completed! Removed {queueList?.Count ?? 0} queues.");
        }