Fix CancelMultipleBackup test failure (#399)

* Fix cancelMultipleBackup test failure
Please enter the commit message for your changes. Lines starting

* Add semaphore to backup stub operation

* remove spaces
This commit is contained in:
Kate Shin
2017-07-05 22:12:41 -07:00
committed by GitHub
parent bcd20af05e
commit b6c8eac8fc
3 changed files with 53 additions and 29 deletions

View File

@@ -7,6 +7,7 @@ using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlTools.ServiceLayer.Admin;
using Microsoft.SqlTools.ServiceLayer.DisasterRecovery;
using Microsoft.SqlTools.ServiceLayer.DisasterRecovery.Contracts;
using System;
using System.Data.SqlClient;
using System.Threading;
@@ -17,6 +18,14 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
/// </summary>
public class BackupOperationStub : IBackupOperation
{
public SemaphoreSlim BackupSemaphore { get; set; }
public BackupOperationStub()
{
this.BackupSemaphore = new SemaphoreSlim(0, 1);
}
/// <summary>
/// Initialize
/// </summary>
@@ -49,7 +58,7 @@ namespace Microsoft.SqlTools.ServiceLayer.UnitTests.DisasterRecovery
/// </summary>
public void PerformBackup()
{
Thread.Sleep(500);
this.BackupSemaphore.Wait(TimeSpan.FromSeconds(5));
}
/// <summary>