Compare commits

..

50 Commits

Author SHA1 Message Date
Sebastien Ros
295e5e8785 Adding Multi-Tenant Commands feature 2015-08-07 17:40:47 -07:00
Sebastien Ros
41bd9ce9bc Adding a file system backed output cache provider 2015-08-05 16:59:34 -07:00
Sebastien Ros
e346170f24 Adding some documentation for IAppDataFolder 2015-08-05 14:21:22 -07:00
Sebastien Ros
430c3de460 Compressing output cache content in Redis 2015-08-04 17:28:49 -07:00
Sebastien Ros
f25758cc05 Refactoring connection multiplexer usage
For consistency with other services using Redis
2015-08-04 10:30:23 -07:00
Sebastien Ros
bb6a44634d Handling output cache provider exceptions 2015-08-04 10:29:46 -07:00
Sebastien Ros
8a08680a74 Localizing RedisTagCache keys 2015-08-03 14:37:25 -07:00
Sebastien Ros
25670b9620 Fixing pager text encoding
Fixes #5359
2015-07-31 17:00:31 -07:00
Sebastien Ros
fa09e2e83a Using master content item to create translations
Fixes #5535
2015-07-31 16:19:34 -07:00
Sebastien Ros
a9a1413331 Fixing unit tests 2015-07-31 16:12:36 -07:00
Sebastien Ros
637cea6a02 Fixing Redis connection creation
With the previous code, when multiple threads tried to create
a Redis connection, the ConcurrentDictionary would have
called the factory delegate multiple times and added only one
of the resulting connections. This is by design, and a solution
is to use a Lazy object to defer the creation of the connection.
Multiple Lazy objects will be created but it doesn't have any impact.
2015-07-31 15:10:08 -07:00
Sebastien Ros
cc82bfcca0 Fixing duplicate session creation 2015-07-30 15:49:13 -07:00
Daniel Stolt
faa216147d Merge pull request #5575 from Codinlab/issue/5519
Fixes #5519 : DynamicForms client validation issue
2015-07-29 16:59:40 +01:00
Sipke Schoorstra
cbf10216b0 Merge pull request #5581 from dcinzona/patch-4
Updated README.md Orchard version to 1.9.1
2015-07-28 15:14:00 +01:00
Gustavo Tandeciarz
bb560f9cdf Updated README.md Orchard version to 1.9.1
Was listing 1.8.1 as latest version in the readme. Minor update.
2015-07-28 08:57:49 -04:00
Thierry Fleury
bc2e0607ef DynamicForms : Mark css & js assets as content
MsBuild raise errors when ccs or js files have "None" BuildAction
2015-07-27 13:30:29 +02:00
Thierry Fleury
cd5ca49b32 Fixes #5519 : DynamicForms client validation issue
jQuery validate script order is important
2015-07-27 11:31:47 +02:00
Daniel Stolt
6da6c5c214 #5450: Implemented generalized Gulp automation.
Fixes #5446.
2015-07-26 01:14:14 +01:00
Lombiq
37a5a7effc Wrapping ITokenizer injection into Work<> for shape methods to prevent possible DependencyResolutionException.
Not doing this can cause "No scope with a Tag matching 'work' is visible from the scope in which the instance was requested." errors with certain token providers.
2015-07-26 00:53:19 +02:00
Nicholas Mayne
baad84ee7b Merge pull request #5570 from jtkech/patch-3
Incorrect plus characters break the compilation in DefaultDataMigrationInterpreter.cs
2015-07-25 21:23:58 +01:00
jtkech
93476c321a Update DefaultDataMigrationInterpreter.cs
Remove incorrect plus characters that break the compilation
2015-07-24 20:31:25 +02:00
Sipke Schoorstra
ea91185816 Falling back to a default base URL in case none is configured.
This fixes an issue where you run Setup from a command line and the recipe does not set BaseUrl on site settings.
The issue is that if the HttpContext does not have a URL, certain properties on the Request object will throw when constructing a URI with a null value.
2015-07-24 10:34:37 +01:00
Sébastien Ros
c0ebbd4ce7 Merge pull request #5548 from minglei84/1.9.x
Fixed [Default Value] And [DropForeignKeyCommand] For Mysql
2015-07-23 12:35:15 -07:00
Nicholas Mayne
818b35a370 Merge pull request #5551 from Codinlab/issue/5519
Fixes #5519 : DynamicForms client validation
2015-07-23 17:22:12 +01:00
Sipke Schoorstra
34947136d4 Fixed and updated scripts and gulp in Dynamic Forms and Layouts. 2015-07-23 11:42:16 +01:00
Sebastien Ros
894d932210 Reverting changes on Orchard.proj for Kudu
Fixes #5557
2015-07-22 14:50:14 -07:00
Sebastien Ros
8032d202e3 Compiling the solution for CI tests 2015-07-22 14:36:57 -07:00
Sebastien Ros
046c62e710 Diagnosing CI failures (wip) 2015-07-22 14:19:28 -07:00
Sebastien Ros
9001972d8b Fixing functional tests execution
On .NET 4.6
2015-07-22 13:03:58 -07:00
Sebastien Ros
0fc8f5accf Updating Redis driver 2015-07-21 18:08:10 -07:00
Lombiq
2a34cb582b Reverting that form validation services of Dynamic Forms were moved to a separate feature (should be only on dev) 2015-07-21 23:42:58 +02:00
Daniel Stolt
7411013b45 Fixed a localization unit test that was failing on some cultures. 2015-07-21 22:11:54 +01:00
Thierry Fleury
0e7f864d4d Fixes #5519 : DynamicForms client validation 2015-07-21 12:17:58 +02:00
Murray Hou
14cdf57bc5 Fixed DropForeignKeyCommand For Mysql 2015-07-21 15:48:54 +08:00
Murray Hou
41e9fda2de Fixed [default value] For Mysql
The [default value] can'nt use [modify column] in mysql.
2015-07-21 15:38:21 +08:00
Sebastien Ros
e6211dbf54 Merge branch '1.9.x' of https://github.com/OrchardCMS/Orchard into 1.9.x 2015-07-20 14:31:33 -07:00
Sebastien Ros
1664aa1bde Fixing Setup due to missing dynamic forms feature 2015-07-20 14:30:57 -07:00
Sebastien Ros
1b54e3e8fb Restoring build log level 2015-07-20 14:29:56 -07:00
Sipke Schoorstra
5d09053d30 Fixed an issue when changing the homepage.
This fixes an issue where the previous published homepage would not have its regenerated alias stored.
2015-07-20 20:56:37 +01:00
Sipke Schoorstra
1494aec836 Removed mixed tabs and spaces. 2015-07-20 20:10:58 +01:00
Sébastien Ros
e964d80f7e Merge pull request #5537 from jtkech/patch-1
#5512: Incorrect message of DynamicForms StringLength rule if only Maximum is specified
2015-07-19 09:58:24 -07:00
Nicholas Mayne
1e62b2b9f8 Merge pull request #5526 from yw80/1.9.x
Correct code indentation format for file IndexingTaskExecutor.cs
2015-07-19 17:53:25 +01:00
Nicholas Mayne
1732c333c2 Merge pull request #5540 from jchenga/issues/5539
[Fixes #5530] YSOD instead of the set up page in Azure.
2015-07-19 17:51:45 +01:00
Jack Cheng
a01d219607 [Fixes #5530] YSOD instead of the set up page in Azure. 2015-07-19 09:23:18 -07:00
Lombiq
36910e8659 Adding missing OrchardFeature attributes to Dynamic Forms validation services 2015-07-18 14:35:43 +02:00
jtkech
230314d7a1 Update StringLength.cs 2015-07-18 02:26:14 +02:00
Sebastien Ros
7282df4326 Adding support for Kudu deployment 2015-07-17 16:27:59 -07:00
Lombiq
81034f43d2 Fixing another potential NRE when saving a content item with LocalizationPart for the first time 2015-07-17 18:56:06 +02:00
yw80
e72d226263 Delete redundant text in file ShapeTracingTemplates.cshtml 2015-07-17 03:17:59 +08:00
yw80
4da838a3c3 Correct code indentation format for file IndexingTaskExecutor.cs
Incorrect indentation format causes code reading difficulties.
2015-07-17 03:03:53 +08:00
1169 changed files with 20610 additions and 25592 deletions

3
.deployment Normal file
View File

@@ -0,0 +1,3 @@
[config]
command = deploy.cmd
SCM_COMMAND_IDLE_TIMEOUT = 3600

4
.gitignore vendored
View File

@@ -172,6 +172,7 @@ profiling/
src/Orchard.Web/Modules-temp/*
src/Backup/*
src/packages/*
src/node_modules
src/UpgradeLog.*
*.itrace.csdef
*.build.csdef
@@ -183,9 +184,6 @@ src/Orchard.Web/Orchard.Web.Publish.xml
src/TestResults/*
src/Orchard.Web/Properties/PublishProfiles
src/Orchard.Azure/Orchard.Azure.CloudService/Staging/
src/Orchard.Web/Modules/Orchard.Azure.MediaServices/node_modules
src/Orchard.Web/Modules/Orchard.Layouts/node_modules
src/Orchard.Web/Modules/Orchard.DynamicForms/node_modules
#enable all /lib artifacts
!lib/*/*.*

View File

@@ -1,8 +1,4 @@
FOR %%b in (
"%VS140COMNTOOLS%..\..\VC\vcvarsall.bat"
"%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"
"%ProgramFiles%\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"
FOR %%b in (
"%VS120COMNTOOLS%..\..\VC\vcvarsall.bat"
"%ProgramFiles(x86)%\Microsoft Visual Studio 12.0\VC\vcvarsall.bat"
"%ProgramFiles%\Microsoft Visual Studio 12.0\VC\vcvarsall.bat"

View File

@@ -1,13 +1,6 @@
# Orchard
Orchard is a free, open source, community-focused Content Management System built on the ASP.NET MVC platform.
[![Join the chat at https://gitter.im/OrchardCMS/Orchard](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/OrchardCMS/Orchard?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
You can try it for free on [Dotnest.com](https://dotnest.com) or on Microsoft Azure by clicking on this button
[![Deploy to Azure](https://azuredeploy.net/deploybutton.png)](https://ms.portal.azure.com/#create/OutercurveFoundation.OrchardCMS.0.5.9)
## About The Orchard Project
#### Please visit our website at http://orchardproject.net for the most current information about this project.
@@ -23,8 +16,8 @@ Our mission is to empower our users and foster a dedicated and diverse community
There are many ways you can [contribute to Orchard](http://orchardproject.net/contribution): you can [fix bugs](https://github.com/OrchardCMS/Orchard/issues), contribute modules and themes to [our gallery](http://gallery.orchardproject.net/), [write documentation](https://github.com/OrchardCMS/OrchardDoc), [translate Orchard](http://orchardproject.net/localize), or answer questions [on our forums](http://orchard.codeplex.com/discussions) and [on Stack Overflow](http://stackoverflow.com/questions/tagged/orchardcms).
## Project Status
Orchard is currently in version 1.9. We invite participation by the developer community in shaping the projects direction, so that we can publicly validate our designs and development approach.
Our 1.9 release is available from [our Downloads page](https://github.com/OrchardCMS/Orchard/releases), and is easy to [Install Orchard using the Web Platform Installer](http://www.orchardproject.net/docs/Installing-Orchard.ashx). We encourage interested developers to check out the source code on the Orchard Github site and get involved with the project.
Orchard is currently in version 1.9.1. We invite participation by the developer community in shaping the projects direction, so that we can publicly validate our designs and development approach.
Our 1.9.1 release is available from our Downloads page, and is easy to [Install Orchard using the Web Platform Installer](http://www.orchardproject.net/docs/Installing-Orchard.ashx). We encourage interested developers to check out the source code on the Orchard Github site and get involved with the project.
* [Download the latest release](https://github.com/OrchardCMS/Orchard/releases)
* [Feature roadmap](http://www.orchardproject.net/docs/feature-roadmap.ashx)

114
deploy.cmd Normal file
View File

@@ -0,0 +1,114 @@
@if "%SCM_TRACE_LEVEL%" NEQ "4" @echo off
:: ----------------------
:: KUDU Deployment Script
:: Version: 0.1.11
:: ----------------------
:: Prerequisites
:: -------------
:: Verify node.js installed
where node 2>nul >nul
IF %ERRORLEVEL% NEQ 0 (
echo Missing node.js executable, please install node.js, if already installed make sure it can be reached from current environment.
goto error
)
:: Setup
:: -----
setlocal enabledelayedexpansion
SET ARTIFACTS=%~dp0%..\artifacts
IF NOT DEFINED DEPLOYMENT_SOURCE (
SET DEPLOYMENT_SOURCE=%~dp0%.
)
IF NOT DEFINED DEPLOYMENT_TARGET (
SET DEPLOYMENT_TARGET=%ARTIFACTS%\wwwroot
)
IF NOT DEFINED NEXT_MANIFEST_PATH (
SET NEXT_MANIFEST_PATH=%ARTIFACTS%\manifest
IF NOT DEFINED PREVIOUS_MANIFEST_PATH (
SET PREVIOUS_MANIFEST_PATH=%ARTIFACTS%\manifest
)
)
IF NOT DEFINED KUDU_SYNC_CMD (
:: Install kudu sync
echo Installing Kudu Sync
call npm install kudusync -g --silent
IF !ERRORLEVEL! NEQ 0 goto error
:: Locally just running "kuduSync" would also work
SET KUDU_SYNC_CMD=%appdata%\npm\kuduSync.cmd
)
IF NOT DEFINED DEPLOYMENT_TEMP (
SET DEPLOYMENT_TEMP=%temp%\___deployTemp%random%
SET CLEAN_LOCAL_DEPLOYMENT_TEMP=true
)
IF DEFINED CLEAN_LOCAL_DEPLOYMENT_TEMP (
IF EXIST "%DEPLOYMENT_TEMP%" rd /s /q "%DEPLOYMENT_TEMP%"
mkdir "%DEPLOYMENT_TEMP%"
)
IF NOT DEFINED MSBUILD_PATH (
SET MSBUILD_PATH=%WINDIR%\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Deployment
:: ----------
echo Handling .NET Web Application deployment.
:: 1. Restore NuGet packages
IF /I "" NEQ "" (
call :ExecuteCmd nuget restore "%DEPLOYMENT_SOURCE%\"
IF !ERRORLEVEL! NEQ 0 goto error
)
:: 2. Build to the temporary path
call :ExecuteCmd "%MSBUILD_PATH%" "%DEPLOYMENT_SOURCE%\Orchard.proj" /t:Precompiled /v:m
IF !ERRORLEVEL! NEQ 0 goto error
:: 3. KuduSync
call :ExecuteCmd "%KUDU_SYNC_CMD%" -v 50 -f "%DEPLOYMENT_SOURCE%\build\Precompiled" -t "%DEPLOYMENT_TARGET%" -n "%NEXT_MANIFEST_PATH%" -p "%PREVIOUS_MANIFEST_PATH%" -i ".git;.hg;.deployment;deploy.cmd"
IF !ERRORLEVEL! NEQ 0 goto error
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: Post deployment stub
IF DEFINED POST_DEPLOYMENT_ACTION call "%POST_DEPLOYMENT_ACTION%"
IF !ERRORLEVEL! NEQ 0 goto error
goto end
:: Execute command routine that will echo out when error
:ExecuteCmd
setlocal
set _CMD_=%*
call %_CMD_%
if "%ERRORLEVEL%" NEQ "0" echo Failed exitCode=%ERRORLEVEL%, command=%_CMD_%
exit /b %ERRORLEVEL%
:error
endlocal
echo An error has occurred during web site deployment.
call :exitSetErrorLevel
call :exitFromFunction 2>nul
:exitSetErrorLevel
exit /b 1
:exitFromFunction
()
:end
endlocal
echo Finished successfully.

View File

@@ -1,7 +0,0 @@
Copyright (c) 2002-2013, The Npgsql Development Team
Permission to use, copy, modify, and distribute this software and its documentation for any purpose, without fee, and without a written agreement is hereby granted, provided that the above copyright notice and this paragraph and the following two paragraphs appear in all copies.
IN NO EVENT SHALL THE NPGSQL DEVELOPMENT TEAM BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE NPGSQL DEVELOPMENT TEAM HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THE NPGSQL DEVELOPMENT TEAM SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE NPGSQL DEVELOPMENT TEAM HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

View File

@@ -1,52 +0,0 @@
Npgsql - .NET Data Provider for PostgreSQL
=============
###What Is Npgsql?
Npgsql is a .Net Data Provider for PostgreSQL. It allows you to connect and interact with PostgreSQL server using .NET.
###Project Information
+ [Offical Site][1]
+ [Npgsql source code @ GitHub][2]
+ [Available on NuGet Gallery][3]
+ [Wiki - Usage and other information][4]
###Developers
Developers who contributes to Npgsql currently or in past, in no particular order:
+ Brar Piening
+ Francisco Figueiredo Jr.
+ Ben Clewett
+ Daniel Morgan
+ Dave Page
+ Ulrich Sprick
+ Glen Parker
+ Josh Cooley
+ Jon Asher
+ Chris Morgan
+ Thilo Utke
+ Hiroshi Saito
+ Shay Rojansky
###License
Refer LICENSE.txt for more information on license terms.
###Code history
On December 2nd, [we committed a change][5] to restructure Npgsql code. This change modified file locations and unfortunately made the complete modification history of those files to not be available anymore through GitHub interface directly. [This stackoverflow post][6] documents a way to access the history before the rename: You just need to access the object tree **before** the rename and then you can see the rest of the file history.
In the case of this rename, this is the tree: https://github.com/npgsql/Npgsql/tree/2f8928e4dee59275767de0df2ec41a654744a3bc
This will help future searches for the history of the files. Note that you stil can access the complete history of the file through command line: `git log --follow ./newflodername/file`
[1]: http://www.npgsql.org/ "Official site"
[2]: https://github.com/npgsql/Npgsql/ "Npgsql source code @ GitHub"
[3]: http://www.nuget.org/packages/Npgsql/ "Npgsql @ Nuget Gallery"
[4]: https://github.com/npgsql/Npgsql/wiki/ "Wiki"
[5]: https://github.com/npgsql/Npgsql/commit/d7beea23f3407b38747cde05568a59ac87cdd121#diff-3b02da674650ba0f31603c365249f34f
[6]: http://stackoverflow.com/questions/17213046/see-history-in-github-after-folder-rename

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

165
src/Gulpfile.js Normal file
View File

@@ -0,0 +1,165 @@
var glob = require("glob"),
path = require("path-posix"),
merge = require("merge-stream"),
gulpif = require("gulp-if"),
gulp = require("gulp"),
newer = require("gulp-newer"),
plumber = require("gulp-plumber"),
sourcemaps = require("gulp-sourcemaps"),
less = require("gulp-less"),
autoprefixer = require("gulp-autoprefixer"),
minify = require("gulp-minify-css"),
typescript = require("gulp-typescript"),
uglify = require("gulp-uglify"),
rename = require("gulp-rename"),
concat = require("gulp-concat"),
header = require("gulp-header")
/*
** GULP TASKS
*/
// Incremental build (each asset group is built only if one or more inputs are newer than the output).
gulp.task("build", function () {
var assetGroupTasks = getAssetGroups().map(function (assetGroup) {
var doRebuild = false;
return createAssetGroupTask(assetGroup, doRebuild);
});
return merge(assetGroupTasks);
});
// Full rebuild (all assets groups are built regardless of timestamps).
gulp.task("rebuild", function () {
var assetGroupTasks = getAssetGroups().map(function (assetGroup) {
var doRebuild = true;
return createAssetGroupTask(assetGroup, doRebuild);
});
return merge(assetGroupTasks);
});
// Continuous watch (each asset group is built whenever one of its inputs changes).
gulp.task("watch", function () {
getAssetGroups().forEach(function (assetGroup) {
gulp.watch(assetGroup.inputPaths, function (event) {
console.log("Asset file '" + event.path + "' was " + event.type + ", rebuilding output '" + assetGroup.outputPath + "'.");
var task = createAssetGroupTask(assetGroup);
});
});
});
/*
** ASSET GROUPS
*/
function getAssetGroups() {
var assetManifestPaths = glob.sync("Orchard.Web/{Core,Modules,Themes}/*/Assets.json");
var assetGroups = [];
assetManifestPaths.forEach(function (assetManifestPath) {
var assetManifest = require("./" + assetManifestPath);
assetManifest.forEach(function (assetGroup) {
resolveAssetGroupPaths(assetGroup, assetManifestPath);
assetGroups.push(assetGroup);
});
});
return assetGroups;
}
function resolveAssetGroupPaths(assetGroup, assetManifestPath) {
assetGroup.basePath = path.dirname(assetManifestPath);
assetGroup.inputPaths = assetGroup.inputs.map(function (inputPath) {
return path.join(assetGroup.basePath, inputPath);
});
assetGroup.outputPath = path.join(assetGroup.basePath, assetGroup.output);
assetGroup.outputDir = path.dirname(assetGroup.outputPath);
assetGroup.outputFileName = path.basename(assetGroup.output);
}
function createAssetGroupTask(assetGroup, doRebuild) {
var outputExt = path.extname(assetGroup.output).toLowerCase();
switch (outputExt) {
case ".css":
return buildCssPipeline(assetGroup, doRebuild);
case ".js":
return buildJsPipeline(assetGroup, doRebuild);
}
}
/*
** PROCESSING PIPELINES
*/
function buildCssPipeline(assetGroup, doRebuild) {
assetGroup.inputPaths.forEach(function (inputPath) {
var ext = path.extname(inputPath).toLowerCase();
if (ext !== ".less" && ext !== ".css")
throw "Input file '" + inputPath + "' is not of a valid type for output file '" + assetGroup.outputPath + "'.";
});
var doConcat = path.basename(assetGroup.outputFileName, ".css") !== "@";
return gulp.src(assetGroup.inputPaths)
.pipe(gulpif(!doRebuild,
gulpif(doConcat,
newer(assetGroup.outputPath),
newer({
dest: assetGroup.outputDir,
ext: ".css"
}))))
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(gulpif("*.less", less()))
.pipe(gulpif(doConcat, concat(assetGroup.outputFileName)))
.pipe(autoprefixer({ browsers: ["last 2 versions"] }))
// TODO: Start using below whenever gulp-header supports sourcemaps.
//.pipe(header(
// "/*\n" +
// "** NOTE: This file is generated by Gulp compilation and should not be edited directly!\n" +
// "** Any changes made directly to this file will be overwritten next time the Gulp compilation runs.\n" +
// "** For more information, see the Readme.txt file in the Gulp solution folder.\n" +
// "*/\n\n"))
.pipe(sourcemaps.write())
.pipe(gulp.dest(assetGroup.outputDir))
.pipe(minify())
.pipe(rename({
suffix: ".min"
}))
.pipe(gulp.dest(assetGroup.outputDir));
}
function buildJsPipeline(assetGroup, doRebuild) {
assetGroup.inputPaths.forEach(function (inputPath) {
var ext = path.extname(inputPath).toLowerCase();
if (ext !== ".ts" && ext !== ".js")
throw "Input file '" + inputPath + "' is not of a valid type for output file '" + assetGroup.outputPath + "'.";
});
var doConcat = path.basename(assetGroup.outputFileName, ".js") !== "@";
return gulp.src(assetGroup.inputPaths)
.pipe(gulpif(!doRebuild,
gulpif(doConcat,
newer(assetGroup.outputPath),
newer({
dest: assetGroup.outputDir,
ext: ".js"
}))))
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(gulpif("*.ts", typescript({
declaration: false,
//noImplicitAny: true,
noEmitOnError: true,
sortOutput: true,
}).js))
.pipe(gulpif(doConcat, concat(assetGroup.outputFileName)))
// TODO: Start using below whenever gulp-header supports sourcemaps.
//.pipe(header(
// "/*\n" +
// "** NOTE: This file is generated by Gulp compilation and should not be edited directly!\n" +
// "** Any changes made directly to this file will be overwritten next time the Gulp compilation runs.\n" +
// "** For more information, see the Readme.txt file in the Gulp solution folder.\n" +
// "*/\n\n"))
.pipe(sourcemaps.write())
.pipe(gulp.dest(assetGroup.outputDir))
.pipe(uglify())
.pipe(rename({
suffix: ".min"
}))
.pipe(gulp.dest(assetGroup.outputDir));
}

View File

@@ -101,7 +101,6 @@
<ProjectReference Include="..\Orchard\Orchard.Framework.csproj">
<Project>{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}</Project>
<Name>Orchard.Framework</Name>
<Private>false</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
@@ -127,11 +126,11 @@
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -147,7 +147,7 @@
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.0.0"/>
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35"/>

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using Autofac;
using JetBrains.Annotations;
using Moq;
using NUnit.Framework;
using Orchard.Caching;
@@ -19,6 +20,7 @@ using Orchard.DisplayManagement.Implementation;
using Orchard.Environment;
using Orchard.Environment.Extensions;
using Orchard.Security;
using Orchard.Tests.ContentManagement;
using Orchard.Tests.Modules;
using Orchard.Tests.Stubs;
using Orchard.UI.Notify;
@@ -34,7 +36,6 @@ namespace Orchard.Core.Tests.Body {
builder.RegisterType<Signals>().As<ISignals>();
builder.RegisterType<DefaultContentManagerSession>().As<IContentManagerSession>();
builder.RegisterInstance(new Mock<IContentDefinitionManager>().Object);
builder.RegisterInstance(new Mock<ITransactionManager>().Object);
builder.RegisterInstance(new Mock<IAuthorizer>().Object);
builder.RegisterInstance(new Mock<INotifier>().Object);
builder.RegisterInstance(new Mock<IContentDisplay>().Object);
@@ -82,6 +83,7 @@ namespace Orchard.Core.Tests.Body {
}
}
[UsedImplicitly]
public class ThingHandler : ContentHandler {
public ThingHandler() {
Filters.Add(new ActivatingFilter<Thing>(ThingDriver.ContentTypeName));

View File

@@ -4,6 +4,7 @@ using System.Linq;
using System.Web;
using System.Web.Routing;
using Autofac;
using JetBrains.Annotations;
using Moq;
using NUnit.Framework;
using Orchard.Caching;
@@ -133,12 +134,12 @@ namespace Orchard.Core.Tests.Common.Providers {
}
}
[UsedImplicitly]
class TestHandler : ContentHandler {
public TestHandler() {
Filters.Add(new ActivatingFilter<CommonPart>("test-item"));
Filters.Add(new ActivatingFilter<ContentPart<CommonPartVersionRecord>>("test-item"));
Filters.Add(new ActivatingFilter<TestUser>("User"));
Filters.Add(new ActivatingFilter<AlternateTestUser>("AlternateUser"));
}
}
@@ -147,11 +148,6 @@ namespace Orchard.Core.Tests.Common.Providers {
public string UserName { get { return "x"; } }
public string Email { get { return "y"; } }
}
class AlternateTestUser : ContentPart, IUser {
public new int Id { get { return 6655322; } }
public string UserName { get { return "y"; } }
public string Email { get { return "x"; } }
}
[Test]
public void OwnerShouldBeNullAndZeroByDefault() {
@@ -365,22 +361,14 @@ namespace Orchard.Core.Tests.Common.Providers {
public void EditingShouldSetModifiedUtc() {
var contentManager = _container.Resolve<IContentManager>();
var user = contentManager.New<IUser>("User");
_authn.Setup(x => x.GetAuthenticatedUser()).Returns(user);
var createUtc = _clock.UtcNow;
var item = contentManager.Create<ICommonPart>("test-item", VersionOptions.Draft, init => { });
contentManager.Publish(item.ContentItem);
Assert.That(item.CreatedUtc, Is.EqualTo(createUtc));
Assert.That(item.ModifiedUtc, Is.EqualTo(createUtc));
Assert.That(item.VersionModifiedBy, Is.EqualTo(user.UserName));
Assert.That(item.PublishedUtc, Is.EqualTo(createUtc));
// Switch user
var secondUser = contentManager.New<IUser>("AlternateUser");
_authn.Setup(x => x.GetAuthenticatedUser()).Returns(secondUser);
_clock.Advance(TimeSpan.FromMinutes(1));
var editUtc = _clock.UtcNow;
@@ -391,7 +379,6 @@ namespace Orchard.Core.Tests.Common.Providers {
Assert.That(item.ModifiedUtc, Is.EqualTo(editUtc));
Assert.That(item.PublishedUtc, Is.EqualTo(createUtc));
Assert.That(updater.ModelErrors.Count, Is.EqualTo(0));
Assert.That(item.VersionModifiedBy, Is.EqualTo(secondUser.UserName));
}
[Test]

View File

@@ -85,6 +85,7 @@
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
<HintPath>..\..\lib\sqlce\System.Data.SqlServerCe.dll</HintPath>
<Private>True</Private>
@@ -127,12 +128,10 @@
<ProjectReference Include="..\Orchard.Web\Core\Orchard.Core.csproj">
<Project>{9916839C-39FC-4CEB-A5AF-89CA7E87119F}</Project>
<Name>Orchard.Core</Name>
<Private>True</Private>
</ProjectReference>
<ProjectReference Include="..\Orchard\Orchard.Framework.csproj">
<Project>{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}</Project>
<Name>Orchard.Framework</Name>
<Private>True</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
@@ -156,10 +155,10 @@
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
-->
<Target Name="CopySqlCeBinaries">
<ItemGroup>

View File

@@ -35,7 +35,6 @@ namespace Orchard.Core.Tests.Scheduling {
public override void Register(ContainerBuilder builder) {
_handler = new StubTaskHandler();
builder.RegisterInstance(new Mock<IOrchardServices>().Object);
builder.RegisterInstance(new Mock<ITransactionManager>().Object);
builder.RegisterType<DefaultContentManager>().As<IContentManager>();
builder.RegisterType<StubCacheManager>().As<ICacheManager>();
builder.RegisterType<Signals>().As<ISignals>();

View File

@@ -13,6 +13,7 @@ using Orchard.Core.Settings.Metadata;
using Orchard.Core.Settings.Metadata.Records;
using Orchard.Data;
using Orchard.Tests;
using Orchard.Tests.ContentManagement;
using Orchard.Tests.Stubs;
using Orchard.Tests.Utility;
@@ -23,6 +24,7 @@ namespace Orchard.Core.Tests.Settings.Metadata {
private ISessionFactory _sessionFactory;
private ISession _session;
private IContainer _container;
private ITransactionManager _transactionManager;
[TestFixtureSetUp]
public void InitFixture() {
@@ -39,6 +41,17 @@ namespace Orchard.Core.Tests.Settings.Metadata {
[SetUp]
public void Init() {
_session = _sessionFactory.OpenSession();
foreach (var killType in new[] { typeof(ContentTypeDefinitionRecord), typeof(ContentPartDefinitionRecord), typeof(ContentFieldDefinitionRecord) }) {
foreach (var killRecord in _session.CreateCriteria(killType).List()) {
_session.Delete(killRecord);
}
}
_session.Flush();
_session.Close();
_session.Dispose();
_session = _sessionFactory.OpenSession();
var builder = new ContainerBuilder();
builder.RegisterAutoMocking();
builder.RegisterType<ContentDefinitionManager>().As<IContentDefinitionManager>();
@@ -48,25 +61,15 @@ namespace Orchard.Core.Tests.Settings.Metadata {
builder.RegisterType<StubCacheManager>().As<ICacheManager>();
builder.RegisterType<StubParallelCacheContext>().As<IParallelCacheContext>();
_session = _sessionFactory.OpenSession();
builder.RegisterInstance(_transactionManager = new TestTransactionManager(_session)).As<ITransactionManager>();
_container = builder.Build();
_container.Mock<ISessionLocator>()
.Setup(x => x.For(It.IsAny<Type>()))
.Returns(() => _session);
_session = _sessionFactory.OpenSession();
foreach (var killType in new[] { typeof(ContentTypeDefinitionRecord), typeof(ContentPartDefinitionRecord), typeof(ContentFieldDefinitionRecord) }) {
foreach (var killRecord in _session.CreateCriteria(killType).List()) {
_session.Delete(killRecord);
}
}
_session.Flush();
}
void ResetSession() {
_session.Flush();
_session.Dispose();
_session = _sessionFactory.OpenSession();
_transactionManager.RequireNew();
}
[TearDown]

View File

@@ -1 +1 @@
setup /SiteName:Profiling /AdminUsername:admin /AdminPassword:profiling-secret /DatabaseProvider:SQLServer /DatabaseConnectionString:"Data Source=.;Initial Catalog=Orchard;Integrated Security=True" /EnabledFeatures:Profiling,Orchard.Framework,Common,Containers,Contents,Dashboard,Feeds,Navigation,Scheduling,Settings,Shapes,Title,PackagingServices,Gallery,Orchard.PublishLater,Orchard.Blogs,Orchard.Comments,Orchard.ContentTypes,Orchard.jQuery,Orchard.Lists,Orchard.MediaLibrary,Orchard.ContentPicker,Orchard.MediaPicker,Orchard.Modules,Orchard.Packaging,Orchard.Pages,Orchard.Recipes,Orchard.Roles,Orchard.Tags,Orchard.Themes,Orchard.Users,Orchard.Scripting,Orchard.Scripting.Lightweight,Orchard.Widgets,TinyMce,TheThemeMachine,Orchard.Tokens,Orchard.Alias,Orchard.Autoroute
setup /SiteName:Profiling /AdminUsername:admin /AdminPassword:profiling-secret /DatabaseProvider:SQLServer /DatabaseConnectionString:"Data Source=.;Initial Catalog=Orchard;Integrated Security=True" /EnabledFeatures:Profiling,Orchard.Framework,Common,Containers,Contents,Dashboard,Feeds,Navigation,Reports,Scheduling,Settings,Shapes,Title,PackagingServices,Gallery,Orchard.PublishLater,Orchard.Blogs,Orchard.Comments,Orchard.ContentTypes,Orchard.jQuery,Orchard.Lists,Orchard.MediaLibrary,Orchard.ContentPicker,Orchard.MediaPicker,Orchard.Modules,Orchard.Packaging,Orchard.Pages,Orchard.Recipes,Orchard.Roles,Orchard.Tags,Orchard.Themes,Orchard.Users,Orchard.Scripting,Orchard.Scripting.Lightweight,Orchard.Widgets,TinyMce,TheThemeMachine,Orchard.Tokens,Orchard.Alias,Orchard.Autoroute

View File

@@ -25,7 +25,7 @@ namespace Orchard.Specs.Bindings {
virtualDirectory,
TableData(
new { extension = "Module", names = "Lucene, Markdown, Orchard.Alias, Orchard.AntiSpam, Orchard.ArchiveLater, Orchard.Autoroute, Orchard.Azure, Orchard.Blogs, Orchard.Caching, Orchard.CodeGeneration, Orchard.Comments, Orchard.ContentPermissions, Orchard.ContentPicker, Orchard.ContentTypes, Orchard.CustomForms, Orchard.DesignerTools, Orchard.Email, Orchard.Fields, Orchard.Forms, Orchard.ImageEditor, Orchard.ImportExport, Orchard.Indexing, Orchard.JobsQueue, Orchard.jQuery, Orchard.Layouts, Orchard.Lists, Orchard.Localization, Orchard.Media, Orchard.MediaLibrary, Orchard.MediaPicker, Orchard.MediaProcessing, Orchard.Migrations, Orchard.Modules, Orchard.MultiTenancy, Orchard.OutputCache, Orchard.Packaging, Orchard.Pages, Orchard.Projections, Orchard.PublishLater, Orchard.Recipes, Orchard.Roles, Orchard.Rules, Orchard.Scripting, Orchard.Scripting.CSharp, Orchard.Scripting.Dlr, Orchard.Search, Orchard.SecureSocketsLayer, Orchard.Setup, Orchard.Tags, Orchard.TaskLease, Orchard.Taxonomies, Orchard.Templates, Orchard.Themes, Orchard.Tokens, Orchard.Users, Orchard.Warmup, Orchard.Widgets, Orchard.Workflows, SysCache, TinyMce, Upgrade" },
new { extension = "Core", names = "Common, Containers, Contents, Dashboard, Feeds, Navigation, Scheduling, Settings, Shapes, Title, XmlRpc" },
new { extension = "Core", names = "Common, Containers, Contents, Dashboard, Feeds, Navigation, Reports, Scheduling, Settings, Shapes, Title, XmlRpc" },
new { extension = "Theme", names = "SafeMode, TheAdmin, TheThemeMachine" }));
webApp.WhenIGoTo("Setup");

View File

@@ -93,13 +93,14 @@ namespace Orchard.Specs.Bindings {
_webHost = new WebHost(_orchardTemp);
Host.Initialize(siteFolder, virtualDirectory ?? "/", _dynamicCompilationOption);
var shuttle = new Shuttle();
Host.Execute(() => {
log4net.Config.BasicConfigurator.Configure(new CastleAppender());
HostingTraceListener.SetHook(msg => shuttle._sink.Receive(msg));
});
Host.Execute(() => Executor(shuttle));
_messages = shuttle._sink;
}
private static void Executor(Shuttle shuttle) {
HostingTraceListener.SetHook(msg => shuttle._sink.Receive(msg));
}
private class CastleAppender : IAppender {
public void Close() { }
public string Name { get; set; }

View File

@@ -68,7 +68,7 @@ namespace Orchard.Specs.Hosting {
TargetInstance = Activator.CreateInstance(classType);
foreach (FieldInfo field in classType.GetFields()) {
if (typeof (Delegate).IsAssignableFrom(field.FieldType))
if (typeof (TDelegate).IsAssignableFrom(field.FieldType))
//If the field is a delegate
field.SetValue(TargetInstance, ((SerializableDelegate<TDelegate>)info.GetValue(field.Name, typeof(SerializableDelegate<TDelegate>))).Delegate);
else if (!field.FieldType.IsSerializable)
@@ -86,8 +86,12 @@ namespace Orchard.Specs.Hosting {
foreach (FieldInfo field in targetType.GetFields()) {
//See corresponding comments above
if (typeof (Delegate).IsAssignableFrom(field.FieldType))
info.AddValue(field.Name, new SerializableDelegate<TDelegate>((TDelegate)field.GetValue(TargetInstance)));
if (typeof (TDelegate).IsAssignableFrom(field.FieldType)) {
var value = (TDelegate)field.GetValue(TargetInstance);
if (value != null) {
info.AddValue(field.Name, new SerializableDelegate<TDelegate>(value));
}
}
else if (!field.FieldType.IsSerializable)
info.AddValue(field.Name, new AnonymousClassWrapper(field.FieldType, field.GetValue(TargetInstance)));
else

View File

@@ -426,7 +426,6 @@
<ProjectReference Include="..\Orchard.Web\Core\Orchard.Core.csproj">
<Project>{9916839C-39FC-4CEB-A5AF-89CA7E87119F}</Project>
<Name>Orchard.Core</Name>
<Private>True</Private>
</ProjectReference>
<ProjectReference Include="..\Orchard.Web\Modules\Orchard.Roles\Orchard.Roles.csproj">
<Project>{D10AD48F-407D-4DB5-A328-173EC7CB010F}</Project>
@@ -447,7 +446,6 @@
<ProjectReference Include="..\Orchard\Orchard.Framework.csproj">
<Project>{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}</Project>
<Name>Orchard.Framework</Name>
<Private>True</Private>
</ProjectReference>
<ProjectReference Include="..\Tools\Orchard\Orchard.csproj">
<Project>{33B1BC8D-E292-4972-A363-22056B207156}</Project>
@@ -504,11 +502,11 @@
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -7,7 +7,7 @@ Scenario: Root request shows setup form
Given I have a clean site with
| extension | names |
| Module | Orchard.Setup, Orchard.Layouts, Orchard.Pages, Orchard.ContentPicker, Orchard.Blogs, Orchard.MediaLibrary, Orchard.Modules, Orchard.Packaging, Orchard.PublishLater, Orchard.Themes, Orchard.Scripting, Orchard.Widgets, Orchard.Users, Orchard.ContentTypes, Orchard.Roles, Orchard.Comments, Orchard.jQuery, Orchard.Tags, TinyMce, Orchard.Recipes, Orchard.Warmup, Orchard.Alias, Orchard.Forms, Orchard.Tokens, Orchard.Autoroute, Orchard.Projections, Orchard.Fields, Orchard.MediaProcessing, Orchard.OutputCache, Orchard.Taxonomies, Orchard.Workflows, Orchard.Scripting.CSharp |
| Core | Common, Containers, Dashboard, Feeds, Navigation, Contents, Scheduling, Settings, Shapes, XmlRpc, Title |
| Core | Common, Containers, Dashboard, Feeds, Navigation, Contents, Scheduling, Settings, Shapes, XmlRpc, Title, Reports |
| Theme | SafeMode |
When I go to "/"
Then I should see "Welcome to Orchard"
@@ -18,7 +18,7 @@ Scenario: Setup folder also shows setup form
Given I have a clean site with
| extension | names |
| Module | Orchard.Setup, Orchard.Layouts, Orchard.Pages, Orchard.ContentPicker, Orchard.Blogs, Orchard.MediaLibrary, Orchard.Modules, Orchard.Packaging, Orchard.PublishLater, Orchard.Themes, Orchard.Scripting, Orchard.Widgets, Orchard.Users, Orchard.ContentTypes, Orchard.Roles, Orchard.Comments, Orchard.jQuery, Orchard.Tags, TinyMce, Orchard.Recipes, Orchard.Warmup, Orchard.Alias, Orchard.Forms, Orchard.Tokens, Orchard.Autoroute, Orchard.Projections, Orchard.Fields, Orchard.MediaProcessing, Orchard.OutputCache, Orchard.Taxonomies, Orchard.Workflows, Orchard.Scripting.CSharp |
| Core | Common, Containers, Dashboard, Feeds, Navigation, Contents, Scheduling, Settings, Shapes, XmlRpc, Title |
| Core | Common, Containers, Dashboard, Feeds, Navigation, Contents, Scheduling, Settings, Shapes, XmlRpc, Title, Reports |
| Theme | SafeMode |
When I go to "/Setup"
Then I should see "Welcome to Orchard"
@@ -29,7 +29,7 @@ Scenario: Some of the initial form values are required
Given I have a clean site with
| extension | names |
| Module | Orchard.Setup, Orchard.Layouts, Orchard.Pages, Orchard.ContentPicker, Orchard.Blogs, Orchard.MediaLibrary, Orchard.Modules, Orchard.Packaging, Orchard.PublishLater, Orchard.Themes, Orchard.Scripting, Orchard.Widgets, Orchard.Users, Orchard.ContentTypes, Orchard.Roles, Orchard.Comments, Orchard.jQuery, Orchard.Tags, TinyMce, Orchard.Recipes, Orchard.Warmup, Orchard.Alias, Orchard.Forms, Orchard.Tokens, Orchard.Autoroute, Orchard.Projections, Orchard.Fields, Orchard.MediaProcessing, Orchard.OutputCache, Orchard.Taxonomies, Orchard.Workflows, Orchard.Scripting.CSharp |
| Core | Common, Containers, Dashboard, Feeds, Navigation, Contents, Scheduling, Settings, Shapes, XmlRpc, Title |
| Core | Common, Containers, Dashboard, Feeds, Navigation, Contents, Scheduling, Settings, Shapes, XmlRpc, Title, Reports |
| Theme | SafeMode |
When I go to "/Setup"
And I hit "Finish Setup"
@@ -41,7 +41,7 @@ Scenario: Calling setup on a brand new install
Given I have a clean site with
| extension | names |
| Module | Orchard.Setup, Orchard.Layouts, Orchard.Pages, Orchard.ContentPicker, Orchard.Blogs, Orchard.MediaLibrary, Orchard.Modules, Orchard.Packaging, Orchard.PublishLater, Orchard.Themes, Orchard.Scripting, Orchard.Widgets, Orchard.Users, Orchard.ContentTypes, Orchard.Roles, Orchard.Comments, Orchard.jQuery, Orchard.Tags, TinyMce, Orchard.Recipes, Orchard.Warmup, Orchard.Alias, Orchard.Forms, Orchard.Tokens, Orchard.Autoroute, Orchard.Projections, Orchard.Fields, Orchard.MediaProcessing, Orchard.OutputCache, Orchard.Taxonomies, Orchard.Workflows, Orchard.Scripting.CSharp |
| Core | Common, Containers, Dashboard, Feeds, Navigation, Contents, Scheduling, Settings, Shapes, XmlRpc, Title |
| Core | Common, Containers, Dashboard, Feeds, Navigation, Contents, Scheduling, Settings, Shapes, XmlRpc, Title, Reports |
| Theme | SafeMode, TheAdmin, TheThemeMachine |
And I am on "/Setup"
When I fill in

View File

@@ -82,7 +82,7 @@ this.ScenarioSetup(scenarioInfo);
table1.AddRow(new string[] {
"Core",
"Common, Containers, Dashboard, Feeds, Navigation, Contents, Scheduling, Settings," +
" Shapes, XmlRpc, Title"});
" Shapes, XmlRpc, Title, Reports"});
table1.AddRow(new string[] {
"Theme",
"SafeMode"});
@@ -117,7 +117,7 @@ this.ScenarioSetup(scenarioInfo);
table2.AddRow(new string[] {
"Core",
"Common, Containers, Dashboard, Feeds, Navigation, Contents, Scheduling, Settings," +
" Shapes, XmlRpc, Title"});
" Shapes, XmlRpc, Title, Reports"});
table2.AddRow(new string[] {
"Theme",
"SafeMode"});
@@ -152,7 +152,7 @@ this.ScenarioSetup(scenarioInfo);
table3.AddRow(new string[] {
"Core",
"Common, Containers, Dashboard, Feeds, Navigation, Contents, Scheduling, Settings," +
" Shapes, XmlRpc, Title"});
" Shapes, XmlRpc, Title, Reports"});
table3.AddRow(new string[] {
"Theme",
"SafeMode"});
@@ -189,7 +189,7 @@ this.ScenarioSetup(scenarioInfo);
table4.AddRow(new string[] {
"Core",
"Common, Containers, Dashboard, Feeds, Navigation, Contents, Scheduling, Settings," +
" Shapes, XmlRpc, Title"});
" Shapes, XmlRpc, Title, Reports"});
table4.AddRow(new string[] {
"Theme",
"SafeMode, TheAdmin, TheThemeMachine"});

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using Autofac;
using JetBrains.Annotations;
using Moq;
using NUnit.Framework;
using Orchard.Caching;
@@ -50,7 +51,6 @@ namespace Orchard.Tests.Modules.Comments.Services {
builder.RegisterType<Signals>().As<ISignals>();
builder.RegisterType<DefaultContentManagerSession>().As<IContentManagerSession>();
builder.RegisterInstance(new Mock<IContentDefinitionManager>().Object);
builder.RegisterInstance(new Mock<ITransactionManager>().Object);
builder.RegisterInstance(new Mock<IAuthorizer>().Object);
builder.RegisterInstance(new Mock<INotifier>().Object);
builder.RegisterInstance(new Mock<IContentDisplay>().Object);
@@ -187,6 +187,7 @@ namespace Orchard.Tests.Modules.Comments.Services {
}
}
[UsedImplicitly]
public class CommentedItemHandler : ContentHandler {
public CommentedItemHandler() {
Filters.Add(new ActivatingFilter<CommentedItem>("commentedItem"));

View File

@@ -12,6 +12,7 @@ using Orchard.ContentManagement.Handlers;
using Orchard.Data;
using Orchard.Environment.Configuration;
using Orchard.Services;
using Orchard.Tests.ContentManagement;
using Orchard.Tests.Data;
using Orchard.Tests.Stubs;
@@ -52,6 +53,7 @@ namespace Orchard.Tests.Modules {
builder.RegisterInstance(_clock).As<IClock>();
builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>));
builder.RegisterInstance(new ShellSettings { Name = ShellSettings.DefaultName, DataProvider = "SqlCe" });
builder.RegisterInstance(new TestTransactionManager(_session)).As<ITransactionManager>();
Register(builder);
_container = builder.Build();
@@ -61,11 +63,6 @@ namespace Orchard.Tests.Modules {
public void Cleanup() {
if(_container != null)
_container.Dispose();
_transaction.Commit();
if(_session != null)
_session.Close();
}
public abstract void Register(ContainerBuilder builder);

View File

@@ -1,4 +1,6 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Xml.Linq;
using Autofac;
using Moq;
using NHibernate;
@@ -6,6 +8,7 @@ using NUnit.Framework;
using Orchard.Caching;
using Orchard.ContentManagement;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.MetaData.Models;
using Orchard.ContentManagement.MetaData.Services;
using Orchard.ContentManagement.Records;
using Orchard.Core.Settings.Metadata;
@@ -18,7 +21,6 @@ using Orchard.FileSystems.AppData;
using Orchard.FileSystems.WebSite;
using Orchard.ImportExport.Services;
using Orchard.Recipes.Events;
using Orchard.Recipes.Models;
using Orchard.Recipes.Services;
using Orchard.Services;
using Orchard.Tests.ContentManagement;
@@ -42,8 +44,7 @@ namespace Orchard.Tests.Modules.ImportExport.Services {
databaseFileName,
typeof(ContentTypeRecord),
typeof(ContentItemRecord),
typeof(ContentItemVersionRecord),
typeof(RecipeStepResultRecord));
typeof(ContentItemVersionRecord));
}
[SetUp]
@@ -55,6 +56,7 @@ namespace Orchard.Tests.Modules.ImportExport.Services {
builder.RegisterType<RecipeHarvester>().As<IRecipeHarvester>();
builder.RegisterType<RecipeStepExecutor>().As<IRecipeStepExecutor>();
builder.RegisterType<StubStepQueue>().As<IRecipeStepQueue>().InstancePerLifetimeScope();
builder.RegisterType<StubRecipeJournal>().As<IRecipeJournal>();
builder.RegisterType<StubRecipeScheduler>().As<IRecipeScheduler>();
builder.RegisterType<ExtensionManager>().As<IExtensionManager>();
builder.RegisterType<StubAppDataFolder>().As<IAppDataFolder>();
@@ -68,14 +70,13 @@ namespace Orchard.Tests.Modules.ImportExport.Services {
builder.RegisterType<ContentDefinitionManager>().As<IContentDefinitionManager>();
builder.RegisterType<ContentDefinitionWriter>().As<IContentDefinitionWriter>();
builder.RegisterType<StubOrchardServices>().As<IOrchardServices>();
builder.RegisterType<StubAppDataFolder>().As<IAppDataFolder>();
builder.RegisterType<Signals>().As<ISignals>();
builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>));
builder.RegisterType<DeploymentPackageBuilder>().As<IDeploymentPackageBuilder>();
builder.RegisterInstance(new Mock<ISettingsFormatter>().Object);
builder.RegisterInstance(new Mock<IRecipeExecuteEventHandler>().Object);
builder.RegisterInstance(new Mock<ITransactionManager>().Object);
_session = _sessionFactory.OpenSession();
builder.RegisterInstance(new DefaultContentManagerTests.TestSessionLocator(_session)).As<ISessionLocator>();
builder.RegisterInstance(new TestTransactionManager(_session)).As<ITransactionManager>();
_container = builder.Build();
_importExportService = _container.Resolve<IImportExportService>();
@@ -83,7 +84,7 @@ namespace Orchard.Tests.Modules.ImportExport.Services {
[Test]
public void ImportSucceedsWhenRecipeContainsImportSteps() {
Assert.DoesNotThrow(() => _importExportService.ImportRecipe(
Assert.DoesNotThrow(() => _importExportService.Import(
@"<Orchard>
<Recipe>
<Name>MyModuleInstaller</Name>
@@ -94,7 +95,7 @@ namespace Orchard.Tests.Modules.ImportExport.Services {
[Test]
public void ImportDoesntFailsWhenRecipeContainsNonImportSteps() {
Assert.DoesNotThrow(() => _importExportService.ImportRecipe(
Assert.DoesNotThrow(() => _importExportService.Import(
@"<Orchard>
<Recipe>
<Name>MyModuleInstaller</Name>

View File

@@ -75,7 +75,6 @@ namespace Orchard.Tests.Modules.Indexing {
builder.RegisterInstance(new Mock<IContentDisplay>().Object);
builder.RegisterType<DefaultContentManagerSession>().As<IContentManagerSession>();
builder.RegisterInstance(new Mock<ITransactionManager>().Object);
builder.RegisterInstance(new Mock<IAuthorizer>().Object);
builder.RegisterType<OrchardServices>().As<IOrchardServices>();

View File

@@ -17,6 +17,7 @@ namespace Orchard.Tests.Modules.Media.Services {
private const string FolderName1 = "Folder1";
private const string FolderName2 = "Folder2";
private const string FolderName3 = "Folder3";
private const string FolderRecipeJournal = "RecipeJournal";
private const string InnerDirectory = "MyDir";
@@ -53,9 +54,11 @@ namespace Orchard.Tests.Modules.Media.Services {
[Test]
public void GetMediaFoldersTest() {
StorageProvider.ListFoldersPredicate = path => {
return string.IsNullOrEmpty(path) ? new[] {new StubStorageFolder(FolderName1)}
: string.Equals(path, FolderName1) ? new[] {new StubStorageFolder(FolderName2), new StubStorageFolder(FolderName3)}
: new StubStorageFolder[] { };
return string.IsNullOrEmpty(path)
? new[] {new StubStorageFolder(FolderName1)}
: string.Equals(path, FolderName1)
? new[] {new StubStorageFolder(FolderName2), new StubStorageFolder(FolderName3)}
: string.Equals(path, FolderRecipeJournal) ? new[] { new StubStorageFolder(FolderRecipeJournal), new StubStorageFolder(FolderName1) } : new StubStorageFolder[] { };
};
IEnumerable<MediaFolder> mediaFolders = MediaService.GetMediaFolders(null);
@@ -69,6 +72,10 @@ namespace Orchard.Tests.Modules.Media.Services {
Assert.That(mediaFolders.Count(), Is.EqualTo(2), "Folder1 has 2 sub directories");
Assert.That(mediaFolders.FirstOrDefault(mediaFolder => mediaFolder.Name.Equals(FolderName2)), Is.Not.Null, "Correct sub directory in root path");
Assert.That(mediaFolders.FirstOrDefault(mediaFolder => mediaFolder.Name.Equals(FolderName3)), Is.Not.Null, "Correct sub directory in root path");
mediaFolders = MediaService.GetMediaFolders(FolderRecipeJournal);
Assert.That(mediaFolders.Count(), Is.EqualTo(1), "Folder that contains RecipeJournal hides the RecipeJournal directory.");
Assert.That(mediaFolders.FirstOrDefault(mediaFolder => mediaFolder.Name.Equals(FolderName1)), Is.Not.Null, "Correct sub directory in root path");
}
[Test]

View File

@@ -94,7 +94,7 @@ namespace Orchard.Tests.Modules.Migrations {
builder.RegisterType<StubHostEnvironment>().As<IHostEnvironment>();
_session = _sessionFactory.OpenSession();
builder.RegisterInstance(new DefaultContentManagerTests.TestSessionLocator(_session)).As<ISessionLocator>();
builder.RegisterInstance(new TestTransactionManager(_session)).As<ITransactionManager>();
builder.RegisterInstance(new ShellBlueprint());

View File

@@ -205,7 +205,6 @@
<ProjectReference Include="..\Orchard.Web\Core\Orchard.Core.csproj">
<Project>{9916839C-39FC-4CEB-A5AF-89CA7E87119F}</Project>
<Name>Orchard.Core</Name>
<Private>True</Private>
</ProjectReference>
<ProjectReference Include="..\Orchard.Web\Modules\Lucene\Lucene.csproj">
<Project>{D5D447D7-EF8E-43A6-B9A4-3B025DD9F45D}</Project>
@@ -302,7 +301,6 @@
<ProjectReference Include="..\Orchard\Orchard.Framework.csproj">
<Project>{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}</Project>
<Name>Orchard.Framework</Name>
<Private>True</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
@@ -336,10 +334,10 @@
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
-->
<Target Name="CopySqlCeBinaries">
<ItemGroup>

View File

@@ -67,6 +67,7 @@ namespace Orchard.Tests.Modules.Recipes.RecipeHandlers {
builder.RegisterType<ShellStateManager>().As<IShellStateManager>().SingleInstance();
builder.RegisterType<StubEventBus>().As<IEventBus>().SingleInstance();
builder.RegisterType<ModuleRecipeHandler>();
builder.RegisterType<StubRecipeJournal>().As<IRecipeJournal>();
builder.RegisterSource(new EventsRegistrationSource());
}

View File

@@ -6,7 +6,6 @@ using Autofac;
using Moq;
using NUnit.Framework;
using Orchard.Caching;
using Orchard.Data;
using Orchard.Environment.Extensions;
using Orchard.Environment.Extensions.Folders;
using Orchard.Environment.Extensions.Loaders;
@@ -17,9 +16,6 @@ using Orchard.Recipes.Services;
using Orchard.Services;
using Orchard.Tests.Stubs;
using Orchard.Recipes.Events;
using Orchard.Data;
using System;
using System.Linq.Expressions;
namespace Orchard.Tests.Modules.Recipes.Services {
[TestFixture]
@@ -74,6 +70,7 @@ namespace Orchard.Tests.Modules.Recipes.Services {
builder.RegisterType<RecipeHarvester>().As<IRecipeHarvester>();
builder.RegisterType<RecipeStepExecutor>().As<IRecipeStepExecutor>();
builder.RegisterType<StubStepQueue>().As<IRecipeStepQueue>().InstancePerLifetimeScope();
builder.RegisterType<StubRecipeJournal>().As<IRecipeJournal>();
builder.RegisterType<StubRecipeScheduler>().As<IRecipeScheduler>();
builder.RegisterType<ExtensionManager>().As<IExtensionManager>();
builder.RegisterType<StubAppDataFolder>().As<IAppDataFolder>();
@@ -87,9 +84,6 @@ namespace Orchard.Tests.Modules.Recipes.Services {
builder.RegisterType<RecipeParser>().As<IRecipeParser>();
builder.RegisterType<StubWebSiteFolder>().As<IWebSiteFolder>();
builder.RegisterType<CustomRecipeHandler>().As<IRecipeHandler>();
builder.RegisterInstance(new StubRecipeStepResultRecordRepository()).As<IRepository<RecipeStepResultRecord>>();
builder.RegisterInstance(new Mock<IRecipeExecuteEventHandler>().Object);
builder.RegisterInstance(new Mock<ITransactionManager>().Object);
_container = builder.Build();
_recipeManager = _container.Resolve<IRecipeManager>();
@@ -104,7 +98,7 @@ namespace Orchard.Tests.Modules.Recipes.Services {
[Test]
public void HarvestRecipesFailsToFindRecipesWhenCalledWithNotExistingExtension() {
var recipes = (List<Recipe>)_recipeHarvester.HarvestRecipes("cantfindme");
var recipes = (List<Recipe>) _recipeHarvester.HarvestRecipes("cantfindme");
Assert.That(recipes.Count, Is.EqualTo(0));
}
@@ -117,7 +111,7 @@ namespace Orchard.Tests.Modules.Recipes.Services {
[Test]
public void ParseRecipeLoadsRecipeMetaDataIntoModel() {
var recipes = (List<Recipe>)_recipeHarvester.HarvestRecipes("Sample1");
var recipes = (List<Recipe>) _recipeHarvester.HarvestRecipes("Sample1");
Assert.That(recipes.Count, Is.EqualTo(1));
var sampleRecipe = recipes[0];
@@ -136,7 +130,7 @@ namespace Orchard.Tests.Modules.Recipes.Services {
Assert.That(recipes.Count, Is.EqualTo(1));
var sampleRecipe = recipes[0];
var recipeSteps = (List<RecipeStep>)sampleRecipe.RecipeSteps;
var recipeSteps = (List<RecipeStep>) sampleRecipe.RecipeSteps;
Assert.That(recipeSteps.Count, Is.EqualTo(9));
}
@@ -156,8 +150,30 @@ namespace Orchard.Tests.Modules.Recipes.Services {
Assert.That(CustomRecipeHandler.AttributeValue == "value1");
}
}
public class StubRecipeJournal : IRecipeJournal {
public void ExecutionStart(string executionId) {
}
public void ExecutionComplete(string executionId) {
}
public void ExecutionFailed(string executionId) {
}
public void WriteJournalEntry(string executionId, string message) {
}
public RecipeJournal GetRecipeJournal(string executionId) {
return new RecipeJournal();
}
public RecipeStatus GetRecipeStatus(string executionId) {
return RecipeStatus.Complete;
}
}
public class StubStepQueue : IRecipeStepQueue {
readonly Queue<RecipeStep> _queue = new Queue<RecipeStep>();
@@ -170,22 +186,6 @@ namespace Orchard.Tests.Modules.Recipes.Services {
}
}
public class StubRecipeStepResultRecordRepository : IRepository<RecipeStepResultRecord> {
private List<RecipeStepResultRecord> _records = new List<RecipeStepResultRecord>();
public IQueryable<RecipeStepResultRecord> Table { get { return _records.AsQueryable(); } }
public void Copy(RecipeStepResultRecord source, RecipeStepResultRecord target) { }
public int Count(Expression<Func<RecipeStepResultRecord, bool>> predicate) { return _records.Count; }
public void Create(RecipeStepResultRecord entity) { _records.Add(entity); }
public void Delete(RecipeStepResultRecord entity) { _records.Remove(entity); }
public IEnumerable<RecipeStepResultRecord> Fetch(Expression<Func<RecipeStepResultRecord, bool>> predicate) { throw new NotImplementedException(); }
public IEnumerable<RecipeStepResultRecord> Fetch(Expression<Func<RecipeStepResultRecord, bool>> predicate, Action<Orderable<RecipeStepResultRecord>> order) { throw new NotImplementedException(); }
public IEnumerable<RecipeStepResultRecord> Fetch(Expression<Func<RecipeStepResultRecord, bool>> predicate, Action<Orderable<RecipeStepResultRecord>> order, int skip, int count) { throw new NotImplementedException(); }
public void Flush() { }
public RecipeStepResultRecord Get(Expression<Func<RecipeStepResultRecord, bool>> predicate) { throw new NotImplementedException(); }
public RecipeStepResultRecord Get(int id) { throw new NotImplementedException(); }
public void Update(RecipeStepResultRecord entity) { }
}
public class StubRecipeScheduler : IRecipeScheduler {
private readonly IRecipeStepExecutor _recipeStepExecutor;
@@ -194,13 +194,13 @@ namespace Orchard.Tests.Modules.Recipes.Services {
}
public void ScheduleWork(string executionId) {
while (_recipeStepExecutor.ExecuteNextStep(executionId)) { }
while (_recipeStepExecutor.ExecuteNextStep(executionId)) ;
}
}
public class CustomRecipeHandler : IRecipeHandler {
public static string AttributeValue;
public string[] _handles = { "Module", "Theme", "Migration", "Custom1", "Custom2", "Command", "Metadata", "Feature", "Settings" };
public string[] _handles = {"Module", "Theme", "Migration", "Custom1", "Custom2", "Command", "Metadata", "Feature", "Settings"};
public void ExecuteRecipeStep(RecipeContext recipeContext) {
if (_handles.Contains(recipeContext.RecipeStep.Name)) {

View File

@@ -74,7 +74,6 @@ namespace Orchard.Tests.Modules.Users.Controllers {
builder.RegisterType<UserPartHandler>().As<IContentHandler>();
builder.RegisterType<OrchardServices>().As<IOrchardServices>();
builder.RegisterInstance(new DefaultContentManagerTests.TestSessionLocator(_session)).As<ITransactionManager>();
builder.RegisterInstance(new Work<IEnumerable<IShapeTableEventHandler>>(resolve => _container.Resolve<IEnumerable<IShapeTableEventHandler>>())).AsSelf();
builder.RegisterType<DefaultShapeTableManager>().As<IShapeTableManager>();
builder.RegisterType<DefaultShapeFactory>().As<IShapeFactory>();

View File

@@ -30,29 +30,15 @@ using Orchard.UI.PageClass;
using Orchard.Users.Handlers;
using Orchard.Users.Models;
using Orchard.Users.Services;
using Orchard.Services;
using Orchard.Tests.ContentManagement;
namespace Orchard.Tests.Modules.Users.Services {
[TestFixture]
public class MembershipServiceTests {
private IMembershipValidationService _membershipValidationService;
private IMembershipService _membershipService;
private ISessionFactory _sessionFactory;
private ISession _session;
private IContainer _container;
private StubClock _clock;
public class TestSessionLocator : ISessionLocator {
private readonly ISession _session;
public TestSessionLocator(ISession session) {
_session = session;
}
public ISession For(Type entityType) {
return _session;
}
}
[TestFixtureSetUp]
public void InitFixture() {
@@ -74,7 +60,6 @@ namespace Orchard.Tests.Modules.Users.Services {
public void Init() {
var builder = new ContainerBuilder();
//builder.RegisterModule(new ImplicitCollectionSupportModule());
builder.RegisterType<MembershipValidationService>().As<IMembershipValidationService>();
builder.RegisterType<MembershipService>().As<IMembershipService>();
builder.RegisterType<DefaultContentQuery>().As<IContentQuery>();
builder.RegisterType<DefaultContentManager>().As<IContentManager>();
@@ -91,19 +76,24 @@ namespace Orchard.Tests.Modules.Users.Services {
builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>));
builder.RegisterType<DefaultShapeTableManager>().As<IShapeTableManager>();
builder.RegisterType<DefaultShapeFactory>().As<IShapeFactory>();
builder.RegisterInstance(_clock = new StubClock()).As<IClock>();
builder.RegisterType<StubExtensionManager>().As<IExtensionManager>();
builder.RegisterInstance(new Mock<IPageClassBuilder>().Object);
builder.RegisterType<DefaultContentDisplay>().As<IContentDisplay>();
builder.RegisterType<InfosetHandler>().As<IContentHandler>();
_session = _sessionFactory.OpenSession();
builder.RegisterInstance(new TestSessionLocator(_session)).As<ISessionLocator>();
builder.RegisterInstance(new TestTransactionManager(_session)).As<ITransactionManager>();
_container = builder.Build();
_membershipValidationService = _container.Resolve<IMembershipValidationService>();
_membershipService = _container.Resolve<IMembershipService>();
}
[TearDown]
public void Cleanup() {
if (_container != null)
_container.Dispose();
}
[Test]
public void CreateUserShouldAllocateModelAndCreateRecords() {
var user = _membershipService.CreateUser(new CreateUserParams("a", "b", "c", null, null, true));
@@ -157,64 +147,5 @@ namespace Orchard.Tests.Modules.Users.Services {
Assert.That(validate2, Is.Null);
Assert.That(validate3, Is.Not.Null);
}
[Test]
public void UsersWhoHaveNeverLoggedInCanBeAuthenticated() {
var user = (UserPart)_membershipService.CreateUser(new CreateUserParams("a", "b", "c", null, null, true));
Assert.That(_membershipValidationService.CanAuthenticateWithCookie(user), Is.True);
}
[Test]
public void UsersWhoHaveNeverLoggedOutCanBeAuthenticated() {
var user = (UserPart)_membershipService.CreateUser(new CreateUserParams("a", "b", "c", null, null, true));
user.LastLoginUtc = _clock.UtcNow;
_clock.Advance(TimeSpan.FromMinutes(1));
Assert.That(_membershipValidationService.CanAuthenticateWithCookie(user), Is.True);
}
[Test]
public void UsersWhoHaveLoggedOutCantBeAuthenticated() {
var user = (UserPart)_membershipService.CreateUser(new CreateUserParams("a", "b", "c", null, null, true));
user.LastLoginUtc = _clock.UtcNow;
_clock.Advance(TimeSpan.FromMinutes(1));
user.LastLogoutUtc = _clock.UtcNow;
_clock.Advance(TimeSpan.FromMinutes(1));
Assert.That(_membershipValidationService.CanAuthenticateWithCookie(user), Is.False);
}
[Test]
public void UsersWhoHaveLoggedInCanBeAuthenticated() {
var user = (UserPart)_membershipService.CreateUser(new CreateUserParams("a", "b", "c", null, null, true));
user.LastLogoutUtc = _clock.UtcNow;
_clock.Advance(TimeSpan.FromMinutes(1));
user.LastLoginUtc = _clock.UtcNow;
_clock.Advance(TimeSpan.FromMinutes(1));
Assert.That(_membershipValidationService.CanAuthenticateWithCookie(user), Is.True);
}
[Test]
public void PendingUsersCantBeAuthenticated() {
var user = (UserPart)_membershipService.CreateUser(new CreateUserParams("a", "b", "c", null, null, true));
user.RegistrationStatus = UserStatus.Pending;
Assert.That(_membershipValidationService.CanAuthenticateWithCookie(user), Is.False);
}
[Test]
public void ApprovedUsersCanBeAuthenticated() {
var user = (UserPart)_membershipService.CreateUser(new CreateUserParams("a", "b", "c", null, null, true));
user.RegistrationStatus = UserStatus.Approved;
Assert.That(_membershipValidationService.CanAuthenticateWithCookie(user), Is.True);
}
}
}

View File

@@ -34,6 +34,7 @@ using Orchard.Users.Services;
using Orchard.Services;
using Orchard.Tests.Messaging;
using Orchard.Tests.Modules.Stubs;
using Orchard.Tests.ContentManagement;
namespace Orchard.Tests.Modules.Users.Services {
[TestFixture]
@@ -47,19 +48,6 @@ namespace Orchard.Tests.Modules.Users.Services {
private IContainer _container;
private CultureInfo _currentCulture;
public class TestSessionLocator : ISessionLocator {
private readonly ISession _session;
public TestSessionLocator(ISession session) {
_session = session;
}
public ISession For(Type entityType) {
return _session;
}
}
[TestFixtureSetUp]
public void InitFixture() {
_currentCulture = Thread.CurrentThread.CurrentCulture;
@@ -109,9 +97,8 @@ namespace Orchard.Tests.Modules.Users.Services {
builder.RegisterInstance(ShellSettingsUtility.CreateEncryptionEnabled());
_session = _sessionFactory.OpenSession();
_session.BeginTransaction();
builder.RegisterInstance(new TestTransactionManager(_session)).As<ITransactionManager>();
builder.RegisterInstance(new TestSessionLocator(_session)).As<ISessionLocator>();
_container = builder.Build();
_membershipService = _container.Resolve<IMembershipService>();
_userService = _container.Resolve<IUserService>();
@@ -119,8 +106,8 @@ namespace Orchard.Tests.Modules.Users.Services {
[TearDown]
public void TearDown() {
_session.Transaction.Commit();
_session.Transaction.Dispose();
if (_container != null)
_container.Dispose();
}
[Test]

View File

@@ -93,7 +93,6 @@ namespace Orchard.Tests.Modules.Widgets.Services {
builder.RegisterType<Signals>().As<ISignals>();
builder.RegisterType<DefaultContentManagerSession>().As<IContentManagerSession>();
builder.RegisterInstance(new Mock<IContentDefinitionManager>().Object);
builder.RegisterInstance(new Mock<ITransactionManager>().Object);
builder.RegisterInstance(new Mock<IAuthorizer>().Object);
builder.RegisterInstance(new Mock<INotifier>().Object);
builder.RegisterInstance(mockFeatureManager.Object);

View File

@@ -63,58 +63,6 @@ namespace Orchard.Tests.ContentManagement {
Assert.IsFalse(ContentIdentity.ContentIdentityEqualityComparer.AreEquivalent(identity1, identity2));
Assert.IsFalse(ContentIdentity.ContentIdentityEqualityComparer.AreEquivalent(identity2, identity1));
}
[Test]
public void IdentitiesCanBeAddedWithNoPriority() {
var contentIdentity = new ContentIdentity();
contentIdentity.Add("identifier", "CAEEB150-F5E9-481D-9FF9-3053D23329C1");
contentIdentity.Add("alias", "some-unique-item-alias/sub-alias");
Assert.AreEqual("/alias=some-unique-item-alias\\/sub-alias/identifier=CAEEB150-F5E9-481D-9FF9-3053D23329C1", contentIdentity.ToString());
}
[Test]
public void IdentitiesCanBeAddedWithSamePriority() {
var contentIdentity = new ContentIdentity();
contentIdentity.Add("identifier", "CAEEB150-F5E9-481D-9FF9-3053D23329C1", 5);
contentIdentity.Add("alias", "some-unique-item-alias/sub-alias", 5);
var contentIdentityNegative = new ContentIdentity();
contentIdentityNegative.Add("identifier", "CAEEB150-F5E9-481D-9FF9-3053D23329C1", -5);
contentIdentityNegative.Add("alias", "some-unique-item-alias/sub-alias", -5);
Assert.AreEqual("/alias=some-unique-item-alias\\/sub-alias/identifier=CAEEB150-F5E9-481D-9FF9-3053D23329C1", contentIdentity.ToString());
Assert.AreEqual("/alias=some-unique-item-alias\\/sub-alias/identifier=CAEEB150-F5E9-481D-9FF9-3053D23329C1", contentIdentityNegative.ToString());
}
[Test]
public void LowestPriorityIdentityIsIgnored() {
var contentIdentity = new ContentIdentity();
contentIdentity.Add("alias", "some-unique-item-alias/sub-alias", 0);
contentIdentity.Add("identifier", "CAEEB150-F5E9-481D-9FF9-3053D23329C1", 5);
var contentIdentityNegative = new ContentIdentity();
contentIdentityNegative.Add("alias", "some-unique-item-alias/sub-alias", -5);
contentIdentityNegative.Add("identifier", "CAEEB150-F5E9-481D-9FF9-3053D23329C1", 0);
Assert.AreEqual("/identifier=CAEEB150-F5E9-481D-9FF9-3053D23329C1", contentIdentity.ToString());
Assert.AreEqual("/identifier=CAEEB150-F5E9-481D-9FF9-3053D23329C1", contentIdentityNegative.ToString());
}
[Test]
public void HighestPriorityIdentityIsRetained() {
var contentIdentity = new ContentIdentity();
contentIdentity.Add("identifier", "CAEEB150-F5E9-481D-9FF9-3053D23329C1", 5);
contentIdentity.Add("alias", "some-unique-item-alias/sub-alias", 0);
var contentIdentityNegative = new ContentIdentity();
contentIdentityNegative.Add("identifier", "CAEEB150-F5E9-481D-9FF9-3053D23329C1", 0);
contentIdentityNegative.Add("alias", "some-unique-item-alias/sub-alias", -5);
Assert.AreEqual("/identifier=CAEEB150-F5E9-481D-9FF9-3053D23329C1", contentIdentity.ToString());
Assert.AreEqual("/identifier=CAEEB150-F5E9-481D-9FF9-3053D23329C1", contentIdentityNegative.ToString());
}
}
}

View File

@@ -29,6 +29,7 @@ namespace Orchard.Tests.ContentManagement {
private IContentManager _manager;
private ISessionFactory _sessionFactory;
private ISession _session;
private ITransactionManager _transactionManager;
[TestFixtureSetUp]
public void InitFixture() {
@@ -74,7 +75,7 @@ namespace Orchard.Tests.ContentManagement {
builder.RegisterType<DefaultContentDisplay>().As<IContentDisplay>();
_session = _sessionFactory.OpenSession();
builder.RegisterInstance(new DefaultContentManagerTests.TestSessionLocator(_session)).As<ISessionLocator>();
builder.RegisterInstance(_transactionManager = new TestTransactionManager(_session)).As<ITransactionManager>();
_session.Delete(string.Format("from {0}", typeof(GammaRecord).FullName));
_session.Delete(string.Format("from {0}", typeof(DeltaRecord).FullName));
@@ -82,14 +83,19 @@ namespace Orchard.Tests.ContentManagement {
_session.Delete(string.Format("from {0}", typeof(ContentItemVersionRecord).FullName));
_session.Delete(string.Format("from {0}", typeof(ContentItemRecord).FullName));
_session.Delete(string.Format("from {0}", typeof(ContentTypeRecord).FullName));
_session.Flush();
_session.Clear();
_transactionManager.RequireNew();
_container = builder.Build();
_manager = _container.Resolve<IContentManager>();
}
[TearDown]
public void Cleanup() {
if (_container != null)
_container.Dispose();
}
private List<IContent> AddSampleData() {
var items = new List<IContent> {
_manager.Create<AlphaPart>("alpha", init => { }),
@@ -98,7 +104,7 @@ namespace Orchard.Tests.ContentManagement {
_manager.Create<DeltaPart>("delta", init => { init.Record.Quux = "the quux value"; })
};
_session.Flush();
_transactionManager.RequireNew();
return items;
}
@@ -212,7 +218,7 @@ namespace Orchard.Tests.ContentManagement {
var twoId = _manager.Create<GammaPart>("gamma", init => { init.Record.Frap = "two"; }).ContentItem.Id;
_manager.Create<GammaPart>("gamma", init => { init.Record.Frap = "three"; });
var fourId = _manager.Create<GammaPart>("gamma", init => { init.Record.Frap = "four"; }).ContentItem.Id;
_session.Flush();
_transactionManager.RequireNew();
var two = _manager.Query()
@@ -239,7 +245,7 @@ namespace Orchard.Tests.ContentManagement {
_manager.Create<GammaPart>("gamma", init => { init.Record.Frap = "two"; });
_manager.Create<GammaPart>("gamma", init => { init.Record.Frap = "three"; });
_manager.Create<GammaPart>("gamma", init => { init.Record.Frap = "four"; });
_session.Flush();
_transactionManager.RequireNew();
var twoOrFour = _manager.Query<GammaPart, GammaRecord>()
.Where(x => x.Frap == "one" || x.Frap == "four")
@@ -271,8 +277,7 @@ namespace Orchard.Tests.ContentManagement {
_manager.Create<GammaPart>("gamma", init => { init.Record.Frap = "two"; });
_manager.Create<GammaPart>("gamma", init => { init.Record.Frap = "three"; });
_manager.Create<GammaPart>("gamma", init => { init.Record.Frap = "four"; });
_session.Flush();
_session.Clear();
_transactionManager.RequireNew();
var ascending = _manager.Query("gamma")
.OrderBy<GammaRecord>(x => x.Frap)
@@ -282,7 +287,7 @@ namespace Orchard.Tests.ContentManagement {
Assert.That(ascending.First().Record.Frap, Is.EqualTo("four"));
Assert.That(ascending.Last().Record.Frap, Is.EqualTo("two"));
_session.Clear();
_transactionManager.RequireNew();
var descending = _manager.Query<GammaPart, GammaRecord>()
.OrderByDescending(x => x.Frap)
@@ -300,7 +305,7 @@ namespace Orchard.Tests.ContentManagement {
_manager.Create<GammaPart>("gamma", init => { init.Record.Frap = "two"; });
_manager.Create<GammaPart>("gamma", init => { init.Record.Frap = "three"; });
_manager.Create<GammaPart>("gamma", init => { init.Record.Frap = "four"; });
_session.Flush();
_transactionManager.RequireNew();
var reverseById = _manager.Query()
.OrderByDescending<GammaRecord>(x => x.Id)
@@ -346,8 +351,7 @@ namespace Orchard.Tests.ContentManagement {
init.Record.Frap = "four";
init.As<EpsilonPart>().Record.Quad = "4";
});
_session.Flush();
_session.Clear();
_transactionManager.RequireNew();
var results = _manager.Query<EpsilonPart, EpsilonRecord>()
.Where(x => x.Quad == "2" || x.Quad == "3")
@@ -365,21 +369,18 @@ namespace Orchard.Tests.ContentManagement {
init.As<GammaPart>().Record.Frap = "one";
init.As<EpsilonPart>().Record.Quad = "v1";
});
_session.Flush();
_session.Clear();
_transactionManager.RequireNew();
var gamma2 = _manager.Get(gamma1.Id, VersionOptions.DraftRequired);
gamma2.As<GammaPart>().Record.Frap = "two";
gamma2.As<EpsilonPart>().Record.Quad = "v2";
_session.Flush();
_session.Clear();
_transactionManager.RequireNew();
var gamma3 = _manager.Create<ContentItem>("gamma", init => {
init.As<GammaPart>().Record.Frap = "three";
init.As<EpsilonPart>().Record.Quad = "v3";
});
_session.Flush();
_session.Clear();
_transactionManager.RequireNew();
}
[Test]
@@ -562,7 +563,7 @@ namespace Orchard.Tests.ContentManagement {
_manager.Create<GammaPart>("gamma", init => { init.Record.Frap = "two"; });
_manager.Create<GammaPart>("gamma", init => { init.Record.Frap = "three"; });
_manager.Create<GammaPart>("gamma", init => { init.Record.Frap = "four"; });
_session.Flush();
_transactionManager.RequireNew();
var result = _manager.Query<GammaPart, GammaRecord>()
.Where(x => x.Frap.StartsWith("t"))
@@ -579,7 +580,7 @@ namespace Orchard.Tests.ContentManagement {
_manager.Create<GammaPart>("gamma", init => { init.Record.Frap = "two"; });
_manager.Create<GammaPart>("gamma", init => { init.Record.Frap = "three"; });
_manager.Create<GammaPart>("gamma", init => { init.Record.Frap = "four"; });
_session.Flush();
_transactionManager.RequireNew();
var result = _manager.Query<GammaPart, GammaRecord>()
.Where(x => x.Frap.EndsWith("e"))
@@ -596,7 +597,7 @@ namespace Orchard.Tests.ContentManagement {
_manager.Create<GammaPart>("gamma", init => { init.Record.Frap = "two"; });
_manager.Create<GammaPart>("gamma", init => { init.Record.Frap = "three"; });
_manager.Create<GammaPart>("gamma", init => { init.Record.Frap = "four"; });
_session.Flush();
_transactionManager.RequireNew();
var result = _manager.Query<GammaPart, GammaRecord>()
.Where(x => x.Frap.Contains("o"))

View File

@@ -86,84 +86,16 @@ namespace Orchard.Tests.ContentManagement {
builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>));
_session = _sessionFactory.OpenSession();
builder.RegisterInstance(new TestSessionLocator(_session)).As<ISessionLocator>();
builder.RegisterInstance(new TestTransactionManager(_session)).As<ITransactionManager>();
_container = builder.Build();
_manager = _container.Resolve<IContentManager>();
}
public class TestSessionLocator : ISessionLocator, ITransactionManager, IDisposable {
private readonly ISession _session;
private ITransaction _transaction;
private bool _cancelled;
public TestSessionLocator(ISession session) {
_session = session;
}
public ISession For(Type entityType) {
return _session;
}
void ITransactionManager.Demand() {
EnsureSession();
if (_transaction == null) {
_transaction = _session.BeginTransaction(IsolationLevel.ReadCommitted);
}
}
void ITransactionManager.RequireNew() {
((ITransactionManager)this).RequireNew(IsolationLevel.ReadCommitted);
}
void ITransactionManager.RequireNew(IsolationLevel level) {
EnsureSession();
if (_cancelled) {
_transaction.Rollback();
_transaction.Dispose();
_transaction = null;
}
else {
if (_transaction != null) {
_transaction.Commit();
}
}
_transaction = _session.BeginTransaction(level);
}
void ITransactionManager.Cancel() {
_cancelled = true;
}
void IDisposable.Dispose() {
if (_transaction != null) {
try {
if (!_cancelled) {
_transaction.Commit();
}
else {
_transaction.Rollback();
}
_transaction.Dispose();
}
catch {
}
finally {
_transaction = null;
_cancelled = false;
}
}
}
private void EnsureSession() {
if (_session != null) {
return;
}
}
[TearDown]
public void Cleanup() {
if (_container != null)
_container.Dispose();
}
[Test]
@@ -471,46 +403,6 @@ namespace Orchard.Tests.ContentManagement {
Assert.That(gamma2.Record.Versions, Has.Count.EqualTo(2));
}
[Test]
public void DraftRequiredShouldAlwaysBuildNewVersionFromPublishedIfDraftNotFound()
{
Trace.WriteLine("gamma1");
var gamma1 = _manager.Create(DefaultGammaName, VersionOptions.Published);
Trace.WriteLine("flush");
_session.Flush();
_session.Clear();
Trace.WriteLine("gammaDraft1");
var gammaDraft1 = _manager.Get(gamma1.Id, VersionOptions.DraftRequired);
Assert.That(gammaDraft1.Version, Is.EqualTo(2));
Trace.WriteLine("flush");
_session.Flush();
_session.Clear();
Trace.WriteLine("Delete gammaDraft1");
var gammaDraft2 = _manager.Get(gammaDraft1.Id, VersionOptions.Draft);
gammaDraft2.VersionRecord.Latest = false;
Trace.WriteLine("Restore gamma1 as Latest");
var gamma2 = _manager.Get(gamma1.Id, VersionOptions.Published);
var publishedVersion = gamma2.Record.Versions.SingleOrDefault(x => x.Published);
if (publishedVersion != null)
{
publishedVersion.Latest = true;
}
Trace.WriteLine("flush");
_session.Flush();
_session.Clear();
Trace.WriteLine("gammaDraft3");
var gammaDraft3 = _manager.Get(gamma1.Id, VersionOptions.DraftRequired);
Assert.That(gammaDraft3.Version, Is.EqualTo(3));
Assert.That(gammaDraft3.Record, Is.Not.SameAs(gammaDraft2.Record));
Trace.WriteLine("flush");
_session.Flush();
_session.Clear();
}
[Test]
public void UsingGetManyDraftRequiredShouldBuildNewVersionIfLatestIsAlreadyPublished() {
Trace.WriteLine("gamma1");

View File

@@ -72,7 +72,7 @@ namespace Orchard.Tests.ContentManagement {
builder.RegisterType<DefaultContentDisplay>().As<IContentDisplay>();
_session = _sessionFactory.OpenSession();
builder.RegisterInstance(new DefaultContentManagerTests.TestSessionLocator(_session)).As<ISessionLocator>();
builder.RegisterInstance(new TestTransactionManager(_session)).As<ITransactionManager>();
_session.Delete(string.Format("from {0}", typeof(GammaRecord).FullName));
_session.Delete(string.Format("from {0}", typeof(DeltaRecord).FullName));
@@ -88,6 +88,12 @@ namespace Orchard.Tests.ContentManagement {
}
[TearDown]
public void Cleanup() {
if (_container != null)
_container.Dispose();
}
private void AddSampleData() {
_manager.Create<AlphaPart>("alpha", init => { });
_manager.Create<BetaPart>("beta", init => { });

View File

@@ -59,7 +59,6 @@ namespace Orchard.Tests.ContentManagement {
builder.RegisterInstance(new ShellSettings { Name = ShellSettings.DefaultName, DataProvider = "SqlCe" });
builder.RegisterType<SqlCeStatementProvider>().As<ISqlStatementProvider>();
builder.RegisterType<MySqlStatementProvider>().As<ISqlStatementProvider>();
builder.RegisterType<PostgreSqlStatementProvider>().As<ISqlStatementProvider>();
builder.RegisterType<AlphaPartHandler>().As<IContentHandler>();
builder.RegisterType<BetaPartHandler>().As<IContentHandler>();
@@ -80,7 +79,7 @@ namespace Orchard.Tests.ContentManagement {
builder.RegisterType<DefaultContentDisplay>().As<IContentDisplay>();
_session = _sessionFactory.OpenSession();
builder.RegisterInstance(new DefaultContentManagerTests.TestSessionLocator(_session)).As<ISessionLocator>();
builder.RegisterInstance(new TestTransactionManager(_session)).As<ITransactionManager>();
_session.Delete(string.Format("from {0}", typeof(GammaRecord).FullName));
_session.Delete(string.Format("from {0}", typeof(DeltaRecord).FullName));
@@ -98,6 +97,12 @@ namespace Orchard.Tests.ContentManagement {
}
[TearDown]
public void Cleanup() {
if (_container != null)
_container.Dispose();
}
[Test]
public void AllDataTypesCanBeQueried() {
var dt = DateTime.Now;

View File

@@ -1,5 +1,4 @@
using System.Collections.Generic;
using Moq;
using Moq;
using NUnit.Framework;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Records;
@@ -40,7 +39,6 @@ namespace Orchard.Tests.ContentManagement {
_contentManager.Setup(m => m.New(It.IsAny<string>())).Returns(draftItem5);
_contentManager.Setup(m => m.HasResolverForIdentity(It.Is<ContentIdentity>(id => id.Get("ItemId") != null))).Returns(true);
_contentManager.Setup(m => m.ResolveIdentity(It.Is<ContentIdentity>(id => id.Get("ItemId") == "1"))).Returns(publishedItem);
}
#endregion
@@ -156,7 +154,7 @@ namespace Orchard.Tests.ContentManagement {
session.InitializeBatch(0, 2);
var firstIdentity = session.GetNextInBatch();
//get later item as dependency
session.Get(_testItemIdentity5.ToString(), VersionOptions.Latest);
var dependencyItem = session.Get(_testItemIdentity5.ToString(), VersionOptions.Latest);
var dependencyIdentity = session.GetNextInBatch();
var secondIdentity = session.GetNextInBatch();
var afterBatch1 = session.GetNextInBatch();

View File

@@ -0,0 +1,83 @@
using System;
using System.Data;
using NHibernate;
using Orchard.Data;
namespace Orchard.Tests.ContentManagement {
public class TestTransactionManager : ITransactionManager, IDisposable {
private ISession _session;
private ITransaction _transaction;
private bool _cancelled;
public TestTransactionManager(ISession session) {
_session = session;
RequireNew();
}
public void Demand() {
EnsureSession();
}
public void RequireNew() {
RequireNew(IsolationLevel.ReadCommitted);
}
public void RequireNew(IsolationLevel level) {
EnsureSession();
if (_cancelled) {
_transaction.Rollback();
_transaction.Dispose();
_transaction = null;
}
else {
if (_transaction != null) {
_transaction.Commit();
}
}
_transaction = _session.BeginTransaction(level);
}
public void Cancel() {
_cancelled = true;
}
public void Dispose() {
if (_transaction != null) {
try {
if (!_cancelled) {
_transaction.Commit();
}
else {
_transaction.Rollback();
}
_transaction.Dispose();
}
catch {
}
finally {
_transaction = null;
_cancelled = false;
}
}
_session.Close();
_session.Dispose();
_session = null;
}
private void EnsureSession() {
if (_session == null) {
throw new ArgumentNullException("Session can't be null, ever");
}
}
public ISession GetSession() {
EnsureSession();
return _session;
}
}
}

View File

@@ -6,6 +6,7 @@ using System.Linq;
using NHibernate;
using NUnit.Framework;
using Orchard.Data;
using Orchard.Tests.ContentManagement;
using Orchard.Tests.Records;
namespace Orchard.Tests.Data {
@@ -22,7 +23,7 @@ namespace Orchard.Tests.Data {
_databaseFilePath = Path.GetTempFileName();
_sessionFactory = DataUtility.CreateSessionFactory(_databaseFilePath, typeof(FooRecord));
_session = _sessionFactory.OpenSession();
_fooRepos = new Repository<FooRecord>(new StubLocator(_session));
_fooRepos = new Repository<FooRecord>(new TestTransactionManager(_session));
}
[TearDown]

View File

@@ -45,16 +45,22 @@ namespace Orchard.Tests.DataMigration {
typeof(ContentTypeRecord));
}
[TearDown]
public void InitDb() {
foreach ( var record in _repository.Fetch(m => m != null) ) {
_repository.Delete(record);
}
_repository.Flush();
_transactionManager.RequireNew();
}
[TearDown]
public void CleanUp() {
if (_container != null)
_container.Dispose();
}
public void Init(IEnumerable<Type> dataMigrations) {
var builder = new ContainerBuilder();
_folders = new StubFolders();
var contentDefinitionManager = new Mock<IContentDefinitionManager>().Object;
@@ -73,7 +79,7 @@ namespace Orchard.Tests.DataMigration {
builder.RegisterType<StubParallelCacheContext>().As<IParallelCacheContext>();
builder.RegisterType<StubAsyncTokenProvider>().As<IAsyncTokenProvider>();
_session = _sessionFactory.OpenSession();
builder.RegisterInstance(new DefaultContentManagerTests.TestSessionLocator(_session)).As<ISessionLocator>().As<ITransactionManager>();
builder.RegisterInstance(new TestTransactionManager(_session)).As<ITransactionManager>();
foreach(var type in dataMigrations) {
builder.RegisterType(type).As<IDataMigration>();
}

View File

@@ -12,14 +12,15 @@ using Orchard.Environment;
using Orchard.Environment.Configuration;
using Orchard.Environment.ShellBuilders.Models;
using Orchard.FileSystems.AppData;
using Orchard.Reports.Services;
using Orchard.Tests.ContentManagement;
using System.IO;
using Orchard.Tests.Environment;
using Orchard.Tests.FileSystems.AppData;
using Orchard.Tests.Stubs;
namespace Orchard.Tests.DataMigration
{
[TestFixture]
namespace Orchard.Tests.DataMigration {
[TestFixture]
public class SchemaBuilderTestsBase {
private IContainer _container;
private ISessionFactory _sessionFactory;
@@ -44,13 +45,14 @@ namespace Orchard.Tests.DataMigration
builder.RegisterInstance(appDataFolder).As<IAppDataFolder>();
builder.RegisterType<SqlCeDataServicesProvider>().As<IDataServicesProvider>();
builder.RegisterType<DataServicesProviderFactory>().As<IDataServicesProviderFactory>();
builder.RegisterType<StubReportsCoordinator>().As<IReportsCoordinator>();
builder.RegisterType<DefaultDataMigrationInterpreter>().As<IDataMigrationInterpreter>();
builder.RegisterType<SqlCeCommandInterpreter>().As<ICommandInterpreter>();
builder.RegisterType<SessionConfigurationCache>().As<ISessionConfigurationCache>();
builder.RegisterType<SessionFactoryHolder>().As<ISessionFactoryHolder>();
builder.RegisterType<DefaultDatabaseCacheConfiguration>().As<IDatabaseCacheConfiguration>();
builder.RegisterType<StubHostEnvironment>().As<IHostEnvironment>();
builder.RegisterInstance(new DefaultContentManagerTests.TestSessionLocator(_session)).As<ISessionLocator>();
builder.RegisterInstance(new TestTransactionManager(_session)).As<ITransactionManager>();
builder.RegisterInstance(new ShellBlueprint { Records = Enumerable.Empty<RecordBlueprint>() }).As<ShellBlueprint>();
builder.RegisterInstance(new ShellSettings { Name = "temp", DataProvider = "SqlCe", DataTablePrefix = "TEST" }).As<ShellSettings>();
builder.RegisterModule(new DataModule());

View File

@@ -11,6 +11,7 @@ using Orchard.ContentManagement.Handlers;
using Orchard.Data;
using Orchard.Environment.Configuration;
using Orchard.Services;
using Orchard.Tests.ContentManagement;
using Orchard.Tests.Data;
using Orchard.Tests.Stubs;
@@ -48,7 +49,8 @@ namespace Orchard.Tests {
builder.RegisterInstance(_clock).As<IClock>();
builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>));
builder.RegisterInstance(new ShellSettings { Name = ShellSettings.DefaultName, DataProvider = "SqlCe" });
builder.RegisterInstance(new TestTransactionManager(_session)).As<ITransactionManager>();
Register(builder);
_container = builder.Build();
}
@@ -57,9 +59,6 @@ namespace Orchard.Tests {
public void Cleanup() {
if(_container != null)
_container.Dispose();
if(_session != null)
_session.Close();
}
public abstract void Register(ContainerBuilder builder);

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Web.Routing;
using Autofac;
using JetBrains.Annotations;
using Moq;
using NUnit.Framework;
using Orchard.DisplayManagement;
@@ -18,7 +19,7 @@ namespace Orchard.Tests.DisplayManagement.Descriptors {
public class ShapeAttributeBindingStrategyTests : ContainerTestBase {
private Feature _testFeature;
protected override void Register(ContainerBuilder builder) {
protected override void Register([NotNull] ContainerBuilder builder) {
if (builder == null) {
throw new ArgumentNullException("builder");
}

View File

@@ -160,6 +160,38 @@ namespace Orchard.Tests.Environment.ShellBuilders {
public class TestDependency : ITestDependency {
}
[Test]
public void ComponentsImplementingMultipleContractsAreResolvableOnce() {
var settings = CreateSettings();
var blueprint = CreateBlueprint(
WithDependency<MultipleDependency>()
);
var factory = _container.Resolve<IShellContainerFactory>();
var shellContainer = factory.CreateContainer(settings, blueprint);
var multipleDependency1 = shellContainer.Resolve<IMultipleDependency1>();
var multipleDependency2 = shellContainer.Resolve<IMultipleDependency2>();
Assert.That(multipleDependency1, Is.Not.Null);
Assert.That(multipleDependency2, Is.Not.Null);
Assert.That(multipleDependency1, Is.InstanceOf<MultipleDependency>());
Assert.That(multipleDependency2, Is.InstanceOf<MultipleDependency>());
Assert.True(multipleDependency1 == multipleDependency2);
}
public interface IMultipleDependency1 : IDependency {
}
public interface IMultipleDependency2 : IDependency {
}
public class MultipleDependency : IMultipleDependency1, IMultipleDependency2 {
}
[Test]
public void ExtraInformationCanDropIntoProperties() {
var settings = CreateSettings();

View File

@@ -46,7 +46,6 @@ namespace Orchard.Tests.Localization {
builder.RegisterType<DefaultShapeTableManager>().As<IShapeTableManager>();
builder.RegisterType<DefaultShapeFactory>().As<IShapeFactory>();
builder.RegisterInstance(new Mock<IContentDefinitionManager>().Object);
builder.RegisterInstance(new Mock<ITransactionManager>().Object);
builder.RegisterInstance(new Mock<IAuthorizer>().Object);
builder.RegisterInstance(new Mock<INotifier>().Object);
builder.RegisterInstance(new Mock<IContentDisplay>().Object);
@@ -60,7 +59,7 @@ namespace Orchard.Tests.Localization {
builder.RegisterType<StubCacheManager>().As<ICacheManager>();
builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>));
_session = _sessionFactory.OpenSession();
builder.RegisterInstance(new DefaultContentManagerTests.TestSessionLocator(_session)).As<ISessionLocator>();
builder.RegisterInstance(new TestTransactionManager(_session)).As<ITransactionManager>();
_container = builder.Build();
_cultureManager = _container.Resolve<ICultureManager>();
}

View File

@@ -213,9 +213,9 @@ namespace Orchard.Tests.Localization {
[Description("DateTime which is DateTimeKind.Local is converted to DateTimeKind.Utc.")]
public void ConvertFromLocalizedDateStringTest01() {
var container = TestHelpers.InitializeContainer("en-US", "GregorianCalendar", TimeZoneInfo.Utc);
var dateTimeLocal = new DateTime(1998, 1, 15);
var dateTimeLocalString = dateTimeLocal.ToShortDateString();
var target = container.Resolve<IDateLocalizationServices>();
var dateTimeLocal = new DateTime(1998, 1, 15);
var dateTimeLocalString = target.ConvertToLocalizedDateString(dateTimeLocal);
var result = target.ConvertFromLocalizedDateString(dateTimeLocalString);
Assert.AreEqual(DateTimeKind.Utc, result.Value.Kind);
}

View File

@@ -208,6 +208,7 @@
<Compile Include="ContentManagement\Records\GammaRecord.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ContentManagement\TestTransactionManager.cs" />
<Compile Include="ContentManagement\XmlHelperTests.cs" />
<Compile Include="DatabaseEnabledTestsBase.cs" />
<Compile Include="DataMigration\SchemaBuilderTests.cs" />
@@ -281,6 +282,7 @@
<Compile Include="Stubs\StubHttpContextAccessor.cs" />
<Compile Include="Stubs\StubWorkContextAccessor.cs" />
<Compile Include="Stubs\StubExtensionManager.cs" />
<Compile Include="Stubs\StubReportsCoordinator.cs" />
<Compile Include="Stubs\StubVirtualPathProvider.cs" />
<Compile Include="Stubs\StubFileSystem.cs" />
<Compile Include="Stubs\StubAppDataFolder.cs" />
@@ -332,12 +334,10 @@
<ProjectReference Include="..\Orchard.Web\Core\Orchard.Core.csproj">
<Project>{9916839C-39FC-4CEB-A5AF-89CA7E87119F}</Project>
<Name>Orchard.Core</Name>
<Private>True</Private>
</ProjectReference>
<ProjectReference Include="..\Orchard\Orchard.Framework.csproj">
<Project>{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}</Project>
<Name>Orchard.Framework</Name>
<Private>True</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
@@ -383,10 +383,10 @@
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
-->
<Target Name="CopySqlCeBinaries">
<ItemGroup>

View File

@@ -20,11 +20,10 @@ namespace Orchard.Tests.Stubs {
get { return _fileSystem; }
}
public IEnumerable<string> ListFiles(string path, bool includeSubdirectories = false) {
public IEnumerable<string> ListFiles(string path) {
var entry = _fileSystem.GetDirectoryEntry(path);
if (entry == null) {
return new string[] { };
}
if (entry == null)
throw new ArgumentException();
return entry.Entries.Where(e => e is StubFileSystem.FileEntry).Select(e => Combine(path, e.Name));
}
@@ -107,7 +106,7 @@ namespace Orchard.Tests.Stubs {
}
public string MapPath(string path) {
return path;
throw new NotImplementedException();
}
public string GetVirtualPath(string path) {

View File

@@ -0,0 +1,14 @@
using Orchard.Reports;
using Orchard.Reports.Services;
namespace Orchard.Tests.Stubs {
public class StubReportsCoordinator : IReportsCoordinator {
public void Add(string reportKey, ReportEntryType type, string message) {
}
public int Register(string reportKey, string activityName, string title) {
return 0;
}
}
}

View File

@@ -96,7 +96,6 @@
<ProjectReference Include="..\Orchard\Orchard.Framework.csproj">
<Project>{2D1D92BB-4555-4CBE-8D0E-63563D6CE4C6}</Project>
<Name>Orchard.Framework</Name>
<Private>True</Private>
</ProjectReference>
</ItemGroup>
<ItemGroup>
@@ -120,11 +119,11 @@
<Service Include="{82A7F48D-3B50-4B1E-B82E-3ADA8210C358}" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -1,108 +1,88 @@
<?xml version="1.0" encoding="utf-8" ?>
<log4net>
<!-- If you are looking here and want more output, first thing to do is change root/priority/@value to "INFO" or "ALL". -->
<!-- If you are looking here and want more output, first thing to do is change root/priority/@value to "INFO" or "ALL". -->
<root>
<!-- Value of priority may be ALL, DEBUG, INFO, WARN, ERROR, FATAL, OFF. -->
<priority value="WARN" />
<appender-ref ref="error-file" />
<appender-ref ref="debug-file" />
</root>
<root>
<!-- Value of priority may be ALL, DEBUG, INFO, WARN, ERROR, FATAL, OFF. -->
<priority value="WARN" />
<appender-ref ref="error-file" />
<appender-ref ref="debug-file" />
</root>
<!-- Example of turning on the output from a component or namespace. -->
<!--
<logger name="Orchard.Data.SessionLocator">
<priority value="INFO" />
</logger>
-->
<!-- Example of turning on the output from a component or namespace. -->
<!--
<logger name="Orchard.Data.SessionLocator">
<priority value="INFO" />
</logger>
-->
<logger name="Orchard.Recipes">
<!-- Anything recipe-related goes into a dedicated file. -->
<priority value="INFO" />
<appender-ref ref="recipes-file" />
</logger>
<logger name="Orchard">
<!-- Messages coming from Orchard are sent to the attached debugger. -->
<appender-ref ref="debugger"/>
<!-- Note: if you put a ref=debugger into <root> element above and widen the priority to ALL or DEBUG, then you will see nhibernate trace in the attached debugger as well. -->
</logger>
<logger name="Orchard">
<!-- Messages coming from Orchard are sent to the attached debugger. -->
<appender-ref ref="debugger"/>
<!-- Note: if you put a ref=debugger into <root> element above and widen the priority to ALL or DEBUG, then you will see nhibernate trace in the attached debugger as well. -->
</logger>
<logger name="Orchard.Localization">
<!-- This source is very verbose - setting priority here to avoid flooding trace if root priority is lowered. -->
<priority value="WARN" />
</logger>
<logger name="Orchard.Localization">
<!-- This source is very verbose - setting priority here to avoid flooding trace if root priority is lowered. -->
<priority value="WARN" />
</logger>
<logger name="NHibernate.Cache">
<!-- This source is very verbose - setting priority here to avoid flooding trace if root priority is lowered. -->
<priority value="ERROR" />
</logger>
<logger name="NHibernate.Cache">
<!-- This source is very verbose - setting priority here to avoid flooding trace if root priority is lowered. -->
<priority value="ERROR" />
</logger>
<logger name="NHibernate.AdoNet.AbstractBatcher">
<!-- Displays failed table statements that are otherwise intercepted and rendered when unexpected. -->
<priority value="OFF" />
</logger>
<logger name="NHibernate.AdoNet.AbstractBatcher">
<!-- Displays failed table statements that are otherwise intercepted and rendered when unexpected. -->
<priority value="OFF" />
</logger>
<logger name="NHibernate.Util.ADOExceptionReporter">
<!-- Displays failed table statements that are otherwise intercepted and rendered when unexpected. -->
<priority value="OFF" />
</logger>
<logger name="NHibernate.Util.ADOExceptionReporter">
<!-- Displays failed table statements that are otherwise intercepted and rendered when unexpected. -->
<priority value="OFF" />
</logger>
<appender name="debugger" type="log4net.Appender.DebugAppender">
<!-- Sends log messages to Visual Studio if attached. -->
<immediateFlush value="true" />
<layout type="log4net.Layout.SimpleLayout" />
</appender>
<appender name="debugger" type="log4net.Appender.DebugAppender">
<!-- Sends log messages to Visual Studio if attached. -->
<immediateFlush value="true" />
<layout type="log4net.Layout.SimpleLayout" />
</appender>
<appender name="debug-file" type="Orchard.Logging.OrchardFileAppender">
<file value="App_Data/Logs/orchard-debug" />
<appendToFile value="true" />
<!-- Immediate flush on error log, to avoid data loss with sudden termination. -->
<immediateFlush value="true" />
<staticLogFileName value="false" />
<rollingStyle value="Date" />
<datepattern value="-yyyy.MM.dd'.log'" />
<!-- Prevents Orchard.exe from displaying locking debug messages. -->
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %logger - %P{Tenant} - %level% %message%newline" />
</layout>
</appender>
<appender name="error-file" type="Orchard.Logging.OrchardFileAppender">
<file value="App_Data/Logs/orchard-error" />
<appendToFile value="true" />
<!-- Immediate flush on error log, to avoid data loss with sudden termination. -->
<immediateFlush value="true" />
<staticLogFileName value="false" />
<rollingStyle value="Date" />
<datepattern value="-yyyy.MM.dd'.log'" />
<!-- Prevents Orchard.exe from displaying locking debug messages. -->
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<filter type="log4net.Filter.LevelRangeFilter">
<!-- Only ERROR and FATAL log messages end up in this target, even if child loggers accept lower priority. -->
<levelMin value="ERROR" />
</filter>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %logger - %P{Tenant} - %message [%P{Url}]%newline" />
</layout>
</appender>
<appender name="recipes-file" type="Orchard.Logging.OrchardFileAppender">
<!-- Sends ERROR and FATAL log messages to a file in App_Data. -->
<file value="App_Data/Logs/orchard-recipes" />
<appendToFile value="true" />
<!-- Immediate flush on error log, to avoid data loss with sudden termination. -->
<immediateFlush value="true" />
<staticLogFileName value="false" />
<rollingStyle value="Date" />
<datepattern value="-yyyy.MM.dd'.log'" />
<!-- Prevents Orchard.exe from displaying locking debug messages. -->
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %logger - %P{Tenant} - %level% %message%newline" />
</layout>
</appender>
<appender name="debug-file" type="Orchard.Logging.OrchardFileAppender">
<!-- Sends log messages to a file in App_Data. -->
<file value="App_Data/Logs/orchard-debug" />
<appendToFile value="true" />
<!-- Immediate flush on error log, to avoid data loss with sudden termination. -->
<immediateFlush value="true" />
<staticLogFileName value="false" />
<rollingStyle value="Date" />
<datepattern value="-yyyy.MM.dd'.log'" />
<!-- Prevents Orchard.exe from displaying locking debug messages. -->
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %logger - %P{Tenant} - %message%newline" />
</layout>
</appender>
<appender name="error-file" type="Orchard.Logging.OrchardFileAppender">
<!-- Sends ERROR and FATAL log messages to a file in App_Data. -->
<file value="App_Data/Logs/orchard-error" />
<appendToFile value="true" />
<!-- Immediate flush on error log, to avoid data loss with sudden termination. -->
<immediateFlush value="true" />
<staticLogFileName value="false" />
<rollingStyle value="Date" />
<datepattern value="-yyyy.MM.dd'.log'" />
<!-- Prevents Orchard.exe from displaying locking debug messages. -->
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<filter type="log4net.Filter.LevelRangeFilter">
<!-- Only ERROR and FATAL log messages end up in this target, even if child loggers accept lower priority. -->
<levelMin value="ERROR" />
</filter>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %logger - %P{Tenant} - %message%newline %P{Url}%newline" />
</layout>
</appender>
</log4net>

View File

@@ -1,8 +1,10 @@
using JetBrains.Annotations;
using Orchard.Core.Common.Models;
using Orchard.ContentManagement.Handlers;
using Orchard.Core.Common.Utilities;
namespace Orchard.Core.Common.DateEditor {
[UsedImplicitly]
public class DateEditorHandler : ContentHandler {
public DateEditorHandler() {
OnPublished<CommonPart>((context, part) => {

View File

@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Web;
using JetBrains.Annotations;
using Orchard.Mvc.Html;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Aspects;
@@ -13,6 +14,7 @@ using System.Web.Mvc;
using System.Web.Routing;
namespace Orchard.Core.Common.Drivers {
[UsedImplicitly]
public class BodyPartDriver : ContentPartDriver<BodyPart> {
private readonly IEnumerable<IHtmlFilter> _htmlFilters;
private readonly RequestContext _requestContext;

View File

@@ -1,8 +1,10 @@
using Orchard.ContentManagement.Drivers;
using JetBrains.Annotations;
using Orchard.ContentManagement.Drivers;
using Orchard.Core.Common.Models;
using Orchard.Localization;
namespace Orchard.Core.Common.Drivers {
[UsedImplicitly]
public class IdentityPartDriver : ContentPartDriver<IdentityPart> {
public IdentityPartDriver() {
T = NullLocalizer.Instance;

View File

@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Web;
using JetBrains.Annotations;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
using Orchard.ContentManagement.Handlers;
@@ -11,6 +12,7 @@ using Orchard.Localization;
using Orchard.Services;
namespace Orchard.Core.Common.Drivers {
[UsedImplicitly]
public class TextFieldDriver : ContentFieldDriver<TextField> {
private readonly IEnumerable<IHtmlFilter> _htmlFilters;

View File

@@ -1,8 +1,10 @@
using JetBrains.Annotations;
using Orchard.Core.Common.Models;
using Orchard.Data;
using Orchard.ContentManagement.Handlers;
namespace Orchard.Core.Common.Handlers {
[UsedImplicitly]
public class BodyPartHandler : ContentHandler {
public BodyPartHandler(IRepository<BodyPartRecord> bodyRepository) {
Filters.Add(StorageFilter.For(bodyRepository));

View File

@@ -1,5 +1,6 @@
using System;
using System.Linq;
using JetBrains.Annotations;
using Orchard.ContentManagement.MetaData;
using Orchard.Core.Common.Models;
using Orchard.Data;
@@ -10,6 +11,7 @@ using Orchard.Security;
using Orchard.Services;
namespace Orchard.Core.Common.Handlers {
[UsedImplicitly]
public class CommonPartHandler : ContentHandler {
private readonly IClock _clock;
private readonly IAuthenticationService _authenticationService;
@@ -75,7 +77,7 @@ namespace Orchard.Core.Common.Handlers {
protected bool ContentTypeWithACommonPart(string typeName) {
//Note: What about content type handlers which activate "CommonPart" in code?
var contentTypeDefinition = _contentDefinitionManager.GetTypeDefinition(typeName);
if (contentTypeDefinition != null)
return contentTypeDefinition.Parts.Any(part => part.PartDefinition.Name == "CommonPart");
@@ -97,7 +99,6 @@ namespace Orchard.Core.Common.Handlers {
part.ModifiedUtc = utcNow;
part.VersionCreatedUtc = utcNow;
part.VersionModifiedUtc = utcNow;
part.VersionModifiedBy = GetUserName();
}
private void AssignUpdateDates(UpdateEditorContext context, CommonPart part) {
@@ -105,7 +106,6 @@ namespace Orchard.Core.Common.Handlers {
part.ModifiedUtc = utcNow;
part.VersionModifiedUtc = utcNow;
part.VersionModifiedBy = GetUserName();
}
private void AssignRemovingDates(RemoveContentContext context, CommonPart part) {
@@ -113,17 +113,15 @@ namespace Orchard.Core.Common.Handlers {
part.ModifiedUtc = utcNow;
part.VersionModifiedUtc = utcNow;
part.VersionModifiedBy = GetUserName();
}
protected void AssignVersioningDates(VersionContentContext context, CommonPart existing, CommonPart building) {
var utcNow = _clock.UtcNow;
// assign the created date
// assign the created date
building.VersionCreatedUtc = utcNow;
// assign modified date for the new version
building.VersionModifiedUtc = utcNow;
building.VersionModifiedBy = GetUserName();
// publish date should be null until publish method called
building.VersionPublishedUtc = null;
@@ -138,7 +136,7 @@ namespace Orchard.Core.Common.Handlers {
protected void AssignPublishingDates(PublishContentContext context, CommonPart part) {
var utcNow = _clock.UtcNow;
part.PublishedUtc = utcNow;
part.VersionPublishedUtc = utcNow;
}
@@ -146,37 +144,33 @@ namespace Orchard.Core.Common.Handlers {
protected void LazyLoadHandlers(CommonPart part) {
// add handlers that will load content for id's just-in-time
part.OwnerField.Loader(() => _contentManager.Get<IUser>(part.Record.OwnerId));
part.ContainerField.Loader(() => part.Record.Container == null ? null : _contentManager.Get(part.Record.Container.Id));
part.ContainerField.Loader(() => part.Record.Container == null ? null : _contentManager.Get(part.Record.Container.Id));
}
protected static void PropertySetHandlers(ActivatedContentContext context, CommonPart part) {
// add handlers that will update records when part properties are set
part.OwnerField.Setter(user => {
part.Record.OwnerId = user == null
? 0
: user.ContentItem.Id;
return user;
});
part.Record.OwnerId = user == null
? 0
: user.ContentItem.Id;
return user;
});
// Force call to setter if we had already set a value
if (part.OwnerField.Value != null)
part.OwnerField.Value = part.OwnerField.Value;
part.ContainerField.Setter(container => {
part.Record.Container = container == null
? null
: container.ContentItem.Record;
return container;
});
part.Record.Container = container == null
? null
: container.ContentItem.Record;
return container;
});
// Force call to setter if we had already set a value
if (part.ContainerField.Value != null)
part.ContainerField.Value = part.ContainerField.Value;
}
private string GetUserName() {
var user = _authenticationService.GetAuthenticatedUser();
return user == null ? string.Empty : user.UserName;
}
}
}

View File

@@ -1,10 +1,12 @@
using System;
using JetBrains.Annotations;
using Orchard.ContentManagement;
using Orchard.Core.Common.Models;
using Orchard.Data;
using Orchard.ContentManagement.Handlers;
namespace Orchard.Core.Common.Handlers {
[UsedImplicitly]
public class IdentityPartHandler : ContentHandler {
public IdentityPartHandler(IRepository<IdentityPartRecord> identityRepository,
IContentManager contentManager) {

View File

@@ -15,14 +15,14 @@ namespace Orchard.Core.Common {
}
public int Create() {
SchemaBuilder.CreateTable("BodyPartRecord",
SchemaBuilder.CreateTable("BodyPartRecord",
table => table
.ContentPartVersionRecord()
.Column<string>("Text", column => column.Unlimited())
.Column<string>("Format")
);
SchemaBuilder.CreateTable("CommonPartRecord",
SchemaBuilder.CreateTable("CommonPartRecord",
table => table
.ContentPartRecord()
.Column<int>("OwnerId")
@@ -31,14 +31,13 @@ namespace Orchard.Core.Common {
.Column<DateTime>("ModifiedUtc")
.Column<int>("Container_id")
);
SchemaBuilder.CreateTable("CommonPartVersionRecord",
SchemaBuilder.CreateTable("CommonPartVersionRecord",
table => table
.ContentPartVersionRecord()
.Column<DateTime>("CreatedUtc")
.Column<DateTime>("PublishedUtc")
.Column<DateTime>("ModifiedUtc")
.Column<string>("ModifiedBy")
);
SchemaBuilder.CreateTable("IdentityPartRecord",
@@ -59,7 +58,7 @@ namespace Orchard.Core.Common {
.Attachable()
.WithDescription("Automatically generates a unique identity for the content item, which is required in import/export scenarios where one content item references another."));
return 5;
return 4;
}
public int UpdateFrom1() {
@@ -100,17 +99,13 @@ namespace Orchard.Core.Common {
foreach (var existingIdentityPart in existingIdentityParts) {
var updateIdentityPartRecord = _identityPartRepository.Get(existingIdentityPart.Id);
updateIdentityPartRecord.Identifier = existingIdentityPart.Identifier;
_identityPartRepository.Update(updateIdentityPartRecord);
}
return 4;
}
public int UpdateFrom4() {
SchemaBuilder.AlterTable("CommonPartVersionRecord", table => table.AddColumn<string>("ModifiedBy", command => command.Nullable()));
return 5;
}
}
}

View File

@@ -1,7 +1,7 @@
using System;
using Orchard.Core.Common.Utilities;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Aspects;
using Orchard.ContentManagement.Utilities;
using Orchard.Security;
namespace Orchard.Core.Common.Models {
@@ -54,15 +54,6 @@ namespace Orchard.Core.Common.Models {
PartVersionRecord.CreatedUtc = value;
}
}
public string VersionModifiedBy {
get {
return PartVersionRecord == null ? null : PartVersionRecord.ModifiedBy;
}
set {
if (PartVersionRecord != null)
PartVersionRecord.ModifiedBy = value;
}
}
public DateTime? VersionPublishedUtc {
get {

View File

@@ -6,6 +6,5 @@ namespace Orchard.Core.Common.Models {
public virtual DateTime? CreatedUtc { get; set; }
public virtual DateTime? PublishedUtc { get; set; }
public virtual DateTime? ModifiedUtc { get; set; }
public virtual string ModifiedBy { get; set; }
}
}

View File

@@ -1,15 +1,14 @@
using System;
namespace Orchard.Core.Common.Utilities {
[Obsolete("Use Orchard.ContentManagement.Utilities.LazyField instead.")]
public class LazyField<T> {
private T _value;
private Func<T> _loader;
private Func<T, T> _setter;
public T Value {
get { return GetValue(); }
set { SetValue(value); }
get {return GetValue();}
set {SetValue(value);}
}
public void Loader(Func<T> loader) {
@@ -23,7 +22,7 @@ namespace Orchard.Core.Common.Utilities {
private T GetValue() {
if (_loader != null) {
_value = _loader();
_loader = null;
_loader = null;
}
return _value;
}

View File

@@ -1,18 +0,0 @@
@*
Model:
ContentPart
*@
@{
string displayUser = null;
if (Model.ContentPart != null) {
if (!string.IsNullOrWhiteSpace(Model.ContentPart.VersionModifiedBy)) {
displayUser = Model.ContentPart.VersionModifiedBy;
}
else if (Model.ContentPart.Owner != null) {
displayUser = Model.ContentPart.Owner.UserName;
}
}
}
@T("By {0}", displayUser ?? T("unknown").ToString())

View File

@@ -0,0 +1,14 @@
@*
Model:
ContentPart
*@
@using Orchard.ContentManagement;
@using Orchard.Core.Common.Models;
@using Orchard.Security;
@{
CommonPart commonPart = Model.ContentPart;
// owner isn't really who last modified this, is it?
IUser owner = commonPart.As<CommonPart>() == null ? null : commonPart.As<CommonPart>().Owner;
}
@T("By {0}", owner == null ? T("unknown").ToString() : Convert.ToString(Html.ItemDisplayText(owner)))

View File

@@ -1,10 +1,12 @@
@{
DateTime? modifiedUtc = Model.ContentPart == null ? null : Model.ContentPart.ModifiedUtc;
@using Orchard.ContentManagement;
@using Orchard.Core.Common.Models;
@{
CommonPart commonPart = Model.ContentPart;
DateTime? modifiedUtc = commonPart.As<CommonPart>() == null ? null : commonPart.As<CommonPart>().ModifiedUtc;
}
<ul class="pageStatus">
<li>
@if (modifiedUtc.HasValue) {
@T("Last modified: {0}", Display.DateTimeRelative(DateTimeUtc: modifiedUtc.Value))}&nbsp;&#124;&nbsp;
</li>
<li>@Display.CommonMetadataLastModified(ContentPart: Model.ContentPart)</li>
</ul>
<li>@if (modifiedUtc.HasValue) {
@T("Last modified: {0}", Display.DateTimeRelative(DateTimeUtc: modifiedUtc.Value))}&nbsp;&#124;&nbsp;
</li>
<li>@Display.CommonMetadataOwner(ContentPart: Model.ContentPart)</li>
</ul>

View File

@@ -2,7 +2,7 @@
using Orchard.ContentManagement;
using Orchard.ContentManagement.MetaData.Models;
using Orchard.ContentManagement.Records;
using Orchard.ContentManagement.Utilities;
using Orchard.Core.Common.Utilities;
using Orchard.Core.Containers.Services;
using Orchard.Core.Containers.Settings;
using Orchard.UI.Navigation;

View File

@@ -0,0 +1,6 @@
namespace Orchard.Core.Containers.Models {
public enum OrderByDirection {
Ascending,
Descending
}
}

View File

@@ -26,6 +26,8 @@ namespace Orchard.Core.Containers.ViewModels {
public enum SortDirection {
Ascending,
Descending
Descending,
Created,
DisplayText
}
}

View File

@@ -1,4 +1,5 @@
@model Orchard.Core.Containers.ViewModels.ContainerWidgetViewModel
@using Orchard.Core.Containers.Models;
@{
Script.Require("ShapesBase");
}
@@ -24,8 +25,8 @@
@Html.SelectOption(Model.Part.Record.OrderByProperty, "CustomPropertiesPart.CustomThree", T("Custom 3").Text)
</select>
<select title="@T("Order direction")" id="@Html.FieldIdFor(m => m.Part.Record.OrderByDirection)" name="@Html.FieldNameFor(m => m.Part.Record.OrderByDirection)">
@Html.SelectOption(Model.Part.Record.OrderByDirection, (int)SortDirection.Ascending, T("Ascending").Text)
@Html.SelectOption(Model.Part.Record.OrderByDirection, (int)SortDirection.Descending, T("Descending").Text)
@Html.SelectOption(Model.Part.Record.OrderByDirection, (int)OrderByDirection.Ascending, T("Ascending").Text)
@Html.SelectOption(Model.Part.Record.OrderByDirection, (int)OrderByDirection.Descending, T("Descending").Text)
</select>
</fieldset>
<fieldset>

View File

@@ -9,14 +9,9 @@ namespace Orchard.Core.Contents.Controllers {
[Themed]
public class ItemController : Controller {
private readonly IContentManager _contentManager;
private readonly IHttpContextAccessor _hca;
public ItemController(IContentManager contentManager,
IShapeFactory shapeFactory,
IOrchardServices services,
IHttpContextAccessor hca) {
public ItemController(IContentManager contentManager, IShapeFactory shapeFactory, IOrchardServices services) {
_contentManager = contentManager;
_hca = hca;
Shape = shapeFactory;
Services = services;
T = NullLocalizer.Instance;
@@ -42,12 +37,8 @@ namespace Orchard.Core.Contents.Controllers {
if (!Services.Authorizer.Authorize(Permissions.ViewContent, contentItem, T("Cannot view content"))) {
return new HttpUnauthorizedResult();
}
var model = _contentManager.BuildDisplay(contentItem);
if (_hca.Current().Request.IsAjaxRequest()) {
return new ShapePartialResult(this,model);
}
var model = _contentManager.BuildDisplay(contentItem);
return View(model);
}
@@ -71,10 +62,6 @@ namespace Orchard.Core.Contents.Controllers {
}
var model = _contentManager.BuildDisplay(contentItem);
if (_hca.Current().Request.IsAjaxRequest()) {
return new ShapePartialResult(this, model);
}
return View(model);
}
}

View File

@@ -1,3 +1,4 @@
using JetBrains.Annotations;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Aspects;
using Orchard.Core.Contents.Settings;
@@ -5,6 +6,7 @@ using Orchard.Security;
using Orchard.Security.Permissions;
namespace Orchard.Core.Contents.Security {
[UsedImplicitly]
public class AuthorizationEventHandler : IAuthorizationServiceEventHandler {
public void Checking(CheckAccessContext context) { }
public void Complete(CheckAccessContext context) { }

View File

@@ -16,10 +16,8 @@
<div class="manage">
@Html.ActionLink(createLinkText.Text, "Create", new { Area = "Contents", Id = (string)Model.Options.SelectedFilter }, new { @class = "button primaryAction" })
</div>
@using (Html.BeginFormAntiForgeryPost()) {
<fieldset class="bulk-actions">
<label><input type="checkbox" class="check-all" />@T("Select all")</label>@T(" | ")
<label for="publishActions">@T("Actions:")</label>
<select id="publishActions" name="Options.BulkAction">
@Html.SelectOption((ContentsBulkAction)Model.Options.BulkAction, ContentsBulkAction.None, T("Choose action...").ToString())

View File

@@ -26,7 +26,7 @@
</div>
<div class="help-item">
<h2 class="contribute">@T("Contribute back")</h2>
<p>@T("Help grow Orchard. We encourage contributions of all sorts, including code submissions, documentation, translations, feature recommendations, and more. Here are some ways to <a href=\"http://orchardproject.net/contribution\">give back to the project</a>.")</p>
<p>@T("Help grow Orchard. We encourage contributions of all sorts, including code submissions, documentation, translations, feature recommendations, and more.Here are some ways to <a href=\"http://orchardproject.net/contribution\">give back to the project</a>.")</p>
</div>
<div class="help-item">

View File

@@ -1,9 +1,11 @@
using System;
using System.Web.Mvc;
using System.Xml.Linq;
using JetBrains.Annotations;
using Orchard.Core.Feeds.Models;
namespace Orchard.Core.Feeds.Rss {
[UsedImplicitly]
public class RssFeedBuilder : IFeedBuilderProvider, IFeedBuilder {
public FeedBuilderMatch Match(FeedContext context) {
if (context.Format == "rss") {

View File

@@ -1,8 +1,10 @@
using System.Web.Mvc;
using JetBrains.Annotations;
using Orchard.DisplayManagement;
using Orchard.Mvc.Filters;
namespace Orchard.Core.Feeds.Services {
[UsedImplicitly]
public class FeedFilter : FilterProvider, IResultFilter {
private readonly IFeedManager _feedManager;
private readonly IWorkContextAccessor _workContextAccessor;

View File

@@ -3,8 +3,10 @@ using System.Collections.Generic;
using System.Text;
using System.Web.Mvc;
using System.Web.Routing;
using JetBrains.Annotations;
namespace Orchard.Core.Feeds.Services {
[UsedImplicitly]
public class FeedManager : IFeedManager {
private readonly IList<Link> _links = new List<Link>();

View File

@@ -4,12 +4,14 @@ using System.Linq;
using System.Web.Mvc;
using System.Web.Routing;
using System.Xml.Linq;
using JetBrains.Annotations;
using Orchard.ContentManagement;
using Orchard.Core.Feeds.Models;
using Orchard.Mvc.Extensions;
using Orchard.Services;
namespace Orchard.Core.Feeds.StandardBuilders {
[UsedImplicitly]
public class CorePartsFeedItemBuilder : IFeedItemBuilder {
private readonly IContentManager _contentManager;
private readonly RouteCollection _routes;

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Web.Mvc;
using System.Xml.Linq;
using JetBrains.Annotations;
using Orchard.ContentManagement;
using Orchard.Core.Common.Models;
using Orchard.Core.Feeds.Models;
@@ -11,6 +12,7 @@ using Orchard.Services;
using Orchard.Utility.Extensions;
namespace Orchard.Core.Feeds.StandardQueries {
[UsedImplicitly]
public class ContainerFeedQuery : IFeedQueryProvider, IFeedQuery {
private readonly IContentManager _contentManager;
private readonly IEnumerable<IHtmlFilter> _htmlFilters;

View File

@@ -90,7 +90,7 @@ namespace Orchard.Core.Navigation.Controllers {
if (!Services.Authorizer.Authorize(Permissions.ManageMenus, T("Couldn't manage the main menu")))
return new HttpUnauthorizedResult();
// See https://github.com/OrchardCMS/Orchard/issues/948
// See http://orchard.codeplex.com/workitem/17116
if (menuItemEntries != null) {
foreach (var menuItemEntry in menuItemEntries) {
MenuPart menuPart = _menuService.Get(menuItemEntry.MenuItemId);

View File

@@ -1,4 +1,5 @@
using System;
using JetBrains.Annotations;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
using Orchard.Core.Navigation.Models;
@@ -9,6 +10,7 @@ using Orchard.UI.Navigation;
using Orchard.Utility;
namespace Orchard.Core.Navigation.Drivers {
[UsedImplicitly]
public class AdminMenuPartDriver : ContentPartDriver<AdminMenuPart> {
private readonly IAuthorizationService _authorizationService;
private readonly INavigationManager _navigationManager;

View File

@@ -1,9 +1,11 @@
using Orchard.ContentManagement;
using JetBrains.Annotations;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
using Orchard.Core.Navigation.Models;
using Orchard.Security;
namespace Orchard.Core.Navigation.Drivers {
[UsedImplicitly]
public class MenuItemPartDriver : ContentPartDriver<MenuItemPart> {
private readonly IAuthorizationService _authorizationService;
private readonly IWorkContextAccessor _workContextAccessor;

View File

@@ -1,4 +1,5 @@
using System.Linq;
using JetBrains.Annotations;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
using Orchard.Core.Navigation.Models;
@@ -10,6 +11,7 @@ using Orchard.UI.Navigation;
using Orchard.Utility;
namespace Orchard.Core.Navigation.Drivers {
[UsedImplicitly]
public class MenuPartDriver : ContentPartDriver<MenuPart> {
private readonly IAuthorizationService _authorizationService;
private readonly INavigationManager _navigationManager;

View File

@@ -1,9 +1,11 @@
using System;
using JetBrains.Annotations;
using Orchard.ContentManagement.Handlers;
using Orchard.Core.Navigation.Models;
using Orchard.Data;
namespace Orchard.Core.Navigation.Handlers {
[UsedImplicitly]
public class AdminMenuPartHandler : ContentHandler {
public AdminMenuPartHandler(IRepository<AdminMenuPartRecord> menuPartRepository) {
Filters.Add(StorageFilter.For(menuPartRepository));

Some files were not shown because too many files have changed in this diff Show More