Added missing event notification is AzureShellSettingsManager

--HG--
branch : dev
This commit is contained in:
Sebastien Ros
2010-05-17 17:39:17 -07:00
parent 3aa2cbe3d0
commit 9a0158036e
3 changed files with 13 additions and 5 deletions

View File

@@ -1,5 +1,4 @@
using System.IO; using System.Linq;
using System.Linq;
using Microsoft.WindowsAzure; using Microsoft.WindowsAzure;
using NUnit.Framework; using NUnit.Framework;
using Orchard.Azure.Environment.Configuration; using Orchard.Azure.Environment.Configuration;
@@ -15,7 +14,7 @@ namespace Orchard.Azure.Tests.Environment.Configuration {
CloudStorageAccount devAccount; CloudStorageAccount devAccount;
CloudStorageAccount.TryParse("UseDevelopmentStorage=true", out devAccount); CloudStorageAccount.TryParse("UseDevelopmentStorage=true", out devAccount);
Loader = new AzureShellSettingsManager(devAccount); Loader = new AzureShellSettingsManager(devAccount, new Moq.Mock<IShellSettingsManagerEventHandler>().Object);
} }
[SetUp] [SetUp]

View File

@@ -34,6 +34,10 @@
<Reference Include="Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" /> <Reference Include="Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="Microsoft.WindowsAzure.ServiceRuntime, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" /> <Reference Include="Microsoft.WindowsAzure.ServiceRuntime, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="Microsoft.WindowsAzure.StorageClient, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" /> <Reference Include="Microsoft.WindowsAzure.StorageClient, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Include="Moq, Version=4.0.812.4, Culture=neutral, PublicKeyToken=69f491c39445e920, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\moq\Moq.dll</HintPath>
</Reference>
<Reference Include="nunit.framework, Version=2.5.2.9222, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL"> <Reference Include="nunit.framework, Version=2.5.2.9222, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<HintPath>..\..\lib\nunit\nunit.framework.dll</HintPath> <HintPath>..\..\lib\nunit\nunit.framework.dll</HintPath>

View File

@@ -13,6 +13,7 @@ namespace Orchard.Azure.Environment.Configuration {
public class AzureShellSettingsManager : IShellSettingsManager { public class AzureShellSettingsManager : IShellSettingsManager {
public const string ContainerName = "sites"; // container names must be lower cased public const string ContainerName = "sites"; // container names must be lower cased
private readonly IShellSettingsManagerEventHandler _events;
private readonly CloudStorageAccount _storageAccount; private readonly CloudStorageAccount _storageAccount;
public CloudBlobClient BlobClient { get; private set; } public CloudBlobClient BlobClient { get; private set; }
@@ -21,14 +22,16 @@ namespace Orchard.Azure.Environment.Configuration {
Localizer T { get; [UsedImplicitly] Localizer T { get; [UsedImplicitly]
set; } set; }
public AzureShellSettingsManager() : this(CloudStorageAccount.FromConfigurationSetting("DataConnectionString")) public AzureShellSettingsManager(IShellSettingsManagerEventHandler events)
: this(CloudStorageAccount.FromConfigurationSetting("DataConnectionString"), events)
{ {
} }
public AzureShellSettingsManager(CloudStorageAccount storageAccount) public AzureShellSettingsManager(CloudStorageAccount storageAccount, IShellSettingsManagerEventHandler events)
{ {
// Setup the connection to custom storage accountm, e.g. Development Storage // Setup the connection to custom storage accountm, e.g. Development Storage
_storageAccount = storageAccount; _storageAccount = storageAccount;
_events = events;
BlobClient = _storageAccount.CreateCloudBlobClient(); BlobClient = _storageAccount.CreateCloudBlobClient();
@@ -54,6 +57,8 @@ namespace Orchard.Azure.Environment.Configuration {
var filePath =String.Concat(settings.Name, "/", "Settings.txt"); var filePath =String.Concat(settings.Name, "/", "Settings.txt");
var blob = Container.GetBlockBlobReference(filePath); var blob = Container.GetBlockBlobReference(filePath);
blob.UploadText(ComposeSettings(settings)); blob.UploadText(ComposeSettings(settings));
_events.Saved(settings);
} }
IEnumerable<ShellSettings> LoadSettings() { IEnumerable<ShellSettings> LoadSettings() {