mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Implemented AzureShellSettingsManager
Refactored common used methods into AzureHelper Added unit tests from DefaultSettingsManagerTests class --HG-- branch : dev
This commit is contained in:
62
src/Orchard.Azure.Tests/AzureVirtualEnvironmentTest.cs
Normal file
62
src/Orchard.Azure.Tests/AzureVirtualEnvironmentTest.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using System.Configuration;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using Microsoft.WindowsAzure.StorageClient;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace Orchard.Azure.Tests {
|
||||
public abstract class AzureVirtualEnvironmentTest {
|
||||
private Process _dsService;
|
||||
|
||||
protected abstract void OnInit();
|
||||
|
||||
[TestFixtureSetUp]
|
||||
public void FixtureSetup() {
|
||||
var count = Process.GetProcessesByName("DSService").Length;
|
||||
if ( count == 0 ) {
|
||||
var start = new ProcessStartInfo {
|
||||
Arguments = "/devstore:start",
|
||||
FileName =
|
||||
Path.Combine(ConfigurationManager.AppSettings["AzureSDK"], @"bin\csrun.exe")
|
||||
};
|
||||
|
||||
_dsService = new Process { StartInfo = start };
|
||||
_dsService.Start();
|
||||
_dsService.WaitForExit();
|
||||
}
|
||||
|
||||
OnInit();
|
||||
}
|
||||
|
||||
[TestFixtureTearDown]
|
||||
public void FixtureTearDown() {
|
||||
|
||||
if ( _dsService != null )
|
||||
_dsService.Close();
|
||||
}
|
||||
|
||||
protected void DeleteAllBlobs(CloudBlobContainer container) {
|
||||
foreach ( var blob in container.ListBlobs() ) {
|
||||
if ( blob is CloudBlob ) {
|
||||
( (CloudBlob)blob ).DeleteIfExists();
|
||||
}
|
||||
|
||||
if ( blob is CloudBlobDirectory ) {
|
||||
DeleteAllBlobs((CloudBlobDirectory)blob);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void DeleteAllBlobs(CloudBlobDirectory cloudBlobDirectory) {
|
||||
foreach ( var blob in cloudBlobDirectory.ListBlobs() ) {
|
||||
if ( blob is CloudBlob ) {
|
||||
( (CloudBlob)blob ).DeleteIfExists();
|
||||
}
|
||||
|
||||
if ( blob is CloudBlobDirectory ) {
|
||||
DeleteAllBlobs((CloudBlobDirectory)blob);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user