public async Task Aborting_Unhides_The_TimeoutEntities_even_when_preparing_failed()
        {
            // Arrange
            var endpointName   = nameof(Aborting_Unhides_The_TimeoutEntities);
            var timeoutsSource = new AspTimeoutsSource(connectionString, 1, containerName, fakeEndpointName, fakeEndpointTimeoutTableName, tablePrefix: tableNamePrefix);
            var cutOffDate     = DateTime.UtcNow;

            var endpointTimeoutTableName = tableClient.GetTableReference($"{tableNamePrefix}{fakeEndpointTimeoutTableName}");
            await endpointTimeoutTableName.CreateIfNotExistsAsync();

            var toolStateTable = tableClient.GetTableReference($"{tableNamePrefix}{AspConstants.ToolStateTableName}");
            await toolStateTable.CreateIfNotExistsAsync();

            var uniqueHiddenEndpointName = string.Format(AspConstants.MigrationHiddenEndpointNameFormat, "gurlugurlu", endpointName);
            var toolStateEntity          = new ToolStateEntity()
            {
                Status = MigrationStatus.Preparing, EndpointName = endpointName, PartitionKey = ToolStateEntity.FixedPartitionKey, RowKey = "bar", UniqueHiddenEndpointName = uniqueHiddenEndpointName
            };

            await toolStateTable.ExecuteAsync(TableOperation.Insert(toolStateEntity));

            for (var x = 0; x < 3; x++)
            {
                var dateTime = cutOffDate.AddDays(random.Next(1, 5));

                var entity = new TimeoutDataEntity(dateTime.ToString(AspConstants.PartitionKeyScope), Guid.NewGuid().ToString())
                {
                    OwningTimeoutManager = uniqueHiddenEndpointName,
                    Destination          = endpointName,
                    SagaId       = Guid.NewGuid(),
                    StateAddress = x.ToString(),
                    Time         = dateTime,
                    Headers      = "Headers",
                };

                await endpointTimeoutTableName.ExecuteAsync(TableOperation.Insert(entity));
            }

            // Act
            await timeoutsSource.Abort();

            // Assert
            var query = new TableQuery <TimeoutDataEntity>()
                        .Where(TableQuery.GenerateFilterCondition("OwningTimeoutManager", QueryComparisons.Equal, endpointName));
            var timeouts = await endpointTimeoutTableName.ExecuteQuerySegmentedAsync(query, null);

            Assert.AreEqual(3, timeouts.Results.Count);

            var currentAfterAborting = await timeoutsSource.TryLoadOngoingMigration();

            Assert.IsNull(currentAfterAborting);

            Assert.IsFalse(await timeoutsSource.CheckIfAMigrationIsInProgress());
        }
        public async Task Aborting_Returns_StagedTimeouts_Back_To_TimeoutEntity_Table()
        {
            // Arrange
            var endpointName   = nameof(Aborting_Returns_StagedTimeouts_Back_To_TimeoutEntity_Table);
            var timeoutsSource = new AspTimeoutsSource(connectionString, 1, containerName, fakeEndpointName, fakeEndpointTimeoutTableName, tablePrefix: tableNamePrefix);
            var runParameters  = new Dictionary <string, string> {
                { "Test", "TestValue" }
            };
            var cutOffDate = DateTime.UtcNow;

            var endpointTimeoutTableName = tableClient.GetTableReference($"{tableNamePrefix}{fakeEndpointTimeoutTableName}");
            await endpointTimeoutTableName.CreateIfNotExistsAsync();

            for (var x = 0; x < 3; x++)
            {
                var dateTime = cutOffDate.AddDays(random.Next(1, 5));

                var entity = new TimeoutDataEntity(dateTime.ToString(AspConstants.PartitionKeyScope), Guid.NewGuid().ToString())
                {
                    OwningTimeoutManager = endpointName,
                    Destination          = endpointName,
                    SagaId       = Guid.NewGuid(),
                    StateAddress = x.ToString(),
                    Time         = dateTime,
                    Headers      = "Headers",
                };

                await endpointTimeoutTableName.ExecuteAsync(TableOperation.Insert(entity));
            }

            await timeoutsSource.Prepare(cutOffDate, endpointName, runParameters);

            // Act
            await timeoutsSource.Abort();

            // Assert
            var query = new TableQuery <TimeoutDataEntity>()
                        .Where(TableQuery.GenerateFilterCondition("OwningTimeoutManager", QueryComparisons.Equal, endpointName));
            var timeouts = await endpointTimeoutTableName.ExecuteQuerySegmentedAsync(query, null);

            Assert.AreEqual(3, timeouts.Results.Count);

            var currentAfterAborting = await timeoutsSource.TryLoadOngoingMigration();

            Assert.IsNull(currentAfterAborting);
        }