mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Adding more binding in Specflow tests
--HG-- branch : 1.4.x
This commit is contained in:
@@ -0,0 +1,39 @@
|
|||||||
|
using System;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using Orchard.ContentManagement;
|
||||||
|
using Orchard.ContentManagement.Aspects;
|
||||||
|
using Orchard.Core.Contents;
|
||||||
|
using Orchard.Data;
|
||||||
|
using Orchard.Roles.Models;
|
||||||
|
using Orchard.Roles.Services;
|
||||||
|
using Orchard.Security;
|
||||||
|
using Orchard.Security.Permissions;
|
||||||
|
using Orchard.Specs.Hosting.Orchard.Web;
|
||||||
|
using TechTalk.SpecFlow;
|
||||||
|
using Orchard.Localization.Services;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace Orchard.Specs.Bindings {
|
||||||
|
[Binding]
|
||||||
|
public class Settings : BindingBase {
|
||||||
|
|
||||||
|
[When(@"I have ""(.*)"" as the default culture")]
|
||||||
|
public void DefineDefaultCulture(string cultureName) {
|
||||||
|
|
||||||
|
var webApp = Binding<WebAppHosting>();
|
||||||
|
webApp.Host.Execute(() => {
|
||||||
|
using ( var environment = MvcApplication.CreateStandaloneEnvironment("Default") ) {
|
||||||
|
var orchardServices = environment.Resolve<IOrchardServices>();
|
||||||
|
var cultureManager = environment.Resolve<ICultureManager>();
|
||||||
|
|
||||||
|
var currentCultures = cultureManager.ListCultures();
|
||||||
|
if (!currentCultures.Contains(cultureName)) {
|
||||||
|
cultureManager.AddCulture(cultureName);
|
||||||
|
}
|
||||||
|
|
||||||
|
orchardServices.WorkContext.CurrentSite.SiteCulture = cultureName;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -176,6 +176,10 @@ namespace Orchard.Specs.Bindings {
|
|||||||
WhenIGoTo(urlPath);
|
WhenIGoTo(urlPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Given(@"I have the file ""(.*)"" in ""(.*)""")]
|
||||||
|
public void GivenIHaveFile(string sourceFileName, string destination) {
|
||||||
|
Host.CopyFile(sourceFileName, destination);
|
||||||
|
}
|
||||||
|
|
||||||
[When(@"I go to ""(.*)"" on host (.*)")]
|
[When(@"I go to ""(.*)"" on host (.*)")]
|
||||||
public void WhenIGoToPathOnHost(string urlPath, string host) {
|
public void WhenIGoToPathOnHost(string urlPath, string host) {
|
||||||
|
|||||||
@@ -214,6 +214,14 @@ namespace Orchard.Specs.Hosting {
|
|||||||
sourceModule.Combine("Views").DeepCopy(targetModule.Combine("Views"));
|
sourceModule.Combine("Views").DeepCopy(targetModule.Combine("Views"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void CopyFile(string source, string destination) {
|
||||||
|
var origin = Path.Current.Parent.Combine(source);
|
||||||
|
var target = _tempSite.Combine(destination);
|
||||||
|
|
||||||
|
Directory.CreateDirectory(target.DirectoryName);
|
||||||
|
File.Copy(origin, target);
|
||||||
|
}
|
||||||
|
|
||||||
private bool IsExtensionBinaryFile(Path path, string extensionName, ExtensionDeploymentOptions deploymentOptions) {
|
private bool IsExtensionBinaryFile(Path path, string extensionName, ExtensionDeploymentOptions deploymentOptions) {
|
||||||
bool isValidExtension = IsAssemblyFile(path);
|
bool isValidExtension = IsAssemblyFile(path);
|
||||||
if (!isValidExtension)
|
if (!isValidExtension)
|
||||||
|
|||||||
@@ -127,6 +127,7 @@
|
|||||||
<Compile Include="Bindings\BindingBase.cs" />
|
<Compile Include="Bindings\BindingBase.cs" />
|
||||||
<Compile Include="Bindings\CommandLine.cs" />
|
<Compile Include="Bindings\CommandLine.cs" />
|
||||||
<Compile Include="Bindings\ContentRights.cs" />
|
<Compile Include="Bindings\ContentRights.cs" />
|
||||||
|
<Compile Include="Bindings\Settings.cs" />
|
||||||
<Compile Include="Bindings\HtmlNodeExtensions.cs" />
|
<Compile Include="Bindings\HtmlNodeExtensions.cs" />
|
||||||
<Compile Include="Bindings\OrchardSiteFactory.cs" />
|
<Compile Include="Bindings\OrchardSiteFactory.cs" />
|
||||||
<Compile Include="Bindings\UsersPermissionsAndRoles.cs" />
|
<Compile Include="Bindings\UsersPermissionsAndRoles.cs" />
|
||||||
|
|||||||
Reference in New Issue
Block a user