Пример #1
0
        public async Task WithTryOnceSynchronizationStrategyExecuteOnceIfFails()
        {
            // Arrange
            SynchronizationStrategy = SchemaSynchronizationStrategy.TryOnce;
            DatabaseDriver.CreateConnection(ConnectionString)
            .Returns(
                x => throw new ApplicationException(),
                x => throw new ApplicationException(),
                x => DbConnection);

            var target = GetTarget();

            // Act
            try
            {
                await target.SynchronizeSchemaAsync(ConnectionString, DatabaseDriver, CancellationToken);
            }
            catch (ApplicationException) { }
            await target.SynchronizeSchemaAsync(ConnectionString, DatabaseDriver, CancellationToken);

            await target.SynchronizeSchemaAsync(ConnectionString, DatabaseDriver, CancellationToken);

            // Assert
            DatabaseDriver.Received(1).CreateConnection(ConnectionString);
        }
Пример #2
0
        public async Task WithUntilSuccessSynchronizationStrategyExecuteOneIfSucceed()
        {
            // Arrange
            SynchronizationStrategy = SchemaSynchronizationStrategy.UntilSuccess;
            var target = GetTarget();

            // Act
            await target.SynchronizeSchemaAsync(ConnectionString, DatabaseDriver, CancellationToken);

            await target.SynchronizeSchemaAsync(ConnectionString, DatabaseDriver, CancellationToken);

            // Assert
            DatabaseDriver.Received(1).CreateConnection(ConnectionString);
        }