From a198decc70a5411407989fd58b85cf98f1cff717 Mon Sep 17 00:00:00 2001 From: Lombiq Date: Thu, 31 Mar 2016 13:17:20 -0700 Subject: [PATCH] Updating Azure Tests --- src/Orchard.Azure.Tests/App.config | 2 +- .../AzureVirtualEnvironmentTest.cs | 59 +++++++++++-------- .../Media/AzureBlobStorageProviderTests.cs | 4 +- .../Orchard.Azure.Tests.csproj | 16 +++-- src/Orchard.Azure.Tests/packages.config | 2 + .../Orchard.Core.Tests.csproj | 4 +- src/Orchard.Core.Tests/packages.config | 2 +- .../Orchard.Tests.Modules.csproj | 4 +- src/Orchard.Tests.Modules/packages.config | 2 +- .../Orchard.Framework.Tests.csproj | 4 +- src/Orchard.Tests/packages.config | 2 +- .../AzureBlobShellSettingsManager.cs | 11 +++- .../Tests/Orchard.Projections.Tests.csproj | 4 +- .../Orchard.Projections/Tests/packages.config | 2 +- src/Rebracer.xml | 4 +- src/Tools/Orchard.Tests/Orchard.Tests.csproj | 4 +- src/Tools/Orchard.Tests/packages.config | 2 +- 17 files changed, 79 insertions(+), 49 deletions(-) diff --git a/src/Orchard.Azure.Tests/App.config b/src/Orchard.Azure.Tests/App.config index fad8a38c7..391caa272 100644 --- a/src/Orchard.Azure.Tests/App.config +++ b/src/Orchard.Azure.Tests/App.config @@ -1,7 +1,7 @@  - + diff --git a/src/Orchard.Azure.Tests/AzureVirtualEnvironmentTest.cs b/src/Orchard.Azure.Tests/AzureVirtualEnvironmentTest.cs index a481a2bec..8980cf327 100644 --- a/src/Orchard.Azure.Tests/AzureVirtualEnvironmentTest.cs +++ b/src/Orchard.Azure.Tests/AzureVirtualEnvironmentTest.cs @@ -1,28 +1,43 @@ -using System.Configuration; +using System; +using System.Configuration; using System.Diagnostics; using System.IO; +using System.Linq; using Microsoft.WindowsAzure.Storage; using Microsoft.WindowsAzure.Storage.Blob; using NUnit.Framework; namespace Orchard.Azure.Tests { public abstract class AzureVirtualEnvironmentTest { - private Process _dsService; + private Process _storageEmulator; 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"], @"emulator\csrun.exe") + if (!Process.GetProcessesByName("AzureStorageEmulator").Any()) { + var azureSDKPath = ConfigurationManager.AppSettings["AzureSDK"]; + var storageEmulatorRelativePath = "Storage Emulator\\AzureStorageEmulator.exe"; + + if (String.IsNullOrEmpty(azureSDKPath)) { + throw new ConfigurationErrorsException("Could not find the AppSetting \"AzureSDK\" that indicates the path to the Azure SDK on the local file system."); + } + + var storageEmulatorAbsolutePath = Path.Combine(azureSDKPath, storageEmulatorRelativePath); + + if (!File.Exists(storageEmulatorAbsolutePath)) { + throw new ConfigurationErrorsException("Could not find the executable to start the Azure Storage Emulator."); + } + + var storageEmulatorStartInfo = new ProcessStartInfo { + Arguments = "start", + FileName = storageEmulatorAbsolutePath }; - _dsService = new Process { StartInfo = start }; - _dsService.Start(); - _dsService.WaitForExit(); + _storageEmulator = new Process { StartInfo = storageEmulatorStartInfo }; + _storageEmulator.Start(); + _storageEmulator.WaitForExit(); } OnInit(); @@ -30,34 +45,32 @@ namespace Orchard.Azure.Tests { [TestFixtureTearDown] public void FixtureTearDown() { - - if ( _dsService != null ) - _dsService.Close(); + if (_storageEmulator != null) + _storageEmulator.Close(); } - protected void DeleteAllBlobs(string containerName, CloudStorageAccount account) - { + protected void DeleteAllBlobs(string containerName, CloudStorageAccount account) { var blobClient = account.CreateCloudBlobClient(); var container = blobClient.GetContainerReference(containerName); - foreach ( var blob in container.ListBlobs() ) { - if ( blob is CloudBlob ) { - ( (CloudBlob)blob ).DeleteIfExists(); + foreach (var blob in container.ListBlobs()) { + if (blob is CloudBlob) { + ((CloudBlob)blob).DeleteIfExists(); } - if ( blob is CloudBlobDirectory ) { + 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(); + foreach (var blob in cloudBlobDirectory.ListBlobs()) { + if (blob is CloudBlob) { + ((CloudBlob)blob).DeleteIfExists(); } - if ( blob is CloudBlobDirectory ) { + if (blob is CloudBlobDirectory) { DeleteAllBlobs((CloudBlobDirectory)blob); } } diff --git a/src/Orchard.Azure.Tests/FileSystems/Media/AzureBlobStorageProviderTests.cs b/src/Orchard.Azure.Tests/FileSystems/Media/AzureBlobStorageProviderTests.cs index 815b6736c..9bf1d3a20 100644 --- a/src/Orchard.Azure.Tests/FileSystems/Media/AzureBlobStorageProviderTests.cs +++ b/src/Orchard.Azure.Tests/FileSystems/Media/AzureBlobStorageProviderTests.cs @@ -269,11 +269,11 @@ namespace Orchard.Azure.Tests.FileSystems.Media { } [Test] - public void UnknownMimeTypeShouldBeAssigned() { + public void DefaultMimeTypeShouldBeAssigned() { _azureBlobStorageProvider.CreateFile("foo1.xyz"); var file = _azureBlobStorageProvider.Container.GetBlockBlobReference("default/foo1.xyz"); file.FetchAttributes(); - Assert.That(file.Properties.ContentType, Is.EqualTo("application/unknown")); + Assert.That(file.Properties.ContentType, Is.EqualTo("application/octet-stream")); } diff --git a/src/Orchard.Azure.Tests/Orchard.Azure.Tests.csproj b/src/Orchard.Azure.Tests/Orchard.Azure.Tests.csproj index 1d40b8301..0ffbf455e 100644 --- a/src/Orchard.Azure.Tests/Orchard.Azure.Tests.csproj +++ b/src/Orchard.Azure.Tests/Orchard.Azure.Tests.csproj @@ -80,16 +80,24 @@ True - ..\packages\Moq.4.2.1510.2205\lib\net40\Moq.dll + ..\packages\Moq.4.2.1510.2205\lib\NET40\Moq.dll True ..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll True - - False - ..\..\lib\nunit\nunit.framework.dll + + ..\packages\NUnit.2.5.10.11092\lib\nunit.framework.dll + True + + + ..\packages\NUnit.2.5.10.11092\lib\nunit.mocks.dll + True + + + ..\packages\NUnit.2.5.10.11092\lib\pnunit.framework.dll + True diff --git a/src/Orchard.Azure.Tests/packages.config b/src/Orchard.Azure.Tests/packages.config index dbe11a587..241602731 100644 --- a/src/Orchard.Azure.Tests/packages.config +++ b/src/Orchard.Azure.Tests/packages.config @@ -6,6 +6,8 @@ + + \ No newline at end of file diff --git a/src/Orchard.Core.Tests/Orchard.Core.Tests.csproj b/src/Orchard.Core.Tests/Orchard.Core.Tests.csproj index 7aa4ca540..e7843e528 100644 --- a/src/Orchard.Core.Tests/Orchard.Core.Tests.csproj +++ b/src/Orchard.Core.Tests/Orchard.Core.Tests.csproj @@ -73,8 +73,8 @@ ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll True - - ..\packages\Moq.4.0.10827\lib\NET40\Moq.dll + + ..\packages\Moq.4.2.1510.2205\lib\NET40\Moq.dll True diff --git a/src/Orchard.Core.Tests/packages.config b/src/Orchard.Core.Tests/packages.config index acebfbf18..351a65220 100644 --- a/src/Orchard.Core.Tests/packages.config +++ b/src/Orchard.Core.Tests/packages.config @@ -7,7 +7,7 @@ - + \ No newline at end of file diff --git a/src/Orchard.Tests.Modules/Orchard.Tests.Modules.csproj b/src/Orchard.Tests.Modules/Orchard.Tests.Modules.csproj index 6facc97e1..59450f75f 100644 --- a/src/Orchard.Tests.Modules/Orchard.Tests.Modules.csproj +++ b/src/Orchard.Tests.Modules/Orchard.Tests.Modules.csproj @@ -118,8 +118,8 @@ ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll True - - ..\packages\Moq.4.0.10827\lib\NET40\Moq.dll + + ..\packages\Moq.4.2.1510.2205\lib\NET40\Moq.dll True diff --git a/src/Orchard.Tests.Modules/packages.config b/src/Orchard.Tests.Modules/packages.config index 52f90a8e3..f5907c5b9 100644 --- a/src/Orchard.Tests.Modules/packages.config +++ b/src/Orchard.Tests.Modules/packages.config @@ -11,7 +11,7 @@ - + diff --git a/src/Orchard.Tests/Orchard.Framework.Tests.csproj b/src/Orchard.Tests/Orchard.Framework.Tests.csproj index c433d1879..4a39036af 100644 --- a/src/Orchard.Tests/Orchard.Framework.Tests.csproj +++ b/src/Orchard.Tests/Orchard.Framework.Tests.csproj @@ -110,8 +110,8 @@ ..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll True - - ..\packages\Moq.4.0.10827\lib\NET40\Moq.dll + + ..\packages\Moq.4.2.1510.2205\lib\NET40\Moq.dll True diff --git a/src/Orchard.Tests/packages.config b/src/Orchard.Tests/packages.config index a2dd05b2f..53387f572 100644 --- a/src/Orchard.Tests/packages.config +++ b/src/Orchard.Tests/packages.config @@ -13,7 +13,7 @@ - + diff --git a/src/Orchard.Web/Modules/Orchard.Azure/Services/Environment/Configuration/AzureBlobShellSettingsManager.cs b/src/Orchard.Web/Modules/Orchard.Azure/Services/Environment/Configuration/AzureBlobShellSettingsManager.cs index f950042d3..2ff20c7e9 100644 --- a/src/Orchard.Web/Modules/Orchard.Azure/Services/Environment/Configuration/AzureBlobShellSettingsManager.cs +++ b/src/Orchard.Web/Modules/Orchard.Azure/Services/Environment/Configuration/AzureBlobShellSettingsManager.cs @@ -21,13 +21,20 @@ namespace Orchard.Azure.Services.Environment.Configuration private readonly IShellSettingsManagerEventHandler _events; public AzureBlobShellSettingsManager(IMimeTypeProvider mimeTypeProvider, IShellSettingsManagerEventHandler events) { + _events = events; + Logger = NullLogger.Instance; + var connectionString = CloudConfigurationManager.GetSetting(Constants.ShellSettingsStorageConnectionStringSettingName); + var containerName = CloudConfigurationManager.GetSetting(Constants.ShellSettingsContainerNameSettingName); if (String.IsNullOrEmpty(containerName)) containerName = Constants.ShellSettingsDefaultContainerName; + _fileSystem = new AzureFileSystem(connectionString, containerName, String.Empty, true, mimeTypeProvider); - _events = events; - Logger = NullLogger.Instance; + + if (!_fileSystem.Container.Exists()) { + _fileSystem.Container.Create(); + } } public ILogger Logger { get; set; } diff --git a/src/Orchard.Web/Modules/Orchard.Projections/Tests/Orchard.Projections.Tests.csproj b/src/Orchard.Web/Modules/Orchard.Projections/Tests/Orchard.Projections.Tests.csproj index b68e36283..f3c149e3b 100644 --- a/src/Orchard.Web/Modules/Orchard.Projections/Tests/Orchard.Projections.Tests.csproj +++ b/src/Orchard.Web/Modules/Orchard.Projections/Tests/Orchard.Projections.Tests.csproj @@ -47,8 +47,8 @@ ..\..\..\..\packages\Iesi.Collections.4.0.1.4000\lib\net40\Iesi.Collections.dll True - - ..\..\..\..\packages\Moq.4.0.10827\lib\NET40\Moq.dll + + ..\..\..\..\packages\Moq.4.2.1510.2205\lib\NET40\Moq.dll True diff --git a/src/Orchard.Web/Modules/Orchard.Projections/Tests/packages.config b/src/Orchard.Web/Modules/Orchard.Projections/Tests/packages.config index a86dc6c98..b0593f20b 100644 --- a/src/Orchard.Web/Modules/Orchard.Projections/Tests/packages.config +++ b/src/Orchard.Web/Modules/Orchard.Projections/Tests/packages.config @@ -3,7 +3,7 @@ - + \ No newline at end of file diff --git a/src/Rebracer.xml b/src/Rebracer.xml index 4663c4402..9d83e6ac7 100644 --- a/src/Rebracer.xml +++ b/src/Rebracer.xml @@ -10,8 +10,8 @@ - TODO:2 - HACK:2 + HACK:2 + TODO:2 UNDONE:2 UnresolvedMergeConflict:3 diff --git a/src/Tools/Orchard.Tests/Orchard.Tests.csproj b/src/Tools/Orchard.Tests/Orchard.Tests.csproj index c23874b9b..9570e1f88 100644 --- a/src/Tools/Orchard.Tests/Orchard.Tests.csproj +++ b/src/Tools/Orchard.Tests/Orchard.Tests.csproj @@ -56,8 +56,8 @@ false - - ..\..\packages\Moq.4.0.10827\lib\NET40\Moq.dll + + ..\..\packages\Moq.4.2.1510.2205\lib\NET40\Moq.dll True diff --git a/src/Tools/Orchard.Tests/packages.config b/src/Tools/Orchard.Tests/packages.config index e0f8fbf73..ea761ef7a 100644 --- a/src/Tools/Orchard.Tests/packages.config +++ b/src/Tools/Orchard.Tests/packages.config @@ -1,5 +1,5 @@  - + \ No newline at end of file