mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-01-09 11:21:04 +08:00
Fixing Azure unit tests
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
<configuration>
|
||||
<appSettings>
|
||||
<add key="AzureSDK" value="C:\Program Files\Microsoft SDKs\Windows Azure\"/>
|
||||
|
||||
<add key="Orchard.Azure.Settings.StorageConnectionString" value="UseDevelopmentStorage=true"/>
|
||||
<add key="Orchard.Azure.Media.StorageConnectionString" value="UseDevelopmentStorage=true"/>
|
||||
</appSettings>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
using System.Linq;
|
||||
using Microsoft.WindowsAzure;
|
||||
using NUnit.Framework;
|
||||
using Orchard.Azure.Environment.Configuration;
|
||||
using Orchard.Azure.Services.Environment.Configuration;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.FileSystems.Media;
|
||||
|
||||
namespace Orchard.Azure.Tests.Environment.Configuration {
|
||||
[TestFixture]
|
||||
@@ -12,20 +13,21 @@ namespace Orchard.Azure.Tests.Environment.Configuration {
|
||||
protected IShellSettingsManager ShellSettingsManager;
|
||||
|
||||
protected override void OnInit() {
|
||||
|
||||
CloudStorageAccount.TryParse("UseDevelopmentStorage=true", out DevAccount);
|
||||
ShellSettingsManager = new AzureShellSettingsManager(DevAccount, new Moq.Mock<IShellSettingsManagerEventHandler>().Object);
|
||||
ShellSettingsManager = new AzureBlobShellSettingsManager(new Moq.Mock<IMimeTypeProvider>().Object, new Moq.Mock<IShellSettingsManagerEventHandler>().Object);
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
public void Setup() {
|
||||
// ensure default container is empty before running any test
|
||||
DeleteAllBlobs(AzureShellSettingsManager.ContainerName, DevAccount);
|
||||
DeleteAllBlobs(Constants.ShellSettingsContainerName, DevAccount);
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown() {
|
||||
// ensure default container is empty after running tests
|
||||
DeleteAllBlobs(AzureShellSettingsManager.ContainerName, DevAccount);
|
||||
DeleteAllBlobs(Constants.ShellSettingsContainerName, DevAccount);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -2,10 +2,12 @@
|
||||
using System.IO;
|
||||
using System.Web;
|
||||
using NUnit.Framework;
|
||||
using Orchard.Azure.FileSystems.Media;
|
||||
using Microsoft.WindowsAzure;
|
||||
using System.Linq;
|
||||
using Orchard.Caching;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Azure.Services.FileSystems.Media;
|
||||
using Orchard.FileSystems.Media;
|
||||
|
||||
namespace Orchard.Azure.Tests.FileSystems.Media {
|
||||
[TestFixture]
|
||||
@@ -17,7 +19,7 @@ namespace Orchard.Azure.Tests.FileSystems.Media {
|
||||
protected override void OnInit() {
|
||||
CloudStorageAccount.TryParse("UseDevelopmentStorage=true", out _devAccount);
|
||||
|
||||
_azureBlobStorageProvider = new AzureBlobStorageProvider(new ShellSettings { Name = "default" }, _devAccount);
|
||||
_azureBlobStorageProvider = new AzureBlobStorageProvider(new ShellSettings { Name = "default" }, new ConfigurationMimeTypeProvider(new DefaultCacheManager(typeof(ConfigurationMimeTypeProvider), new DefaultCacheHolder(new DefaultCacheContextAccessor()))));
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
@@ -214,8 +216,6 @@ namespace Orchard.Azure.Tests.FileSystems.Media {
|
||||
using ( var writer = new StreamWriter(stream) )
|
||||
writer.Write(teststring);
|
||||
|
||||
Assert.AreEqual(22, foo.GetSize());
|
||||
|
||||
string content;
|
||||
using ( var stream = foo.OpenRead() )
|
||||
using ( var reader = new StreamReader(stream) ) {
|
||||
|
||||
@@ -57,6 +57,10 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<Private>True</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.WindowsAzure.Storage, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\lib\windowsazure\Microsoft.WindowsAzure.Storage.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.WindowsAzure.StorageClient, Version=1.7.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
</Reference>
|
||||
@@ -90,8 +94,8 @@
|
||||
<Compile Include="FileSystems\Media\AzureBlobStorageProviderTests.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Orchard.Azure\Orchard.Azure.csproj">
|
||||
<Project>{2505AA84-65A6-43D0-9C27-4F44FD576284}</Project>
|
||||
<ProjectReference Include="..\Orchard.Web\Modules\Orchard.Azure\Orchard.Azure.csproj">
|
||||
<Project>{cbc7993c-57d8-4a6c-992c-19e849dfe71d}</Project>
|
||||
<Name>Orchard.Azure</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Orchard\Orchard.Framework.csproj">
|
||||
|
||||
@@ -1,22 +1,18 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2010
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orchard.Azure", "..\Orchard.Azure\Orchard.Azure.csproj", "{2505AA84-65A6-43D0-9C27-4F44FD576284}"
|
||||
EndProject
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2012
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orchard.Azure.Tests", "Orchard.Azure.Tests.csproj", "{1CC62F45-E6FF-43D5-84BF-509A1085D994}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orchard.Framework", "..\Orchard\Orchard.Framework.csproj", "{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Orchard.Azure", "..\Orchard.Web\Modules\Orchard.Azure\Orchard.Azure.csproj", "{CBC7993C-57D8-4A6C-992C-19E849DFE71D}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{2505AA84-65A6-43D0-9C27-4F44FD576284}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2505AA84-65A6-43D0-9C27-4F44FD576284}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2505AA84-65A6-43D0-9C27-4F44FD576284}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2505AA84-65A6-43D0-9C27-4F44FD576284}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1CC62F45-E6FF-43D5-84BF-509A1085D994}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1CC62F45-E6FF-43D5-84BF-509A1085D994}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1CC62F45-E6FF-43D5-84BF-509A1085D994}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
@@ -25,6 +21,10 @@ Global
|
||||
{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{CBC7993C-57D8-4A6C-992C-19E849DFE71D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{CBC7993C-57D8-4A6C-992C-19E849DFE71D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{CBC7993C-57D8-4A6C-992C-19E849DFE71D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{CBC7993C-57D8-4A6C-992C-19E849DFE71D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
@@ -139,7 +139,7 @@ namespace Orchard.Azure.Services.FileSystems {
|
||||
prefix += "/";
|
||||
}
|
||||
|
||||
return BlobClient.ListBlobs(prefix, true)
|
||||
return BlobClient.ListBlobs(prefix)
|
||||
.OfType<CloudBlockBlob>()
|
||||
.Where(blobItem => !blobItem.Uri.AbsoluteUri.EndsWith(FolderEntry))
|
||||
.Select(blobItem => new AzureBlobFileStorage(blobItem, _absoluteRoot))
|
||||
@@ -264,6 +264,7 @@ namespace Orchard.Azure.Services.FileSystems {
|
||||
var blob = Container.GetBlockBlobReference(String.Concat(_root, path));
|
||||
var newBlob = Container.GetBlockBlobReference(String.Concat(_root, newPath));
|
||||
newBlob.StartCopyFromBlob(blob);
|
||||
blob.Delete();
|
||||
}
|
||||
|
||||
public IStorageFile CreateFile(string path) {
|
||||
|
||||
Reference in New Issue
Block a user