Implemented AzureShellSettingsManager

Refactored common used methods into AzureHelper
Added unit tests from DefaultSettingsManagerTests class

--HG--
branch : dev
This commit is contained in:
Sebastien Ros
2010-04-26 14:58:29 -07:00
parent 97f8ed294e
commit 4b52a0aee1
8 changed files with 399 additions and 200 deletions

View File

@@ -11,74 +11,21 @@ using System.Text;
namespace Orchard.Azure.Tests.Storage {
[TestFixture]
public class AzureBlobStorageProviderTests {
public class AzureBlobStorageProviderTests : AzureVirtualEnvironmentTest {
#region Azure Environment initialization
private Process _dsService;
[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();
}
private AzureBlobStorageProvider _azureBlobStorageProvider;
protected override void OnInit() {
CloudStorageAccount devAccount;
CloudStorageAccount.TryParse("UseDevelopmentStorage=true", out devAccount);
_azureBlobStorageProvider = new AzureBlobStorageProvider("default", devAccount);
}
[TestFixtureTearDown]
public void FixtureTearDown() {
if(_dsService != null)
_dsService.Close();
}
[SetUp]
public void Setup() {
// ensure default container is empty before running any test
DeleteAllBlobs();
}
#endregion
private AzureBlobStorageProvider _azureBlobStorageProvider;
private void DeleteAllBlobs() {
foreach(var blob in _azureBlobStorageProvider.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);
}
}
DeleteAllBlobs(_azureBlobStorageProvider.Container);
}
[Test]
@@ -131,8 +78,7 @@ namespace Orchard.Azure.Tests.Storage {
}
[Test]
public void CreateFileShouldBeFolderAgnostic()
{
public void CreateFileShouldBeFolderAgnostic() {
_azureBlobStorageProvider.CreateFile("foo.txt");
_azureBlobStorageProvider.CreateFile("folder/foo.txt");
_azureBlobStorageProvider.CreateFile("folder/folder/foo.txt");
@@ -193,9 +139,9 @@ namespace Orchard.Azure.Tests.Storage {
var foo = _azureBlobStorageProvider.CreateFile("folder1/foo.txt");
using(var stream = foo.OpenWrite())
using (var writer = new StreamWriter(stream))
writer.Write(teststring);
using ( var stream = foo.OpenWrite() )
using ( var writer = new StreamWriter(stream) )
writer.Write(teststring);
Assert.AreEqual(22, foo.GetSize());