Compare commits

...

164 Commits

Author SHA1 Message Date
andrerod@andrerod-dev1.redmond.corp.microsoft.com
0c4a7342a9 #17955: Using TryFileExists instead of FileExists to avoid exception.
--HG--
branch : dev
2011-09-02 11:55:54 -07:00
andrerod@andrerod-dev1.redmond.corp.microsoft.com
55fa90bb92 #17973: Avoiding all content items to be returned in case there is no content type with a containablePart.
--HG--
branch : dev
2011-08-30 14:42:37 -07:00
andrerod@andrerod-dev1.redmond.corp.microsoft.com
fa6329e286 #18014: Using correct name property.
--HG--
branch : dev
2011-08-29 11:03:21 -07:00
andrerod@andrerod-dev1.redmond.corp.microsoft.com
a8ddde992d #18017: Fail to access gallery themes [5409 (4743bb7dc463)]
--HG--
branch : dev
2011-08-26 12:58:28 -07:00
andrerod@andrerod-dev1.redmond.corp.microsoft.com
b20ea47f63 #18044: Can not match "recipes == null" in "if” condition of HarvestRecipes and ExecuteRecipe functions.
--HG--
branch : dev
2011-08-26 11:43:45 -07:00
Dave Reed
5a265af902 Remove BodyPart's dependency on RoutePart. MediaPicker uses directory name the same as the content type, not content path.
--HG--
branch : dev
2011-08-08 14:28:57 -07:00
Dave Reed
1bf98a49dc Fix MediaPicker preview
--HG--
branch : dev
2011-08-08 14:27:02 -07:00
Dave Reed
086f4568a9 Fixing project file
--HG--
branch : dev
2011-08-05 18:20:30 -07:00
Dave Reed
aa9038a6f6 Removing Containers reliance on a route constraint provider. Instead it sets the items DisplayRouteValues. The new Route part will be responsible for setting an alias (orchardalias.codeplex.com) to those route values.
Note that this breaks containers routability for the moment -- to fix, remove the Route part and add the Route Part from orchardroutable.codeplex.com instead.

--HG--
branch : dev
2011-08-05 18:20:10 -07:00
Dave Reed
4a25281909 Remove Orchard.Experimental dependnecy on core RoutePart
--HG--
branch : dev
2011-08-05 18:09:31 -07:00
Dave Reed
ec0167149a Removing dependency of ContainerWidgetPartDriver on IRoutePart interface.
--HG--
branch : dev
2011-08-05 17:28:46 -07:00
Dave Reed
9f84774cf0 Removing Indexing dependency on IRoutePart
--HG--
branch : dev
2011-08-05 17:19:51 -07:00
Dave Reed
4dc608cd99 Fixed a bug where the Checkbox editor template was not posting correctly.
--HG--
branch : dev
2011-08-05 14:06:07 -07:00
Dave Reed
1cd80a6eaa Removing tokens
--HG--
branch : dev
2011-07-22 10:28:27 -07:00
Dave Reed
505e068362 Fixed simple tokens like {foo}
--HG--
branch : dev
2011-07-20 16:39:06 -07:00
Dave Reed
7caf8941a7 Implemented Token Provider and related interfaces.
--HG--
branch : dev
2011-07-19 16:20:10 -07:00
nheskew@SKEWED.redmond.corp.microsoft.com
c14f05066b Fixing a bunch of zone class names in TheThemeMachine site.css
--HG--
branch : dev
2011-07-12 15:24:29 -07:00
nheskew@SKEWED.redmond.corp.microsoft.com
79aa72c291 Fixing what camparer is used in the widget admin placement UI
--HG--
branch : dev
2011-07-12 14:44:55 -07:00
nheskew@SKEWED.redmond.corp.microsoft.com
531eafd0d7 Merge
--HG--
branch : dev
2011-07-11 11:58:07 -07:00
nheskew@SKEWED.redmond.corp.microsoft.com
87f6cec32a Some pager updates based on feedback.
- first, previous, next and last params to objects so they can be anything
- pass the Pager shape to its child shape Display()'s

--HG--
branch : dev
2011-07-11 11:26:26 -07:00
nheskew@SKEWED.redmond.corp.microsoft.com
a80ee4bac7 Improved page display templates from Admin and TheThemeMachine on down.
An improvement, definately, but not yet completely awesome.

--HG--
branch : dev
2011-07-08 15:00:58 -07:00
Dave Reed
4cee2e00e9 Make using Object template explicit and render others as display templates.
--HG--
branch : dev
2011-07-08 10:49:13 -07:00
Dave Reed
c08edd5a5f Merge
--HG--
branch : dev
2011-07-08 10:12:02 -07:00
Dave Reed
262f140c8c Merging InputShapes->dev
--HG--
branch : dev
2011-07-08 10:10:49 -07:00
nheskew@SKEWED.redmond.corp.microsoft.com
f07e42e6dc Some pager shape progress
--HG--
branch : dev
2011-07-07 16:11:08 -07:00
Suha Can
2fd7d2b069 Renaming ContentManagement.Metadata to ContentManagement.Definition
--HG--
branch : dev
2011-07-07 12:31:03 -07:00
Dave Reed
81b4fbb262 Rename EditorString to Textbox and EditorBoolean to Checkbox
--HG--
branch : InputShapes
2011-07-06 15:37:31 -07:00
Dave Reed
cb7f29c048 Fix merge issue
--HG--
branch : InputShapes
2011-07-06 15:28:06 -07:00
Dave Reed
63a9bf4fe9 Merge
--HG--
branch : InputShapes
2011-07-06 15:23:16 -07:00
Dave Reed
db3b9658e6 Merge
--HG--
branch : dev
2011-07-06 15:08:34 -07:00
Suha Can
c5d63e97b4 Remove obsolete diagram file.
--HG--
branch : dev
2011-07-06 13:37:20 -07:00
Suha Can
53f6c7b76c Refactor ContentManager.BuildDisplay/BuildEditor/UpdateEditor to move away from
optional parameters.

--HG--
branch : dev
2011-07-06 13:17:36 -07:00
Dave Reed
5474cd2a64 Added Object EditorTemplate that renders a Fieldset shape and converted User Registration Settings view to take advantage.
Fixed calculated display name overwriting provided title.
Fieldset can take non-shape items, and optionally provide a position via tuple.

--HG--
branch : InputShapes
2011-07-06 12:23:29 -07:00
Dave Reed
ea150b759a Added InputLabel, InputHint and InputRequiredMarker.
--HG--
branch : InputShapes
2011-07-01 15:32:09 -07:00
Louis DeJardin
29b7de4587 More notes
--HG--
branch : InputShapes
2011-07-01 11:04:44 -07:00
Andre Rodrigues
45d00e8a1c Commenting IAppDataFolder. Thining out API by removing redundant methods. After review comments.
--HG--
branch : dev
2011-06-30 13:45:17 -07:00
Sebastien Ros
05ef56f774 Refactoring position management as per reviews
--HG--
branch : dev
2011-06-29 11:09:04 -07:00
Louis DeJardin
8d5504bbc0 Merge
--HG--
branch : InputShapes
2011-06-28 17:47:36 -07:00
Sebastien Ros
50e417387b Centralizing code related to dotted position - Take 2
--HG--
branch : dev
2011-06-28 14:16:55 -07:00
Dave Reed
8278b9c63a Fixed missing HtmlString instances in <a> to Link() conversion.
--HG--
branch : dev
2011-06-27 17:35:23 -07:00
Dave Reed
c079414806 Refactoring, added Boolean editor template, and converted Users settings to take advantage.
--HG--
branch : InputShapes
2011-06-27 15:49:32 -07:00
Dave Reed
7f263df119 Convert appropriate uses of <a> to Display.Link
--HG--
branch : dev
2011-06-27 14:05:58 -07:00
Louis DeJardin
1328fbf9bc Updating ClaySharp.dll
All methods in IClayBehavior interface now have object self parameter
Removes _hack/_shape field from Orchard's ShapeBehavior

--HG--
branch : dev
2011-06-24 15:10:28 -07:00
Louis DeJardin
798f6523b0 Adjustments to support null/empty timezone in site settings
Site setting given priority of -5 (to be below default, 0, if other activated)
Fallback selector with priority -100 provides machine's Local tzi
WorkContext property produces null if no selectors provide any tzi

--HG--
branch : dev
2011-06-24 15:03:44 -07:00
Louis DeJardin
1845cb946d Extra class just was for fun?
--HG--
branch : dev
2011-06-24 14:43:44 -07:00
Louis DeJardin
b3441be450 Shape method binder adjustments
Adding overload for Output parameter
Improving null detection slightly
Adjusting Items initialization slightly

--HG--
branch : dev
extra : transplant_source : %A3%A9U%3F%DD%89%F6%B2%9E%F5%F9%8A1ff%FE%DF%9B%CD%B9
2011-06-24 14:20:53 -07:00
Dave Reed
1604177109 Removed unneeded injections
--HG--
branch : InputShapes
2011-06-22 17:58:07 -07:00
Dave Reed
484bbd9979 Merge
--HG--
branch : dev
2011-06-22 17:51:36 -07:00
Dave Reed
f52697526b Merge
--HG--
branch : InputShapes
2011-06-22 17:49:12 -07:00
Dave Reed
78e8072918 Initial work on Input Shapes (experimental)
--HG--
branch : InputShapes
2011-06-22 17:45:30 -07:00
Suha Can
0cf400f56f Part II of MetaData renaming.
--HG--
branch : dev
2011-06-22 16:25:05 -07:00
Suha Can
09c624ff73 Orchard.ContentManagement.MetaData -> Orchard.ContentManagement.Metadata.
--HG--
branch : dev
2011-06-22 16:08:53 -07:00
Suha Can
a2d62bbc9c Removing IContentManager::GetContentTypeDefinitions in favor of ContentDefinitionManager::ListTypeDefinitions.
--HG--
branch : dev
2011-06-21 14:50:45 -07:00
Andre Rodrigues
c2ea509702 Merge
--HG--
branch : dev
2011-06-21 12:52:59 -07:00
Suha Can
d4b12292ee Refactoring LazyField and ComputedField into one under Orchard.Utility.
Removing the LazyField implementation in Orchard.Core.Common.

--HG--
branch : dev
2011-06-21 12:37:53 -07:00
Suha Can
c5878f67b3 Commenting IContentHandler with lifecycle related information.
--HG--
branch : dev
2011-06-20 15:22:15 -07:00
Suha Can
b11cf31c1f Notifier extension methods moved to the INotifier interface.
--HG--
branch : dev
2011-06-20 14:46:02 -07:00
Suha Can
4273f82ac9 Refactoring Orchard.ContentManagement.Aspects namespace. Aspect was an old nomenclature that's no longer used.
IRoutableAspect -> IRoutePart
IPublishingControlAspect -> IPublishLaterPart
Related refactoring.

--HG--
branch : dev
2011-06-20 14:16:28 -07:00
Andre Rodrigues
68b5048e9e Moving IVirtualPathProvider (and related classes) and IBuildManager to a new namespace. Adding comments.
--HG--
branch : dev
rename : src/Orchard/FileSystems/VirtualPath/DefaultVirtualPathMonitor.cs => src/Orchard/AspNet/Abstractions/DefaultVirtualPathMonitor.cs
rename : src/Orchard/FileSystems/VirtualPath/DefaultVirtualPathProvider.cs => src/Orchard/AspNet/Abstractions/DefaultVirtualPathProvider.cs
rename : src/Orchard/Environment/IBuildManager.cs => src/Orchard/AspNet/Abstractions/IBuildManager.cs
rename : src/Orchard/FileSystems/VirtualPath/ICustomVirtualPathProvider.cs => src/Orchard/AspNet/Abstractions/ICustomVirtualPathProvider.cs
rename : src/Orchard/FileSystems/VirtualPath/IVirtualPathMonitor.cs => src/Orchard/AspNet/Abstractions/IVirtualPathMonitor.cs
rename : src/Orchard/FileSystems/VirtualPath/IVirtualPathProvider.cs => src/Orchard/AspNet/Abstractions/IVirtualPathProvider.cs
2011-06-17 14:46:35 -07:00
Dave Reed
0e7318cdfa Converted Html.ActionLink => Display.ActionLink.
Added Fragment support to Link shape.

--HG--
branch : dev
2011-06-16 17:57:17 -07:00
Dave Reed
db6fea2e10 Merge
--HG--
branch : dev
2011-06-16 15:45:05 -07:00
Dave Reed
ace621c978 Added UrlType to UnsafeActionLink
--HG--
branch : dev
2011-06-16 15:43:29 -07:00
Dave Reed
80a3eb7193 Added shape 'UnsafeActionLink' and converted inline UnsafeUrl itemprop links to use it (now we can change how this works via the shape in a single location).
--HG--
branch : dev
2011-06-16 15:25:22 -07:00
Dave Reed
7c53fc709b Added ActionLink shape with Action/Controller/Area params and removed Action/Controller/Area params from Link shape.
Plus one sample conversion of Html.ActionLink to Display.ActionLink.

--HG--
branch : dev
2011-06-15 17:14:42 -07:00
Dave Reed
a0a050bced Link shape accepts Action, Controller, Area like ActionLink does for easier ActionLinking w/o having to supply a RouteValueDictionary.
Link uses Action() instead of RouteUrl() so the current route context is accounted for.
Link shape has some code review changes.

--HG--
branch : dev
2011-06-15 13:32:44 -07:00
Nathan Heskew
7b2d3ec960 Refactoring Orchard.Utility.Extensions.StringExtensions
- regex no more
- pulled a few methods which had a specific use out to more appropriate locations

--HG--
branch : dev
2011-06-15 10:57:42 -07:00
Dave Reed
481bfe476f Removing dead code HtmlHelper.AntiForgeryTokenValueOrchardLink
--HG--
branch : dev
2011-06-14 15:09:23 -07:00
Dave Reed
5d05c1998a Missing ')'
--HG--
branch : dev
2011-06-14 14:58:09 -07:00
Dave Reed
902fbb9a62 Merge
--HG--
branch : dev
2011-06-14 14:56:38 -07:00
Dave Reed
3f4dc7e45f Converted all uses of Html.Link() to Link shape.
Link shape encodes the value if it's not already (IHtmlString).
Removed Link HtmlHelper.
NOTE: There's still a ton of uses of Html.ActionLink and raw <a> tags :(

--HG--
branch : dev
2011-06-14 14:55:24 -07:00
Andre Rodrigues
c1db77ee51 Merge
--HG--
branch : dev
rename : src/Orchard.Tests/FileSystems/Dependencies/DependenciesFolderTests.cs => src/Orchard.Tests/Environment/Compilation/Dependencies/DependencyDescriptorManagerTests.cs
rename : src/Orchard.Tests/Environment/Loaders/DynamicExtensionLoaderTests.cs => src/Orchard.Tests/Environment/Compilation/Loaders/DynamicExtensionLoaderTests.cs
2011-06-14 12:24:09 -07:00
Andre Rodrigues
b7ed4c6144 Adding comments to the dependecydescriptormanager class / interface.
--HG--
branch : dev
2011-06-14 12:19:20 -07:00
Dave Reed
61f34904c1 Replacing all uses of Html.UnorderedList with List shape.
Deleted Html.UnorderedList.
Added AlternatingItemClasses support to List shape.
Nicer inline support:
Added ability for Classes and ItemClasses params to be a space delimited string.
Added ability to specify RouteValues to Link shape as anon object.

--HG--
branch : dev
2011-06-14 12:00:13 -07:00
Dave Reed
faa35c26b7 Fix typo in Comments view
--HG--
branch : dev
2011-06-14 11:57:47 -07:00
Andre Rodrigues
a8dd6cd46a Renaming IDependenciesFolder to IDependencyDescriptorManager
--HG--
branch : dev
rename : src/Orchard.Tests/Environment/Compilation/Dependencies/DependenciesFolderTests.cs => src/Orchard.Tests/Environment/Compilation/Dependencies/DependencyDescriptorManagerTests.cs
rename : src/Orchard/Environment/Compilation/Dependencies/DefaultDependenciesFolder.cs => src/Orchard/Environment/Compilation/Dependencies/DefaultDependencyDescriptorManager.cs
rename : src/Orchard/Environment/Compilation/Dependencies/IDependenciesFolder.cs => src/Orchard/Environment/Compilation/Dependencies/IDependencyDescriptorManager.cs
2011-06-14 11:45:50 -07:00
Sebastien Ros
910f8e03bb Replacing ITimeZoneProvider by a CurrentTimeZone property in WorkContext
--HG--
branch : dev
2011-06-14 11:38:24 -07:00
Andre Rodrigues
02f62b4a06 Moving UT to matching namespace.
--HG--
branch : dev
rename : src/Orchard.Tests/FileSystems/Dependencies/AssemblyProbingFolderTests.cs => src/Orchard.Tests/Environment/Compilation/Dependencies/AssemblyProbingFolderTests.cs
rename : src/Orchard.Tests/FileSystems/Dependencies/DependenciesFolderTests.cs => src/Orchard.Tests/Environment/Compilation/Dependencies/DependenciesFolderTests.cs
rename : src/Orchard.Tests/Environment/Loaders/DynamicExtensionLoaderTests.cs => src/Orchard.Tests/Environment/Compilation/Loaders/DynamicExtensionLoaderTests.cs
2011-06-14 11:33:57 -07:00
Andre Rodrigues
7aaf4aad74 Moving all compilation / assembly loading related classes into a common namespace (environment | compilation).
--HG--
branch : dev
rename : src/Orchard/Environment/Extensions/Compilers/CSharpExtensionBuildProviderShim.cs => src/Orchard/Environment/Compilation/Compilers/CSharpExtensionBuildProviderShim.cs
rename : src/Orchard/Environment/Extensions/Compilers/CompileExtensionContext.cs => src/Orchard/Environment/Compilation/Compilers/CompileExtensionContext.cs
rename : src/Orchard/Environment/Extensions/Compilers/DefaultExtensionCompiler.cs => src/Orchard/Environment/Compilation/Compilers/DefaultExtensionCompiler.cs
rename : src/Orchard/Environment/Extensions/Compilers/DefaultProjectFileParser.cs => src/Orchard/Environment/Compilation/Compilers/DefaultProjectFileParser.cs
rename : src/Orchard/Environment/Extensions/Compilers/IExtensionCompiler.cs => src/Orchard/Environment/Compilation/Compilers/IExtensionCompiler.cs
rename : src/Orchard/Environment/Extensions/Compilers/IProjectFileParser.cs => src/Orchard/Environment/Compilation/Compilers/IProjectFileParser.cs
rename : src/Orchard/Environment/Extensions/Compilers/ProjectFileDescriptor.cs => src/Orchard/Environment/Compilation/Compilers/ProjectFileDescriptor.cs
rename : src/Orchard/FileSystems/Dependencies/DefaultAssemblyProbingFolder.cs => src/Orchard/Environment/Compilation/Dependencies/DefaultAssemblyProbingFolder.cs
rename : src/Orchard/FileSystems/Dependencies/DefaultDependenciesFolder.cs => src/Orchard/Environment/Compilation/Dependencies/DefaultDependenciesFolder.cs
rename : src/Orchard/FileSystems/Dependencies/DefaultExtensionDependenciesManager.cs => src/Orchard/Environment/Compilation/Dependencies/DefaultExtensionDependenciesManager.cs
rename : src/Orchard/FileSystems/Dependencies/DynamicModuleVirtualPathProvider.cs => src/Orchard/Environment/Compilation/Dependencies/DynamicModuleVirtualPathProvider.cs
rename : src/Orchard/FileSystems/Dependencies/IAssemblyProbingFolder.cs => src/Orchard/Environment/Compilation/Dependencies/IAssemblyProbingFolder.cs
rename : src/Orchard/FileSystems/Dependencies/IDependenciesFolder.cs => src/Orchard/Environment/Compilation/Dependencies/IDependenciesFolder.cs
rename : src/Orchard/FileSystems/Dependencies/IExtensionDependenciesManager.cs => src/Orchard/Environment/Compilation/Dependencies/IExtensionDependenciesManager.cs
rename : src/Orchard/FileSystems/Dependencies/WebFormsExtensionsVirtualFile.cs => src/Orchard/Environment/Compilation/Dependencies/WebFormsExtensionsVirtualFile.cs
rename : src/Orchard/FileSystems/Dependencies/WebFormsExtensionsVirtualPathProvider.cs => src/Orchard/Environment/Compilation/Dependencies/WebFormsExtensionsVirtualPathProvider.cs
rename : src/Orchard/Environment/Extensions/Loaders/CoreExtensionLoader.cs => src/Orchard/Environment/Compilation/Loaders/CoreExtensionLoader.cs
rename : src/Orchard/Environment/Extensions/Loaders/DynamicExtensionLoader.cs => src/Orchard/Environment/Compilation/Loaders/DynamicExtensionLoader.cs
rename : src/Orchard/Environment/Extensions/Loaders/ExtensionLoaderBase.cs => src/Orchard/Environment/Compilation/Loaders/ExtensionLoaderBase.cs
rename : src/Orchard/Environment/Extensions/Loaders/IExtensionLoader.cs => src/Orchard/Environment/Compilation/Loaders/IExtensionLoader.cs
rename : src/Orchard/Environment/Extensions/Loaders/PrecompiledExtensionLoader.cs => src/Orchard/Environment/Compilation/Loaders/PrecompiledExtensionLoader.cs
rename : src/Orchard/Environment/Extensions/Loaders/RawThemeExtensionLoader.cs => src/Orchard/Environment/Compilation/Loaders/RawThemeExtensionLoader.cs
rename : src/Orchard/Environment/Extensions/Loaders/ReferencedExtensionLoader.cs => src/Orchard/Environment/Compilation/Loaders/ReferencedExtensionLoader.cs
2011-06-14 11:23:45 -07:00
Sebastien Ros
d4ffd2cb20 Fixing WorkContext issue
--HG--
branch : dev
2011-06-13 20:44:24 -07:00
Dave Reed
3f805072ae Fixing broken setup; adding ITagBuilderFactory to setup mode for CoreShapes to function.
--HG--
branch : dev
2011-06-13 17:36:09 -07:00
Sebastien Ros
c76e63b4ec Refactoring DateTime shapes to use Time Selector
--HG--
branch : dev
extra : transplant_source : 8%BB%DD%1A%B0%F5A%9E%B5b%7F5%EB%ACM%5D%F5%08%07%A5
2011-06-13 17:08:51 -07:00
Sebastien Ros
8296c43ac2 Merge
--HG--
branch : dev
2011-06-13 17:01:18 -07:00
Dave Reed
bab5fe32a2 Adding alt text to Images where missing
--HG--
branch : dev
2011-06-13 14:36:37 -07:00
Dave Reed
4048f697bb Merge
--HG--
branch : dev
2011-06-13 14:29:19 -07:00
Dave Reed
d6255d141e Replacing all uses of <img> with Display.Image. Added Title support to Image shape.
--HG--
branch : dev
2011-06-13 14:28:25 -07:00
Sebastien Ros
25e33b320e Adding TimeZone property and editor to Site Settings
--HG--
branch : dev
extra : transplant_source : %AD%CDD%CC%F0%8ABc%C2%EC%8D%2A%8B%E7%3Fb%C3%80%FEd
2011-06-13 14:26:12 -07:00
Dave Reed
7c566bebbb ShapeBehavior: Ability to specify Id of shape, and Attributes translates "_" to "-" so you can use new {} to create data-foo attributes, and it strips "@" (like MVC). Rename _hack to _shape.
--HG--
branch : dev
2011-06-13 14:25:29 -07:00
Andre Rodrigues
62f9f2bacb Merge
--HG--
branch : dev
2011-06-13 14:19:53 -07:00
Andre Rodrigues
5cc3c48887 Merge
--HG--
branch : dev
2011-06-13 14:19:35 -07:00
Andre Rodrigues
e4767d9b39 Adding stylecop settings file.
--HG--
branch : dev
2011-06-13 13:57:36 -07:00
Suha Can
88f2edaf88 Added new Fetch methods to IRepository.
Removed Table in favor of Fetch().
Removed Update which was a NOP.

--HG--
branch : dev
2011-06-13 12:04:35 -07:00
Dave Reed
03a9d9c57b Added a ShapeBehavior to make Display.Shape() named parameters Items, Classes, and Attributes work (thanks loudej)
--HG--
branch : dev
2011-06-13 11:02:12 -07:00
Dave Reed
129b2eff3e Merge
--HG--
branch : dev
2011-06-13 09:40:03 -07:00
Sebastien Ros
2263881904 Implementing SiteTimeZoneSelector
--HG--
branch : dev
extra : transplant_source : %3AQ%04G%B4%DF%F6%CFH%84%80%AC%93V%EAq%EB%D0%DC%FC
2011-06-10 17:33:04 -07:00
Dave Reed
9f0857a9f4 New Shape: Image
--HG--
branch : dev
2011-06-10 16:34:19 -07:00
Andre Rodrigues
0a75a58b08 Moving Virtual Path Provider extension methods to private methods where they are used.
--HG--
branch : dev
2011-06-10 15:19:47 -07:00
Suha Can
9cc1a844e7 Remove ReadOnlyCollection extensions class. Instead, inline code when it made sense, remove it altogether in instances where it was too parano.
--HG--
branch : dev
2011-06-10 15:09:41 -07:00
Sebastien Ros
fc1a9188a3 Moving IClock to Orchard.Time and adding ITimeZoneSelector
--HG--
branch : dev
extra : transplant_source : %7F%11%E9%9D%80F%A9%F0%7Bk%22%C0O%FC%EE%2B%06%91m%C8
2011-06-10 14:23:36 -07:00
Suha Can
c9bb2903bb Updating a unit test case.
--HG--
branch : dev
2011-06-10 14:10:28 -07:00
Andre Rodrigues
bf618ad46f Removing IMapper.
--HG--
branch : dev
rename : src/Orchard/ContentManagement/MetaData/IContentDefinitionReader.cs => src/Orchard/ContentManagement/MetaData/Services/IContentDefinitionReader.cs
rename : src/Orchard/ContentManagement/MetaData/IContentDefinitionWriter.cs => src/Orchard/ContentManagement/MetaData/Services/IContentDefinitionWriter.cs
2011-06-10 13:40:02 -07:00
Suha Can
ee1bc8fe73 Exception handling consolidation in command handlers.
Use Context.Output to write error messages when you handle an Exception or an error case. If you can't recover afterwards, just return.
Don't throw an exception from within the handler unless necessary.
-> If you want to throw due to an inner exception, throw an OrchardException. Add an error message and the exception as the innerexception of your OrchardException.
Your exception will be caught by the command executive, an error message will indicate which command failed, and the inner exceptions will be displayed.
Also, do not return values from commands, they are not services.

--HG--
branch : dev
2011-06-10 13:34:29 -07:00
Dave Reed
8cd476fad3 IHtmlString is a better way :)
--HG--
branch : dev
2011-06-10 13:04:33 -07:00
Dave Reed
8dd0398b70 Applying code review to Display and Editor shapes, which includes adding a Link core shape.
--HG--
branch : dev
2011-06-10 12:20:06 -07:00
Dave Reed
edfec6f595 Merge
--HG--
branch : dev
2011-06-10 10:12:14 -07:00
Renaud Paquay
9b32e4546f Fix compilation error after merge
--HG--
branch : dev
2011-06-09 22:31:46 -07:00
Renaud Paquay
505e96bb3e Merge 1.x => dev
--HG--
branch : dev
2011-06-09 22:28:10 -07:00
Dave Reed
9e49827410 Removing extension methods ItemDisplayText, ItemDisplayUrl, ItemEditUrl (if anything these should be more accessible on ContentItem or ContentItemMetadata)
--HG--
branch : dev
2011-06-09 17:22:52 -07:00
Suha Can
333b0582a3 IExceptionPolicy concept and default implementation.
Updating EventBus and UnhandledExceptionFilter to use the exception policy.
Adding OrchardFatalException.
Updating text on default error page.
(Part II) Removing the unhandled "catch" from module controllers. If there are "expected" exceptions, move them closer to the APIs where they occur.
Removing ControllerExtensions.Error and refactoring.

--HG--
branch : dev
2011-06-09 16:34:31 -07:00
Sebastien Ros
40f90b2625 Merge
--HG--
branch : dev
2011-06-09 16:29:41 -07:00
Sebastien Ros
bec029c43c Merge
--HG--
branch : dev
2011-06-09 16:29:24 -07:00
Sebastien Ros
85beb317fe Merge
--HG--
branch : dev
2011-06-09 16:28:40 -07:00
Dave Reed
9dcb38a7fb Removed ItemAdminLink extension method in favor of AdminLink parameter to EditLink shape.
--HG--
branch : dev
2011-06-09 15:47:26 -07:00
Dave Reed
ba3eb3ee22 Replaced EditItemLink extension method with an EditLink shape.
--HG--
branch : dev
2011-06-09 15:37:31 -07:00
Dave Reed
6eddbeb226 Added a comment to DisplayLink shape
--HG--
branch : dev
2011-06-09 14:27:50 -07:00
Dave Reed
6a4b998d49 Converted ItemDisplayLink Html Helper to a DisplayLink shape.
--HG--
branch : dev
2011-06-09 14:04:10 -07:00
Suha Can
b9f903511a Moving DependencyOrdering class to a better place.
--HG--
branch : dev
2011-06-09 11:19:32 -07:00
Sebastien Ros
603449417e Renaming Lock in TryLock
--HG--
branch : dev
2011-06-09 10:53:09 -07:00
Sebastien Ros
a9dae8b009 Removing IsLocked()
--HG--
branch : dev
2011-06-09 10:48:10 -07:00
Sebastien Ros
72a4a45d98 Removing IVolatileProvider
--HG--
branch : dev
2011-06-08 18:01:26 -07:00
Sebastien Ros
8f060c8482 Adding more comments on main summaries
--HG--
branch : dev
2011-06-08 17:02:32 -07:00
Sebastien Ros
a8b168f2f8 Remove Utility/Reflect + ReflectOn classes
--HG--
branch : dev
2011-06-08 16:35:22 -07:00
Suha Can
02baf3b498 (Part I) Removing the unhandled "catch" from module controllers. If there are "expected" exceptions, move them closer to the APIs where they occur.
--HG--
branch : dev
2011-06-08 16:26:58 -07:00
Suha Can
9aa1437d2c Exception handling in controllers. No more YSOD.
Create custom 500 error page (with admin theme) for all technical errors (i.e. exceptions that the app doesn't handle)
Implement an filter that will catch all unhandled exceptions and display the custom 500 page. Filter will also use ILogger to log the exception.

--HG--
branch : dev
2011-06-08 14:27:05 -07:00
Sebastien Ros
6c7b1e5f71 Refactoring ILockManager
--HG--
branch : dev
2011-06-08 13:05:55 -07:00
Suha Can
f2a28631a1 Removed the FailFast option on EventHandler. Will call notifier instead.
--HG--
branch : dev
2011-06-07 16:58:33 -07:00
Suha Can
3c27c6166b Merge contributions -> dev
--HG--
branch : dev
2011-06-07 11:38:37 -07:00
Suha Can
7dbc363757 Merge integration -> contributions.
--HG--
branch : contributions
2011-06-07 11:19:34 -07:00
Renaud Paquay
8506ef41ef Merge 1.x => dev
--HG--
branch : dev
2011-06-06 11:53:32 -07:00
Renaud Paquay
5549d0dfe5 Merge 1.x => integration
--HG--
branch : integration
2011-06-06 11:53:01 -07:00
Andre Rodrigues
464a021669 Fixing compilation errors.
--HG--
branch : dev
2011-06-06 10:45:51 -07:00
Renaud Paquay
88174a2b9b Merge 1.x => integration
--HG--
branch : integration
2011-06-04 14:03:26 -07:00
Renaud Paquay
7020f89086 Merge 1.x => dev
--HG--
branch : dev
2011-06-04 13:56:46 -07:00
Suha Can
1dbc40c6ac Contribution by Piotr.
Fix workitem #17872: Null shape added to Zone causes NotImplementedException being thrown (return to change listing).
Added handling of null shapes. If shape that gets passed to Add method is null - it is simply ignored.

--HG--
branch : contributions
2011-05-31 12:38:34 -07:00
Suha Can
13d921a648 Contribution by mspring.
Added the BlogPart to the shape model of RecentBlogPostsPart just the same way
as being done in BlogArchivesPartDriver.
This enables the use of Html.ItemDisplayLink((IContent)Model.Blog) inside
overwritten shapes which want to show a link to the entire blog.

--HG--
branch : contributions
2011-05-31 12:20:43 -07:00
Andre Rodrigues
38e5a8380b Moving default SiteSettings values to a handler.
--HG--
branch : dev
2011-05-23 15:27:40 -07:00
Dave Reed
9ba56ef8fb #17692: ResourceManager uses static VirtualPathProvider methods
--HG--
branch : dev
2011-05-18 16:46:48 -07:00
Suha Can
cd09bc389b Remove RouteValueDictionaryExtensions and refactor ItemEditLink/ItemAdminLink.
--HG--
branch : dev
2011-05-11 12:06:54 -07:00
Suha Can
3500842e82 Refactoring.
Removing JetBrains.* namespace and UsedImplicitly attributes from Orchard.

--HG--
branch : dev
2011-05-10 17:01:58 -07:00
Suha Can
b0caa07f13 Remove unused utility class, ReflectOn.
--HG--
branch : dev
2011-05-10 14:27:17 -07:00
Suha Can
97b01b14d9 Merge
--HG--
branch : contributions
2011-05-09 10:23:28 -07:00
Suha Can
891695b328 Contribution by sfmskywalker.
As a theme developer we need to be able to override widget rendering (not widget the wrapper, but contenttypes that are sterotyped as a widget, e.g. RecentBlogPosts).
This adds a new feature WidgetAlternates in the Orchard.DesignerTools module.

--HG--
branch : contributions
2011-05-09 10:08:00 -07:00
LukeHertert@LukeHertert-BC
44ece7842e Modified template module project to include mvc project type.
Modified module codegen command to include orchard controller t4 template.

--HG--
branch : contributions
2011-04-27 16:53:09 -04:00
Suha Can
c55e4ab956 Fixing typos causing script errors (#17715)
--HG--
branch : dev
2011-04-19 10:49:54 -07:00
Suha Can
b4ec14747b Contribution by wmild to fix bug #17119.
--HG--
branch : contributions
2011-04-11 11:47:17 -07:00
Suha Can
135b4bd722 Merge integration -> contributions
--HG--
branch : contributions
2011-04-11 10:03:46 -07:00
Suha Can
046563b520 Merge 1.x -> integration
--HG--
branch : integration
2011-04-11 09:41:06 -07:00
Renaud Paquay
ef94183d9e Merge 1.x -> dev
--HG--
branch : dev
2011-04-10 19:27:20 -07:00
Renaud Paquay
2687655e93 Added tag 1.1 for changeset 97186e9f4536 2011-04-10 18:57:29 -07:00
Renaud Paquay
8efb9a4145 Merge 1.x -> default 2011-04-10 18:57:12 -07:00
Renaud Paquay
71254bac95 Set build version (1.1.30) for v1.1. 2011-04-10 18:53:43 -07:00
Renaud Paquay
2962ba675d Added tag 1.1 for changeset 48aedbdcebb1 2011-04-09 10:50:47 -07:00
Renaud Paquay
8fe03f6f32 Set build version (1.1.29) for v1.1. 2011-04-09 10:50:24 -07:00
Renaud Paquay
98091b23f9 Merge 1.x -> default 2011-04-09 10:46:52 -07:00
Suha Can
f7e239d728 Added tag 1.1 for changeset 6d7b973415c9 2011-04-08 17:24:55 -07:00
Suha Can
f8aebb342f Set build version (1.1.28) for v1.1. 2011-04-08 17:24:31 -07:00
Suha Can
1dbeae220a Merge 1.x -> default 2011-04-08 17:19:18 -07:00
Suha Can
0af9f295e1 Merge 1.x -> default 2011-04-08 14:39:02 -07:00
Suha Can
ed5b107b7a Merge 1.x -> default 2011-04-08 12:01:40 -07:00
Andre Rodrigues
7ef08d8c95 #17703: Added recipes to the search modules
--HG--
branch : dev
2011-04-08 11:06:44 -07:00
Suha Can
01c483db81 Merge 1.x -> default 2011-04-08 09:14:31 -07:00
Dave Reed
fe74d9fec1 Refactored jQuery isolation in shape tracing script
--HG--
branch : dev
2011-03-28 11:52:19 -07:00
Andre Rodrigues
5e0a71fd00 Adding Orchard Service Host Factory and IoC behavior for WCF support.
--HG--
branch : dev
2011-03-28 09:29:51 -07:00
Sebastien Ros
5ff0201489 Refactoring jQuery isolation in shape tracing
--HG--
branch : dev
2011-03-27 15:13:12 -07:00
Suha Can
2f4822f5c7 Merge integration -> contributions
--HG--
branch : contributions
2011-03-26 12:37:59 -07:00
646 changed files with 6679 additions and 5568 deletions

View File

@@ -13,3 +13,8 @@ d2cca954cbf94750946a6325e5ec23e267430bd2 perf snapshot 1
5cc01ad95f11fcd241163685effaf01ef4b6cb02 1.0
5cc01ad95f11fcd241163685effaf01ef4b6cb02 1.0
16f874f7c4f38ed92ec2e40bd5a9cc7b1ee87407 1.0
6d7b973415c94482a417ba025a4c823d5c2d6630 1.1
6d7b973415c94482a417ba025a4c823d5c2d6630 1.1
48aedbdcebb174eb37534df9c7401fa35da22bbd 1.1
48aedbdcebb174eb37534df9c7401fa35da22bbd 1.1
97186e9f4536562febcdecf3da481231d375b0c7 1.1

Binary file not shown.

View File

@@ -2,13 +2,12 @@
using System.Collections.Generic;
using System.Linq;
using Autofac;
using JetBrains.Annotations;
using Moq;
using NUnit.Framework;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
using Orchard.ContentManagement.Handlers;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.Definition;
using Orchard.ContentManagement.Records;
using Orchard.Core.Common.Handlers;
using Orchard.Core.Common.Models;
@@ -76,7 +75,6 @@ namespace Orchard.Core.Tests.Body {
}
}
[UsedImplicitly]
public class ThingHandler : ContentHandler {
public ThingHandler() {
Filters.Add(new ActivatingFilter<Thing>(ThingDriver.ContentTypeName));

View File

@@ -4,14 +4,14 @@ using System.Linq;
using System.Web;
using System.Web.Routing;
using Autofac;
using JetBrains.Annotations;
using Moq;
using NUnit.Framework;
using Orchard.AspNet.Abstractions;
using Orchard.Caching;
using Orchard.ContentManagement.Aspects;
using Orchard.ContentManagement.Parts;
using Orchard.ContentManagement.Drivers;
using Orchard.ContentManagement.Drivers.Coordinators;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.Definition;
using Orchard.Core.Common.Drivers;
using Orchard.Core.Common.Handlers;
using Orchard.Core.Common.Models;
@@ -29,7 +29,6 @@ using Orchard.DisplayManagement.Descriptors.ShapePlacementStrategy;
using Orchard.DisplayManagement.Implementation;
using Orchard.Environment.Extensions;
using Orchard.Environment.Extensions.Models;
using Orchard.FileSystems.VirtualPath;
using Orchard.Localization;
using Orchard.Security;
using Orchard.Tasks.Scheduling;
@@ -122,7 +121,6 @@ namespace Orchard.Core.Tests.Common.Providers {
}
}
[UsedImplicitly]
class TestHandler : ContentHandler {
public TestHandler() {
Filters.Add(new ActivatingFilter<CommonPart>("test-item"));
@@ -158,7 +156,7 @@ namespace Orchard.Core.Tests.Common.Providers {
var item = contentManager.Create<ICommonPart>("test-item", VersionOptions.Draft, init => { });
var viewModel = new OwnerEditorViewModel { Owner = "User" };
updateModel.Setup(x => x.TryUpdateModel(viewModel, "", null, null)).Returns(true);
contentManager.UpdateEditor(item.ContentItem, updateModel.Object);
contentManager.UpdateEditor(item.ContentItem, new EditorOptions { Updater = updateModel.Object });
}
class UpdatModelStub : IUpdateModel {
@@ -205,7 +203,7 @@ namespace Orchard.Core.Tests.Common.Providers {
var updater = new UpdatModelStub() { Owner = null };
contentManager.UpdateEditor(item.ContentItem, updater);
contentManager.UpdateEditor(item.ContentItem, new EditorOptions { Updater = updater });
}
[Test]
@@ -226,7 +224,7 @@ namespace Orchard.Core.Tests.Common.Providers {
b => b.Describe("Parts_Common_Owner_Edit").From(TestFeature())
.Placement(ShapePlacementParsingStrategy.BuildPredicate(c => true, new KeyValuePair<string, string>("Path", "~/yadda")), new PlacementInfo { Location = "Match" });
contentManager.UpdateEditor(item.ContentItem, updater);
contentManager.UpdateEditor(item.ContentItem, new EditorOptions { Updater = updater });
Assert.That(updater.ModelErrors.ContainsKey("OwnerEditor.Owner"), Is.True);
}
@@ -338,8 +336,8 @@ namespace Orchard.Core.Tests.Common.Providers {
_clock.Advance(TimeSpan.FromMinutes(1));
var editUtc = _clock.UtcNow;
var updater = new UpdatModelStub() { Owner = "" };
contentManager.UpdateEditor(item.ContentItem, updater);
var updater = new UpdatModelStub { Owner = "" };
contentManager.UpdateEditor(item.ContentItem, new EditorOptions { Updater = updater });
Assert.That(item.CreatedUtc, Is.EqualTo(createUtc));
Assert.That(item.ModifiedUtc, Is.EqualTo(editUtc));

View File

@@ -9,7 +9,7 @@ using Moq;
using NUnit.Framework;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers;
using Orchard.ContentManagement.MetaData.Builders;
using Orchard.ContentManagement.Definition.Builders;
using Orchard.Core.Common.Models;
using Orchard.Core.Feeds;
using Orchard.Core.Feeds.Controllers;

View File

@@ -1,13 +1,12 @@
using System;
using System.Collections.Generic;
using Autofac;
using JetBrains.Annotations;
using Moq;
using NUnit.Framework;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Aspects;
using Orchard.ContentManagement.Parts;
using Orchard.ContentManagement.Handlers;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.Definition;
using Orchard.ContentManagement.Records;
using Orchard.Core.Common.Models;
using Orchard.Core.Routable;
@@ -261,7 +260,6 @@ namespace Orchard.Core.Tests.Routable.Services {
}
}
[UsedImplicitly]
public class ThingHandler : ContentHandler {
public ThingHandler() {
Filters.Add(new ActivatingFilter<Thing>("thing"));
@@ -283,7 +281,6 @@ namespace Orchard.Core.Tests.Routable.Services {
}
}
[UsedImplicitly]
public class StuffHandler : ContentHandler {
public StuffHandler() {
Filters.Add(new ActivatingFilter<Stuff>("stuff"));

View File

@@ -4,7 +4,7 @@ using Autofac;
using Moq;
using NUnit.Framework;
using Orchard.ContentManagement;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.Definition;
using Orchard.ContentManagement.Records;
using Orchard.Core.Scheduling.Models;
using Orchard.Core.Scheduling.Services;

View File

@@ -5,7 +5,7 @@ using Autofac;
using Moq;
using NUnit.Framework;
using Orchard.ContentManagement;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.Definition;
using Orchard.ContentManagement.Records;
using Orchard.Core.Scheduling.Models;
using Orchard.Core.Scheduling.Services;

View File

@@ -1,16 +1,14 @@
using System;
using System.IO;
using System.Linq;
using System.Xml.Linq;
using Autofac;
using Moq;
using NHibernate;
using NUnit.Framework;
using Orchard.Caching;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.MetaData.Builders;
using Orchard.ContentManagement.MetaData.Models;
using Orchard.ContentManagement.MetaData.Services;
using Orchard.ContentManagement.Definition;
using Orchard.ContentManagement.Definition.Builders;
using Orchard.ContentManagement.Definition.Services;
using Orchard.Core.Settings.Metadata;
using Orchard.Core.Settings.Metadata.Records;
using Orchard.Data;
@@ -45,9 +43,7 @@ namespace Orchard.Core.Tests.Settings.Metadata {
builder.RegisterAutoMocking();
builder.RegisterType<ContentDefinitionManager>().As<IContentDefinitionManager>();
builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>));
builder.RegisterType(typeof(SettingsFormatter))
.As(typeof(IMapper<XElement, SettingsDictionary>))
.As(typeof(IMapper<SettingsDictionary, XElement>));
builder.RegisterType(typeof(SettingsFormatter)).As(typeof(ISettingsFormatter));
builder.RegisterType<Signals>().As<ISignals>();
builder.RegisterType<StubCacheManager>().As<ICacheManager>();
builder.RegisterType<StubParallelCacheContext>().As<IParallelCacheContext>();
@@ -208,7 +204,7 @@ namespace Orchard.Core.Tests.Settings.Metadata {
var type = _container.Resolve<IContentDefinitionManager>().GetTypeDefinition(typeName);
Assert.That(type, Is.Not.Null);
Assert.That(type.Parts.Count(), Is.EqualTo(partNames.Count()));
foreach(var partName in partNames) {
foreach (var partName in partNames) {
Assert.That(type.Parts.Select(p=>p.PartDefinition.Name), Has.Some.EqualTo(partName));
}
}

View File

@@ -1,7 +1,7 @@
using System;
using NUnit.Framework;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Aspects;
using Orchard.ContentManagement.Parts;
using Orchard.Core.Contents;
using Orchard.Data;
using Orchard.Roles.Models;

View File

@@ -1,6 +1,6 @@
using System.Linq;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.MetaData.Models;
using Orchard.ContentManagement.Definition;
using Orchard.ContentManagement.Definition.Models;
using Orchard.Core.Contents.Extensions;
using Orchard.Environment.Configuration;
using Orchard.Environment.Descriptor;

View File

@@ -60,14 +60,14 @@ namespace Orchard.Tests.Modules.CodeGeneration.Commands {
}
[Test]
[ExpectedException(typeof(OrchardException))]
public void CreateDataMigrationTestNonExistentFeature() {
CodeGenerationCommands codeGenerationCommands = new CodeGenerationCommands(_extensionManager,
_schemaCommandGenerator);
TextWriter textWriterOutput = new StringWriter();
var textWriterOutput = new StringWriter();
codeGenerationCommands.Context = new CommandContext { Output = textWriterOutput };
codeGenerationCommands.CreateDataMigration("feature");
Assert.That(textWriterOutput.ToString().Contains("Creating data migration failed: target Feature feature could not be found."));
}
}
}

View File

@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using Autofac;
using JetBrains.Annotations;
using Moq;
using NUnit.Framework;
using Orchard.Comments.Handlers;
@@ -10,7 +9,7 @@ using Orchard.Comments.Services;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
using Orchard.ContentManagement.Handlers;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.Definition;
using Orchard.ContentManagement.Records;
using Orchard.Core.Common.Handlers;
using Orchard.Core.Common.Models;
@@ -187,7 +186,6 @@ namespace Orchard.Tests.Modules.Comments.Services {
}
}
[UsedImplicitly]
public class CommentedItemHandler : ContentHandler {
public CommentedItemHandler() {
Filters.Add(new ActivatingFilter<CommentedItem>("commentedItem"));

View File

@@ -10,6 +10,7 @@ using Orchard.Data;
using Orchard.Services;
using Orchard.Tests.Data;
using Orchard.Tests.Stubs;
using Orchard.Time;
namespace Orchard.Tests.Modules {
public abstract class DatabaseEnabledTestsBase {

View File

@@ -7,16 +7,16 @@ using NHibernate;
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.Definition;
using Orchard.ContentManagement.Definition.Models;
using Orchard.ContentManagement.Definition.Services;
using Orchard.ContentManagement.Records;
using Orchard.Core.Settings.Metadata;
using Orchard.Data;
using Orchard.Environment.Compilation.Loaders;
using Orchard.Environment.Descriptor;
using Orchard.Environment.Descriptor.Models;
using Orchard.Environment.Extensions;
using Orchard.Environment.Extensions.Loaders;
using Orchard.FileSystems.AppData;
using Orchard.FileSystems.WebSite;
using Orchard.ImportExport.Services;
@@ -27,6 +27,7 @@ using Orchard.Tests.Environment.Extensions;
using Orchard.Tests.Modules.Recipes.Services;
using Orchard.Tests.Stubs;
using Orchard.Tests.UI.Navigation;
using Orchard.Time;
namespace Orchard.Tests.Modules.ImportExport.Services {
[TestFixture]
@@ -72,8 +73,7 @@ namespace Orchard.Tests.Modules.ImportExport.Services {
builder.RegisterType<StubAppDataFolder>().As<IAppDataFolder>();
builder.RegisterType<Signals>().As<ISignals>();
builder.RegisterGeneric(typeof(Repository<>)).As(typeof(IRepository<>));
builder.RegisterInstance(new Mock<IMapper<SettingsDictionary, XElement>>().Object);
builder.RegisterInstance(new Mock<IMapper<XElement, SettingsDictionary>>().Object);
builder.RegisterInstance(new Mock<ISettingsFormatter>().Object);
_session = _sessionFactory.OpenSession();
builder.RegisterInstance(new DefaultContentManagerTests.TestSessionLocator(_session)).As<ISessionLocator>();

View File

@@ -8,8 +8,8 @@ using NUnit.Framework;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
using Orchard.ContentManagement.Handlers;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.MetaData.Builders;
using Orchard.ContentManagement.Definition;
using Orchard.ContentManagement.Definition.Builders;
using Orchard.ContentManagement.Records;
using Orchard.Core.Common.Handlers;
using Orchard.Core.Common.Models;
@@ -18,11 +18,11 @@ using Orchard.Environment;
using Orchard.Environment.Configuration;
using Orchard.Environment.Extensions;
using Orchard.FileSystems.AppData;
using Orchard.FileSystems.LockFile;
using Orchard.Indexing;
using Orchard.Indexing.Handlers;
using Orchard.Indexing.Models;
using Orchard.Indexing.Services;
using Orchard.Locking;
using Orchard.Logging;
using Orchard.Security;
using Orchard.Tasks.Indexing;
@@ -38,7 +38,7 @@ namespace Orchard.Tests.Modules.Indexing {
private IContentManager _contentManager;
private Mock<IContentDefinitionManager> _contentDefinitionManager;
private StubLogger _logger;
private ILockFileManager _lockFileManager;
private ILockManager _lockManager;
private const string IndexName = "Search";
private readonly string _basePath = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
@@ -81,7 +81,7 @@ namespace Orchard.Tests.Modules.Indexing {
builder.RegisterType<BodyPartHandler>().As<IContentHandler>();
builder.RegisterType<StubExtensionManager>().As<IExtensionManager>();
builder.RegisterType<DefaultLockFileManager>().As<ILockFileManager>();
builder.RegisterType<DefaultLockManager>().As<ILockManager>();
// setting up a ShellSettings instance
_shellSettings = new ShellSettings { Name = "My Site" };
@@ -103,7 +103,7 @@ namespace Orchard.Tests.Modules.Indexing {
public override void Init() {
base.Init();
_lockFileManager = _container.Resolve<ILockFileManager>();
_lockManager = _container.Resolve<ILockManager>();
_provider = _container.Resolve<IIndexProvider>();
_indexTaskExecutor = _container.Resolve<IIndexingTaskExecutor>();
_contentManager = _container.Resolve<IContentManager>();
@@ -184,9 +184,9 @@ namespace Orchard.Tests.Modules.Indexing {
[Test]
public void IndexingTaskExecutorShouldNotBeReEntrant() {
ILockFile lockFile = null;
_lockFileManager.TryAcquireLock("Sites/My Site/Search.settings.xml.lock", ref lockFile);
using (lockFile) {
var @lock = _lockManager.TryLock(IndexName);
using (@lock) {
while (_indexTaskExecutor.UpdateIndexBatch(IndexName)) {}
Assert.That(_logger.LogEntries.Count, Is.EqualTo(1));
Assert.That(_logger.LogEntries, Has.Some.Matches<LogEntry>(entry => entry.LogFormat == "Index was requested but is already running"));

View File

@@ -7,7 +7,6 @@ using NUnit.Framework;
using Orchard.Environment.Configuration;
using Orchard.FileSystems.AppData;
using Orchard.Indexing;
using Orchard.Indexing.Services;
using Orchard.Tests.FileSystems.AppData;
namespace Orchard.Tests.Modules.Indexing {
@@ -46,7 +45,7 @@ namespace Orchard.Tests.Modules.Indexing {
_provider = _container.Resolve<IIndexProvider>();
}
private ISearchBuilder _searchBuilder { get { return _provider.CreateSearchBuilder("default"); } }
private ISearchBuilder SearchBuilder { get { return _provider.CreateSearchBuilder("default"); } }
[Test]
public void SearchTermsShouldBeFoundInMultipleFields() {
@@ -74,9 +73,9 @@ namespace Orchard.Tests.Modules.Indexing {
_provider.Store("default", _provider.New(3));
Assert.That(_searchBuilder.Get(1).ContentItemId, Is.EqualTo(1));
Assert.That(_searchBuilder.Get(2).ContentItemId, Is.EqualTo(2));
Assert.That(_searchBuilder.Get(3).ContentItemId, Is.EqualTo(3));
Assert.That(SearchBuilder.Get(1).ContentItemId, Is.EqualTo(1));
Assert.That(SearchBuilder.Get(2).ContentItemId, Is.EqualTo(2));
Assert.That(SearchBuilder.Get(3).ContentItemId, Is.EqualTo(3));
}
[Test]
@@ -87,11 +86,93 @@ namespace Orchard.Tests.Modules.Indexing {
_provider.Store("default", _provider.New(3).Add("title", "cat"));
Assert.That(_searchBuilder.WithField("title", "cat").Search().Count(), Is.EqualTo(2));
Assert.That(_searchBuilder.WithField("title", "cat").Search().Any(hit => new[] { 1, 3 }.Contains(hit.ContentItemId)), Is.True);
Assert.That(SearchBuilder.WithField("title", "cat").Search().Count(), Is.EqualTo(2));
Assert.That(SearchBuilder.WithField("title", "cat").Search().Any(hit => new[] { 1, 3 }.Contains(hit.ContentItemId)), Is.True);
}
[Test]
public void ShouldSearchByBooleanWhateverIndexingScheme() {
_provider.CreateIndex("default");
_provider.Store("default", _provider.New(1).Add("foo", true));
_provider.Store("default", _provider.New(2).Add("foo", true).Store());
_provider.Store("default", _provider.New(3).Add("foo", true).Analyze());
_provider.Store("default", _provider.New(4).Add("foo", true).Store().Analyze());
_provider.Store("default", _provider.New(5).Add("foo", false));
_provider.Store("default", _provider.New(6).Add("foo", false).Store());
_provider.Store("default", _provider.New(7).Add("foo", false).Analyze());
_provider.Store("default", _provider.New(8).Add("foo", false).Store().Analyze());
Assert.That(SearchBuilder.WithField("foo", false).Search().Count(), Is.EqualTo(4));
Assert.That(SearchBuilder.WithField("foo", true).Search().Count(), Is.EqualTo(4));
}
[Test]
public void ShouldSearchByStringWhateverIndexingScheme() {
_provider.CreateIndex("default");
_provider.Store("default", _provider.New(1).Add("foo", "abc"));
_provider.Store("default", _provider.New(2).Add("foo", "abc").Store());
_provider.Store("default", _provider.New(3).Add("foo", "abc").Analyze());
_provider.Store("default", _provider.New(4).Add("foo", "abc").Store().Analyze());
_provider.Store("default", _provider.New(5).Add("foo", "def"));
_provider.Store("default", _provider.New(6).Add("foo", "def").Store());
_provider.Store("default", _provider.New(7).Add("foo", "def").Analyze());
_provider.Store("default", _provider.New(8).Add("foo", "def").Store().Analyze());
Assert.That(SearchBuilder.WithField("foo", "abc").Search().Count(), Is.EqualTo(4));
Assert.That(SearchBuilder.WithField("foo", "def").Search().Count(), Is.EqualTo(4));
}
[Test]
public void ShouldSearchByIntegerWhateverIndexingScheme() {
_provider.CreateIndex("default");
_provider.Store("default", _provider.New(1).Add("foo", 1));
_provider.Store("default", _provider.New(2).Add("foo", 1).Store());
_provider.Store("default", _provider.New(3).Add("foo", 1).Analyze());
_provider.Store("default", _provider.New(4).Add("foo", 1).Store().Analyze());
_provider.Store("default", _provider.New(5).Add("foo", 2));
_provider.Store("default", _provider.New(6).Add("foo", 2).Store());
_provider.Store("default", _provider.New(7).Add("foo", 2).Analyze());
_provider.Store("default", _provider.New(8).Add("foo", 2).Store().Analyze());
Assert.That(SearchBuilder.WithField("foo", 1).Search().Count(), Is.EqualTo(4));
Assert.That(SearchBuilder.WithField("foo", 2).Search().Count(), Is.EqualTo(4));
}
[Test]
public void ShouldSearchByFloatWhateverIndexingScheme() {
_provider.CreateIndex("default");
_provider.Store("default", _provider.New(1).Add("foo", 1.1));
_provider.Store("default", _provider.New(2).Add("foo", 1.1).Store());
_provider.Store("default", _provider.New(3).Add("foo", 1.1).Analyze());
_provider.Store("default", _provider.New(4).Add("foo", 1.1).Store().Analyze());
_provider.Store("default", _provider.New(5).Add("foo", 2.1));
_provider.Store("default", _provider.New(6).Add("foo", 2.1).Store());
_provider.Store("default", _provider.New(7).Add("foo", 2.1).Analyze());
_provider.Store("default", _provider.New(8).Add("foo", 2.1).Store().Analyze());
Assert.That(SearchBuilder.WithField("foo", 1.1).Search().Count(), Is.EqualTo(4));
Assert.That(SearchBuilder.WithField("foo", 2.1).Search().Count(), Is.EqualTo(4));
}
[Test]
public void ShouldSearchByDateTimeWhateverIndexingScheme() {
var date1 = DateTime.Today;
var date2 = DateTime.Today.AddDays(1);
_provider.CreateIndex("default");
_provider.Store("default", _provider.New(1).Add("foo", date1));
_provider.Store("default", _provider.New(2).Add("foo", date1).Store());
_provider.Store("default", _provider.New(3).Add("foo", date1).Analyze());
_provider.Store("default", _provider.New(4).Add("foo", date1).Store().Analyze());
_provider.Store("default", _provider.New(5).Add("foo", date2));
_provider.Store("default", _provider.New(6).Add("foo", date2).Store());
_provider.Store("default", _provider.New(7).Add("foo", date2).Analyze());
_provider.Store("default", _provider.New(8).Add("foo", date2).Store().Analyze());
Assert.That(SearchBuilder.WithField("foo", date1).Search().Count(), Is.EqualTo(4));
Assert.That(SearchBuilder.WithField("foo", date2).Search().Count(), Is.EqualTo(4));
}
[Test]
public void ShouldCountResultsOnly() {
_provider.CreateIndex("default");
@@ -99,8 +180,8 @@ namespace Orchard.Tests.Modules.Indexing {
_provider.Store("default", _provider.New(2).Add("title", "dog"));
_provider.Store("default", _provider.New(3).Add("title", "cat"));
Assert.That(_searchBuilder.WithField("title", "dog").Count(), Is.EqualTo(1));
Assert.That(_searchBuilder.WithField("title", "cat").Count(), Is.EqualTo(2));
Assert.That(SearchBuilder.WithField("title", "dog").Count(), Is.EqualTo(1));
Assert.That(SearchBuilder.WithField("title", "cat").Count(), Is.EqualTo(2));
}
[Test]
@@ -110,12 +191,12 @@ namespace Orchard.Tests.Modules.Indexing {
_provider.Store("default", _provider.New(2).Add("date", new DateTime(2010, 05, 28, 12, 30, 30)));
_provider.Store("default", _provider.New(3).Add("date", new DateTime(2010, 05, 28, 12, 30, 45)));
Assert.That(_searchBuilder.WithinRange("date", new DateTime(2010, 05, 28, 12, 30, 15), DateTime.MaxValue).Count(), Is.EqualTo(3));
Assert.That(_searchBuilder.WithinRange("date", DateTime.MinValue, new DateTime(2010, 05, 28, 12, 30, 45)).Count(), Is.EqualTo(3));
Assert.That(_searchBuilder.WithinRange("date", new DateTime(2010, 05, 28, 12, 30, 15), new DateTime(2010, 05, 28, 12, 30, 45)).Count(), Is.EqualTo(3));
Assert.That(_searchBuilder.WithinRange("date", new DateTime(2010, 05, 28, 12, 30, 16), new DateTime(2010, 05, 28, 12, 30, 44)).Count(), Is.EqualTo(1));
Assert.That(_searchBuilder.WithinRange("date", new DateTime(2010, 05, 28, 12, 30, 46), DateTime.MaxValue).Count(), Is.EqualTo(0));
Assert.That(_searchBuilder.WithinRange("date", DateTime.MinValue, new DateTime(2010, 05, 28, 12, 30, 1)).Count(), Is.EqualTo(0));
Assert.That(SearchBuilder.WithinRange("date", new DateTime(2010, 05, 28, 12, 30, 15), DateTime.MaxValue).Count(), Is.EqualTo(3));
Assert.That(SearchBuilder.WithinRange("date", DateTime.MinValue, new DateTime(2010, 05, 28, 12, 30, 45)).Count(), Is.EqualTo(3));
Assert.That(SearchBuilder.WithinRange("date", new DateTime(2010, 05, 28, 12, 30, 15), new DateTime(2010, 05, 28, 12, 30, 45)).Count(), Is.EqualTo(3));
Assert.That(SearchBuilder.WithinRange("date", new DateTime(2010, 05, 28, 12, 30, 16), new DateTime(2010, 05, 28, 12, 30, 44)).Count(), Is.EqualTo(1));
Assert.That(SearchBuilder.WithinRange("date", new DateTime(2010, 05, 28, 12, 30, 46), DateTime.MaxValue).Count(), Is.EqualTo(0));
Assert.That(SearchBuilder.WithinRange("date", DateTime.MinValue, new DateTime(2010, 05, 28, 12, 30, 1)).Count(), Is.EqualTo(0));
}
[Test]
@@ -128,16 +209,16 @@ namespace Orchard.Tests.Modules.Indexing {
_provider.Store("default", _provider.New(55555));
Assert.That(_searchBuilder.Count(), Is.EqualTo(5));
Assert.That(_searchBuilder.Slice(0, 3).Count(), Is.EqualTo(3));
Assert.That(_searchBuilder.Slice(1, 3).Count(), Is.EqualTo(3));
Assert.That(_searchBuilder.Slice(3, 3).Count(), Is.EqualTo(2));
Assert.That(SearchBuilder.Count(), Is.EqualTo(5));
Assert.That(SearchBuilder.Slice(0, 3).Count(), Is.EqualTo(3));
Assert.That(SearchBuilder.Slice(1, 3).Count(), Is.EqualTo(3));
Assert.That(SearchBuilder.Slice(3, 3).Count(), Is.EqualTo(2));
// Count() and Search() should return the same results
Assert.That(_searchBuilder.Search().Count(), Is.EqualTo(5));
Assert.That(_searchBuilder.Slice(0, 3).Search().Count(), Is.EqualTo(3));
Assert.That(_searchBuilder.Slice(1, 3).Search().Count(), Is.EqualTo(3));
Assert.That(_searchBuilder.Slice(3, 3).Search().Count(), Is.EqualTo(2));
Assert.That(SearchBuilder.Search().Count(), Is.EqualTo(5));
Assert.That(SearchBuilder.Slice(0, 3).Search().Count(), Is.EqualTo(3));
Assert.That(SearchBuilder.Slice(1, 3).Search().Count(), Is.EqualTo(3));
Assert.That(SearchBuilder.Slice(3, 3).Search().Count(), Is.EqualTo(2));
}
[Test]
@@ -149,12 +230,12 @@ namespace Orchard.Tests.Modules.Indexing {
_provider.Store("default", _provider.New(4).Add("body", "a dog is pursuing a cat").Analyze());
_provider.Store("default", _provider.New(5).Add("body", "the elephant can't catch up the dog").Analyze());
var michael = _searchBuilder.WithField("body", "michael").Search().ToList();
var michael = SearchBuilder.WithField("body", "michael").Search().ToList();
Assert.That(michael.Count(), Is.EqualTo(2));
Assert.That(michael[0].Score >= michael[1].Score, Is.True);
// Sorting on score is always descending
michael = _searchBuilder.WithField("body", "michael").Ascending().Search().ToList();
michael = SearchBuilder.WithField("body", "michael").Ascending().Search().ToList();
Assert.That(michael.Count(), Is.EqualTo(2));
Assert.That(michael[0].Score >= michael[1].Score, Is.True);
}
@@ -162,37 +243,77 @@ namespace Orchard.Tests.Modules.Indexing {
[Test]
public void ShouldSortByDate() {
_provider.CreateIndex("default");
_provider.Store("default", _provider.New(1).Add("date", new DateTime(2010, 05, 28, 12, 30, 15)).Store());
_provider.Store("default", _provider.New(2).Add("date", new DateTime(2010, 05, 28, 12, 30, 30)).Store());
_provider.Store("default", _provider.New(3).Add("date", new DateTime(2010, 05, 28, 12, 30, 45)).Store());
_provider.Store("default", _provider.New(1).Add("date", new DateTime(2010, 05, 28, 12, 30, 30)));
_provider.Store("default", _provider.New(2).Add("date", DateTime.MinValue));
_provider.Store("default", _provider.New(3).Add("date", DateTime.MaxValue));
var date = _searchBuilder.SortByDateTime("date").Search().ToList();
var date = SearchBuilder.SortByDateTime("date").Search().ToList();
Assert.That(date.Count(), Is.EqualTo(3));
Assert.That(date[0].GetDateTime("date") > date[1].GetDateTime("date"), Is.True);
Assert.That(date[1].GetDateTime("date") > date[2].GetDateTime("date"), Is.True);
Assert.That(date[0].ContentItemId, Is.EqualTo(3));
Assert.That(date[1].ContentItemId, Is.EqualTo(1));
Assert.That(date[2].ContentItemId, Is.EqualTo(2));
date = _searchBuilder.SortByDateTime("date").Ascending().Search().ToList();
Assert.That(date.Count(), Is.EqualTo(3));
Assert.That(date[0].GetDateTime("date") < date[1].GetDateTime("date"), Is.True);
Assert.That(date[1].GetDateTime("date") < date[2].GetDateTime("date"), Is.True);
date = SearchBuilder.SortByDateTime("date").Ascending().Search().ToList();
Assert.That(date[0].ContentItemId, Is.EqualTo(2));
Assert.That(date[1].ContentItemId, Is.EqualTo(1));
Assert.That(date[2].ContentItemId, Is.EqualTo(3));
}
[Test]
public void ShouldSortByNumber() {
_provider.CreateIndex("default");
_provider.Store("default", _provider.New(1).Add("downloads", 111).Store());
_provider.Store("default", _provider.New(2).Add("downloads", 2222).Store());
_provider.Store("default", _provider.New(3).Add("downloads", 3).Store());
_provider.Store("default", _provider.New(1).Add("downloads", 111));
_provider.Store("default", _provider.New(2).Add("downloads", int.MaxValue));
_provider.Store("default", _provider.New(3).Add("downloads", int.MinValue));
var number = _searchBuilder.SortByInteger("downloads").Search().ToList();
var number = SearchBuilder.SortByInteger("downloads").Search().ToList();
Assert.That(number.Count(), Is.EqualTo(3));
Assert.That(number[0].GetInt("downloads") > number[1].GetInt("downloads"), Is.True);
Assert.That(number[1].GetInt("downloads") > number[2].GetInt("downloads"), Is.True);
Assert.That(number[0].ContentItemId, Is.EqualTo(2));
Assert.That(number[1].ContentItemId, Is.EqualTo(1));
Assert.That(number[2].ContentItemId, Is.EqualTo(3));
number = _searchBuilder.SortByInteger("downloads").Ascending().Search().ToList();
number = SearchBuilder.SortByInteger("downloads").Ascending().Search().ToList();
Assert.That(number.Count(), Is.EqualTo(3));
Assert.That(number[0].GetInt("downloads") < number[1].GetInt("downloads"), Is.True);
Assert.That(number[1].GetInt("downloads") < number[2].GetInt("downloads"), Is.True);
Assert.That(number[0].ContentItemId, Is.EqualTo(3));
Assert.That(number[1].ContentItemId, Is.EqualTo(1));
Assert.That(number[2].ContentItemId, Is.EqualTo(2));
}
[Test]
public void ShouldSortByBoolean() {
_provider.CreateIndex("default");
_provider.Store("default", _provider.New(1).Add("active", true));
_provider.Store("default", _provider.New(2).Add("active", false));
var number = SearchBuilder.SortByBoolean("active").Search().ToList();
Assert.That(number.Count(), Is.EqualTo(2));
Assert.That(number[0].ContentItemId, Is.EqualTo(1));
Assert.That(number[1].ContentItemId, Is.EqualTo(2));
number = SearchBuilder.SortByBoolean("active").Ascending().Search().ToList();
Assert.That(number.Count(), Is.EqualTo(2));
Assert.That(number[0].ContentItemId, Is.EqualTo(2));
Assert.That(number[1].ContentItemId, Is.EqualTo(1));
}
[Test]
public void ShouldSortByDouble() {
_provider.CreateIndex("default");
_provider.Store("default", _provider.New(1).Add("rating", 111.111));
_provider.Store("default", _provider.New(2).Add("rating", double.MaxValue));
_provider.Store("default", _provider.New(3).Add("rating", double.MinValue));
var number = SearchBuilder.SortByDouble("rating").Search().ToList();
Assert.That(number.Count(), Is.EqualTo(3));
Assert.That(number[0].ContentItemId, Is.EqualTo(2));
Assert.That(number[1].ContentItemId, Is.EqualTo(1));
Assert.That(number[2].ContentItemId, Is.EqualTo(3));
number = SearchBuilder.SortByDouble("rating").Ascending().Search().ToList();
Assert.That(number.Count(), Is.EqualTo(3));
Assert.That(number[0].ContentItemId, Is.EqualTo(3));
Assert.That(number[1].ContentItemId, Is.EqualTo(1));
Assert.That(number[2].ContentItemId, Is.EqualTo(2));
}
[Test]
@@ -201,10 +322,10 @@ namespace Orchard.Tests.Modules.Indexing {
_provider.Store("default", _provider.New(1).Add("body", "Orchard has been developped in C#").Analyze());
_provider.Store("default", _provider.New(2).Add("body", "Windows has been developped in C++").Analyze());
var cs = _searchBuilder.Parse("body", "C#").Search().ToList();
var cs = SearchBuilder.Parse("body", "C#").Search().ToList();
Assert.That(cs.Count(), Is.EqualTo(2));
var cpp = _searchBuilder.Parse("body", "C++").Search().ToList();
var cpp = SearchBuilder.Parse("body", "C++").Search().ToList();
Assert.That(cpp.Count(), Is.EqualTo(2));
}
@@ -215,10 +336,10 @@ namespace Orchard.Tests.Modules.Indexing {
_provider.Store("default", _provider.New(1).Add("body", "Orchard has been developped in C#").Analyze());
_provider.Store("default", _provider.New(2).Add("body", "Windows has been developped in C++").Analyze());
Assert.That(_searchBuilder.WithField("body", "develop").Search().ToList().Count(), Is.EqualTo(2));
Assert.That(_searchBuilder.WithField("body", "develop").WithField("body", "Orchard").Search().ToList().Count(), Is.EqualTo(2));
Assert.That(_searchBuilder.WithField("body", "develop").WithField("body", "Orchard").Mandatory().Search().ToList().Count(), Is.EqualTo(1));
Assert.That(_searchBuilder.WithField("body", "develop").WithField("body", "Orchard").Mandatory().Search().First().ContentItemId, Is.EqualTo(1));
Assert.That(SearchBuilder.WithField("body", "develop").Search().ToList().Count(), Is.EqualTo(2));
Assert.That(SearchBuilder.WithField("body", "develop").WithField("body", "Orchard").Search().ToList().Count(), Is.EqualTo(2));
Assert.That(SearchBuilder.WithField("body", "develop").WithField("body", "Orchard").Mandatory().Search().ToList().Count(), Is.EqualTo(1));
Assert.That(SearchBuilder.WithField("body", "develop").WithField("body", "Orchard").Mandatory().Search().First().ContentItemId, Is.EqualTo(1));
}
[Test]
@@ -227,10 +348,10 @@ namespace Orchard.Tests.Modules.Indexing {
_provider.Store("default", _provider.New(1).Add("body", "Orchard has been developped in C#").Analyze());
_provider.Store("default", _provider.New(2).Add("body", "Windows has been developped in C++").Analyze());
Assert.That(_searchBuilder.WithField("body", "developped").Search().ToList().Count(), Is.EqualTo(2));
Assert.That(_searchBuilder.WithField("body", "developped").WithField("body", "Orchard").Search().ToList().Count(), Is.EqualTo(2));
Assert.That(_searchBuilder.WithField("body", "developped").WithField("body", "Orchard").Forbidden().Search().ToList().Count(), Is.EqualTo(1));
Assert.That(_searchBuilder.WithField("body", "developped").WithField("body", "Orchard").Forbidden().Search().First().ContentItemId, Is.EqualTo(2));
Assert.That(SearchBuilder.WithField("body", "developped").Search().ToList().Count(), Is.EqualTo(2));
Assert.That(SearchBuilder.WithField("body", "developped").WithField("body", "Orchard").Search().ToList().Count(), Is.EqualTo(2));
Assert.That(SearchBuilder.WithField("body", "developped").WithField("body", "Orchard").Forbidden().Search().ToList().Count(), Is.EqualTo(1));
Assert.That(SearchBuilder.WithField("body", "developped").WithField("body", "Orchard").Forbidden().Search().First().ContentItemId, Is.EqualTo(2));
}
[Test]
@@ -239,7 +360,7 @@ namespace Orchard.Tests.Modules.Indexing {
_provider.Store("default", _provider.New(1).Add("body", "Orchard has been developped in C#").Analyze());
_provider.Store("default", _provider.New(2).Add("body", "Windows has been developped in C++").Analyze());
Assert.That(_searchBuilder.WithField("body", "developped").WithField("body", "Orchard").Weighted(2).Search().First().ContentItemId, Is.EqualTo(1));
Assert.That(SearchBuilder.WithField("body", "developped").WithField("body", "Orchard").Weighted(2).Search().First().ContentItemId, Is.EqualTo(1));
}
[Test]
@@ -249,14 +370,14 @@ namespace Orchard.Tests.Modules.Indexing {
_provider.Store("default", _provider.New(2).Add("body", "Renaud is also in the kitchen.").Analyze().Add("title", "A love affair").Analyze());
_provider.Store("default", _provider.New(3).Add("body", "Bertrand is a little bit jealous.").Analyze().Add("title", "Soap opera").Analyze());
Assert.That(_searchBuilder.Parse(new[] {"body"}, "kitchen", false).Count(), Is.EqualTo(2));
Assert.That(_searchBuilder.Parse(new[] {"body"}, "kitchen bertrand", false).Count(), Is.EqualTo(3));
Assert.That(_searchBuilder.Parse(new[] {"body"}, "kitchen +bertrand", false).Count(), Is.EqualTo(1));
Assert.That(_searchBuilder.Parse(new[] {"body"}, "+kitchen +bertrand", false).Count(), Is.EqualTo(0));
Assert.That(_searchBuilder.Parse(new[] {"body"}, "kit", false).Count(), Is.EqualTo(0));
Assert.That(_searchBuilder.Parse(new[] {"body"}, "kit*", false).Count(), Is.EqualTo(2));
Assert.That(_searchBuilder.Parse(new[] {"body", "title"}, "bradley love^3 soap", false).Count(), Is.EqualTo(3));
Assert.That(_searchBuilder.Parse(new[] {"body", "title"}, "bradley love^3 soap", false).Search().First().ContentItemId, Is.EqualTo(2));
Assert.That(SearchBuilder.Parse(new[] {"body"}, "kitchen", false).Count(), Is.EqualTo(2));
Assert.That(SearchBuilder.Parse(new[] {"body"}, "kitchen bertrand", false).Count(), Is.EqualTo(3));
Assert.That(SearchBuilder.Parse(new[] {"body"}, "kitchen +bertrand", false).Count(), Is.EqualTo(1));
Assert.That(SearchBuilder.Parse(new[] {"body"}, "+kitchen +bertrand", false).Count(), Is.EqualTo(0));
Assert.That(SearchBuilder.Parse(new[] {"body"}, "kit", false).Count(), Is.EqualTo(0));
Assert.That(SearchBuilder.Parse(new[] {"body"}, "kit*", false).Count(), Is.EqualTo(2));
Assert.That(SearchBuilder.Parse(new[] {"body", "title"}, "bradley love^3 soap", false).Count(), Is.EqualTo(3));
Assert.That(SearchBuilder.Parse(new[] {"body", "title"}, "bradley love^3 soap", false).Search().First().ContentItemId, Is.EqualTo(2));
}
[Test]
@@ -267,11 +388,11 @@ namespace Orchard.Tests.Modules.Indexing {
_provider.Store("default", _provider.New(3).Add("body", "Bertrand is a little bit jealous.").Analyze().Add("title", "Soap opera").Analyze());
// specifying a field to match
Assert.That(_searchBuilder.Parse(new[] { "body" }, "title:bradley", false).Search().Count(), Is.EqualTo(0));
Assert.That(_searchBuilder.Parse(new[] { "body" }, "title:s*", false).Search().Count(), Is.EqualTo(1));
Assert.That(SearchBuilder.Parse(new[] { "body" }, "title:bradley", false).Search().Count(), Is.EqualTo(0));
Assert.That(SearchBuilder.Parse(new[] { "body" }, "title:s*", false).Search().Count(), Is.EqualTo(1));
// checking terms fall back to the default fields
Assert.That(_searchBuilder.Parse(new[] { "body" }, "title:bradley bradley", false).Search().Count(), Is.EqualTo(1));
Assert.That(SearchBuilder.Parse(new[] { "body" }, "title:bradley bradley", false).Search().Count(), Is.EqualTo(1));
}
[Test]
@@ -281,13 +402,13 @@ namespace Orchard.Tests.Modules.Indexing {
_provider.Store("default", _provider.New(2).Add("field", 22));
_provider.Store("default", _provider.New(3).Add("field", 333));
Assert.That(_searchBuilder.WithField("field", 1).ExactMatch().Count(), Is.EqualTo(1));
Assert.That(_searchBuilder.WithField("field", 22).ExactMatch().Count(), Is.EqualTo(1));
Assert.That(_searchBuilder.WithField("field", 333).ExactMatch().Count(), Is.EqualTo(1));
Assert.That(SearchBuilder.WithField("field", 1).ExactMatch().Count(), Is.EqualTo(1));
Assert.That(SearchBuilder.WithField("field", 22).ExactMatch().Count(), Is.EqualTo(1));
Assert.That(SearchBuilder.WithField("field", 333).ExactMatch().Count(), Is.EqualTo(1));
Assert.That(_searchBuilder.WithField("field", 0).ExactMatch().Count(), Is.EqualTo(0));
Assert.That(_searchBuilder.WithField("field", 2).ExactMatch().Count(), Is.EqualTo(0));
Assert.That(_searchBuilder.WithField("field", 3).ExactMatch().Count(), Is.EqualTo(0));
Assert.That(SearchBuilder.WithField("field", 0).ExactMatch().Count(), Is.EqualTo(0));
Assert.That(SearchBuilder.WithField("field", 2).ExactMatch().Count(), Is.EqualTo(0));
Assert.That(SearchBuilder.WithField("field", 3).ExactMatch().Count(), Is.EqualTo(0));
}
[Test]
@@ -297,13 +418,13 @@ namespace Orchard.Tests.Modules.Indexing {
_provider.Store("default", _provider.New(2).Add("field", 22).Store());
_provider.Store("default", _provider.New(3).Add("field", 333).Store());
Assert.That(_searchBuilder.WithField("field", 1).ExactMatch().Count(), Is.EqualTo(1));
Assert.That(_searchBuilder.WithField("field", 22).ExactMatch().Count(), Is.EqualTo(1));
Assert.That(_searchBuilder.WithField("field", 333).ExactMatch().Count(), Is.EqualTo(1));
Assert.That(SearchBuilder.WithField("field", 1).ExactMatch().Count(), Is.EqualTo(1));
Assert.That(SearchBuilder.WithField("field", 22).ExactMatch().Count(), Is.EqualTo(1));
Assert.That(SearchBuilder.WithField("field", 333).ExactMatch().Count(), Is.EqualTo(1));
Assert.That(_searchBuilder.WithField("field", 0).ExactMatch().Count(), Is.EqualTo(0));
Assert.That(_searchBuilder.WithField("field", 2).ExactMatch().Count(), Is.EqualTo(0));
Assert.That(_searchBuilder.WithField("field", 3).ExactMatch().Count(), Is.EqualTo(0));
Assert.That(SearchBuilder.WithField("field", 0).ExactMatch().Count(), Is.EqualTo(0));
Assert.That(SearchBuilder.WithField("field", 2).ExactMatch().Count(), Is.EqualTo(0));
Assert.That(SearchBuilder.WithField("field", 3).ExactMatch().Count(), Is.EqualTo(0));
}
[Test]
@@ -324,21 +445,21 @@ namespace Orchard.Tests.Modules.Indexing {
_provider.Store("default", _provider.New(2).Add("body", "Windows a été développé par Microsoft en C++").Analyze().Add("culture", 1036));
_provider.Store("default", _provider.New(3).Add("title", "Home").Analyze().Add("culture", 1033));
Assert.That(_searchBuilder.WithField("body", "Microsoft").Count(), Is.EqualTo(2));
Assert.That(_searchBuilder.WithField("body", "Microsoft").WithField("culture", 1033).Count(), Is.EqualTo(3));
Assert.That(_searchBuilder.WithField("body", "Microsoft").WithField("culture", 1033).AsFilter().Count(), Is.EqualTo(1));
Assert.That(SearchBuilder.WithField("body", "Microsoft").Count(), Is.EqualTo(2));
Assert.That(SearchBuilder.WithField("body", "Microsoft").WithField("culture", 1033).Count(), Is.EqualTo(3));
Assert.That(SearchBuilder.WithField("body", "Microsoft").WithField("culture", 1033).AsFilter().Count(), Is.EqualTo(1));
Assert.That(_searchBuilder.WithField("body", "Orchard").WithField("culture", 1036).Count(), Is.EqualTo(2));
Assert.That(_searchBuilder.WithField("body", "Orchard").WithField("culture", 1036).AsFilter().Count(), Is.EqualTo(0));
Assert.That(SearchBuilder.WithField("body", "Orchard").WithField("culture", 1036).Count(), Is.EqualTo(2));
Assert.That(SearchBuilder.WithField("body", "Orchard").WithField("culture", 1036).AsFilter().Count(), Is.EqualTo(0));
Assert.That(_searchBuilder.WithField("culture", 1033).Count(), Is.EqualTo(2));
Assert.That(_searchBuilder.WithField("culture", 1033).AsFilter().Count(), Is.EqualTo(2));
Assert.That(SearchBuilder.WithField("culture", 1033).Count(), Is.EqualTo(2));
Assert.That(SearchBuilder.WithField("culture", 1033).AsFilter().Count(), Is.EqualTo(2));
Assert.That(_searchBuilder.WithField("body", "blabla").WithField("culture", 1033).Count(), Is.EqualTo(2));
Assert.That(_searchBuilder.WithField("body", "blabla").WithField("culture", 1033).AsFilter().Count(), Is.EqualTo(0));
Assert.That(SearchBuilder.WithField("body", "blabla").WithField("culture", 1033).Count(), Is.EqualTo(2));
Assert.That(SearchBuilder.WithField("body", "blabla").WithField("culture", 1033).AsFilter().Count(), Is.EqualTo(0));
Assert.That(_searchBuilder.Parse("title", "home").Count(), Is.EqualTo(1));
Assert.That(_searchBuilder.Parse("title", "home").WithField("culture", 1033).AsFilter().Count(), Is.EqualTo(1));
Assert.That(SearchBuilder.Parse("title", "home").Count(), Is.EqualTo(1));
Assert.That(SearchBuilder.Parse("title", "home").WithField("culture", 1033).AsFilter().Count(), Is.EqualTo(1));
}
[Test]
@@ -346,7 +467,7 @@ namespace Orchard.Tests.Modules.Indexing {
_provider.CreateIndex("default");
_provider.Store("default", _provider.New(1).Add("body", "foo.bar").Analyze());
Assert.That(_searchBuilder.Parse("body", "*@!woo*@!").Count(), Is.EqualTo(0));
Assert.That(SearchBuilder.Parse("body", "*@!woo*@!").Count(), Is.EqualTo(0));
}
[Test]
@@ -362,17 +483,17 @@ namespace Orchard.Tests.Modules.Indexing {
_provider.Store("default", documentIndex);
Assert.That(_searchBuilder.WithField("tag-id", 0).Count(), Is.EqualTo(0));
Assert.That(_searchBuilder.WithField("tag-id", 1).Count(), Is.EqualTo(1));
Assert.That(_searchBuilder.WithField("tag-id", 2).Count(), Is.EqualTo(1));
Assert.That(_searchBuilder.WithField("tag-id", 3).Count(), Is.EqualTo(1));
Assert.That(SearchBuilder.WithField("tag-id", 0).Count(), Is.EqualTo(0));
Assert.That(SearchBuilder.WithField("tag-id", 1).Count(), Is.EqualTo(1));
Assert.That(SearchBuilder.WithField("tag-id", 2).Count(), Is.EqualTo(1));
Assert.That(SearchBuilder.WithField("tag-id", 3).Count(), Is.EqualTo(1));
Assert.That(_searchBuilder.WithField("tag-value", "tag").ExactMatch().Count(), Is.EqualTo(0));
Assert.That(_searchBuilder.WithField("tag-value", "tag1").ExactMatch().Count(), Is.EqualTo(1));
Assert.That(_searchBuilder.WithField("tag-value", "tag2").ExactMatch().Count(), Is.EqualTo(1));
Assert.That(_searchBuilder.WithField("tag-value", "tag3").ExactMatch().Count(), Is.EqualTo(1));
Assert.That(SearchBuilder.WithField("tag-value", "tag").ExactMatch().Count(), Is.EqualTo(0));
Assert.That(SearchBuilder.WithField("tag-value", "tag1").ExactMatch().Count(), Is.EqualTo(1));
Assert.That(SearchBuilder.WithField("tag-value", "tag2").ExactMatch().Count(), Is.EqualTo(1));
Assert.That(SearchBuilder.WithField("tag-value", "tag3").ExactMatch().Count(), Is.EqualTo(1));
Assert.That(_searchBuilder.WithField("tag-value", "tag").Count(), Is.EqualTo(1));
Assert.That(SearchBuilder.WithField("tag-value", "tag").Count(), Is.EqualTo(1));
}
[Test]
@@ -385,12 +506,12 @@ namespace Orchard.Tests.Modules.Indexing {
_provider.Store("default", documentIndex);
// trying in prefix mode
Assert.That(_searchBuilder.WithField("tag-value", "tag").Count(), Is.EqualTo(1));
Assert.That(_searchBuilder.WithField("tag-value", "Tag").Count(), Is.EqualTo(1));
Assert.That(SearchBuilder.WithField("tag-value", "tag").Count(), Is.EqualTo(1));
Assert.That(SearchBuilder.WithField("tag-value", "Tag").Count(), Is.EqualTo(1));
// trying in full word match mode
Assert.That(_searchBuilder.WithField("tag-value", "tag1").ExactMatch().Count(), Is.EqualTo(1));
Assert.That(_searchBuilder.WithField("tag-value", "Tag1").ExactMatch().Count(), Is.EqualTo(1));
Assert.That(SearchBuilder.WithField("tag-value", "tag1").ExactMatch().Count(), Is.EqualTo(1));
Assert.That(SearchBuilder.WithField("tag-value", "Tag1").ExactMatch().Count(), Is.EqualTo(1));
}
[Test]
@@ -404,12 +525,12 @@ namespace Orchard.Tests.Modules.Indexing {
_provider.Store("default", documentIndex);
// a value which is not analyzed, is not lowered cased in the index
Assert.That(_searchBuilder.WithField("tag-valueL", "tag").Count(), Is.EqualTo(1));
Assert.That(_searchBuilder.WithField("tag-valueU", "tag").Count(), Is.EqualTo(0));
Assert.That(_searchBuilder.WithField("tag-valueL", "Tag").Count(), Is.EqualTo(1)); // queried term is lower cased
Assert.That(_searchBuilder.WithField("tag-valueU", "Tag").Count(), Is.EqualTo(0)); // queried term is lower cased
Assert.That(_searchBuilder.WithField("tag-valueL", "tag1").ExactMatch().Count(), Is.EqualTo(1));
Assert.That(_searchBuilder.WithField("tag-valueU", "tag1").ExactMatch().Count(), Is.EqualTo(0));
Assert.That(SearchBuilder.WithField("tag-valueL", "tag").Count(), Is.EqualTo(1));
Assert.That(SearchBuilder.WithField("tag-valueU", "tag").Count(), Is.EqualTo(0));
Assert.That(SearchBuilder.WithField("tag-valueL", "Tag").Count(), Is.EqualTo(1)); // queried term is lower cased
Assert.That(SearchBuilder.WithField("tag-valueU", "Tag").Count(), Is.EqualTo(0)); // queried term is lower cased
Assert.That(SearchBuilder.WithField("tag-valueL", "tag1").ExactMatch().Count(), Is.EqualTo(1));
Assert.That(SearchBuilder.WithField("tag-valueU", "tag1").ExactMatch().Count(), Is.EqualTo(0));
}
[Test]
@@ -419,7 +540,7 @@ namespace Orchard.Tests.Modules.Indexing {
_provider.Store("default", _provider.New(i).Add("term-id", i).Store());
}
Assert.That(_searchBuilder.Count(), Is.EqualTo(99));
Assert.That(SearchBuilder.Count(), Is.EqualTo(99));
}
[Test]
@@ -429,12 +550,12 @@ namespace Orchard.Tests.Modules.Indexing {
_provider.Store("default", _provider.New(i).Add("term-id", i / 10).Store());
}
Assert.That(_searchBuilder.Count(), Is.EqualTo(49));
Assert.That(_searchBuilder.WithField("term-id", 0).ExactMatch().AsFilter().Count(), Is.EqualTo(9));
Assert.That(_searchBuilder.WithField("term-id", 1).ExactMatch().AsFilter().Count(), Is.EqualTo(10));
Assert.That(_searchBuilder.WithField("term-id", 2).ExactMatch().AsFilter().Count(), Is.EqualTo(10));
Assert.That(_searchBuilder.WithField("term-id", 3).ExactMatch().AsFilter().Count(), Is.EqualTo(10));
Assert.That(_searchBuilder.WithField("term-id", 4).ExactMatch().AsFilter().Count(), Is.EqualTo(10));
Assert.That(SearchBuilder.Count(), Is.EqualTo(49));
Assert.That(SearchBuilder.WithField("term-id", 0).ExactMatch().AsFilter().Count(), Is.EqualTo(9));
Assert.That(SearchBuilder.WithField("term-id", 1).ExactMatch().AsFilter().Count(), Is.EqualTo(10));
Assert.That(SearchBuilder.WithField("term-id", 2).ExactMatch().AsFilter().Count(), Is.EqualTo(10));
Assert.That(SearchBuilder.WithField("term-id", 3).ExactMatch().AsFilter().Count(), Is.EqualTo(10));
Assert.That(SearchBuilder.WithField("term-id", 4).ExactMatch().AsFilter().Count(), Is.EqualTo(10));
}
[Test]
@@ -462,10 +583,10 @@ namespace Orchard.Tests.Modules.Indexing {
);
Assert.That(_searchBuilder.WithField("field1", 0).Mandatory().Count(), Is.EqualTo(0));
Assert.That(_searchBuilder.WithField("field1", 1).Mandatory().Count(), Is.EqualTo(3));
Assert.That(_searchBuilder.WithField("field1", 1).Mandatory().WithField("field2", 2).Mandatory().Count(), Is.EqualTo(2));
Assert.That(_searchBuilder.WithField("field1", 1).Mandatory().WithField("field2", 2).Mandatory().WithField("field3", 3).Mandatory().Count(), Is.EqualTo(1));
Assert.That(SearchBuilder.WithField("field1", 0).Mandatory().Count(), Is.EqualTo(0));
Assert.That(SearchBuilder.WithField("field1", 1).Mandatory().Count(), Is.EqualTo(3));
Assert.That(SearchBuilder.WithField("field1", 1).Mandatory().WithField("field2", 2).Mandatory().Count(), Is.EqualTo(2));
Assert.That(SearchBuilder.WithField("field1", 1).Mandatory().WithField("field2", 2).Mandatory().WithField("field3", 3).Mandatory().Count(), Is.EqualTo(1));
}
[Test]
@@ -492,9 +613,18 @@ namespace Orchard.Tests.Modules.Indexing {
.Add("field3", 3)
);
Assert.That(_searchBuilder.WithField("field1", 1).Count(), Is.EqualTo(3));
Assert.That(_searchBuilder.WithField("field1", 1).WithField("field2", 2).AsFilter().Count(), Is.EqualTo(2));
Assert.That(_searchBuilder.WithField("field1", 1).WithField("field2", 2).Mandatory().AsFilter().WithField("field3", 3).Mandatory().AsFilter().Count(), Is.EqualTo(1));
Assert.That(SearchBuilder.WithField("field1", 1).Count(), Is.EqualTo(3));
Assert.That(SearchBuilder
.WithField("field1", 1)
.WithField("field2", 2).AsFilter()
.Count(), Is.EqualTo(2));
Assert.That(SearchBuilder
.WithField("field1", 1)
.WithField("field2", 2).Mandatory().AsFilter()
.WithField("field3", 3).Mandatory().AsFilter()
.Count(), Is.EqualTo(1));
}
}
}

View File

@@ -17,15 +17,15 @@ using Orchard.Data.Conventions;
using Orchard.Data.Migration.Generator;
using Orchard.Data.Migration.Interpreters;
using Orchard.Data.Migration.Schema;
using Orchard.Environment.Compilation.Dependencies;
using Orchard.Environment.Compilation.Loaders;
using Orchard.Environment.Configuration;
using Orchard.Environment.Extensions;
using Orchard.Environment.Extensions.Folders;
using Orchard.Environment.Extensions.Loaders;
using Orchard.Environment.Extensions.Models;
using Orchard.Environment.ShellBuilders;
using Orchard.Environment.ShellBuilders.Models;
using Orchard.FileSystems.AppData;
using Orchard.FileSystems.Dependencies;
using Orchard.Tests.ContentManagement;
using Orchard.Data.Providers;
using Orchard.Tests.DataMigration.Utilities;

View File

@@ -3,11 +3,11 @@ using Autofac;
using Moq;
using NuGet;
using NUnit.Framework;
using Orchard.AspNet.Abstractions;
using Orchard.Caching;
using Orchard.Environment;
using Orchard.Environment.Extensions;
using Orchard.Environment.Extensions.Models;
using Orchard.FileSystems.VirtualPath;
using Orchard.FileSystems.WebSite;
using Orchard.Packaging.Services;
using Orchard.Tests.Stubs;

View File

@@ -3,9 +3,9 @@ using System.IO;
using System.IO.Packaging;
using Autofac;
using NUnit.Framework;
using Orchard.AspNet.Abstractions;
using Orchard.Environment;
using Orchard.Environment.Extensions.Models;
using Orchard.FileSystems.VirtualPath;
using Orchard.FileSystems.WebSite;
using Orchard.Packaging.Services;
using Orchard.Tests.Stubs;

View File

@@ -3,11 +3,11 @@ using Autofac;
using Moq;
using NuGet;
using NUnit.Framework;
using Orchard.AspNet.Abstractions;
using Orchard.Caching;
using Orchard.Environment;
using Orchard.Environment.Extensions;
using Orchard.Environment.Extensions.Models;
using Orchard.FileSystems.VirtualPath;
using Orchard.FileSystems.WebSite;
using Orchard.Packaging.Services;
using Orchard.Tests.Stubs;

View File

@@ -5,6 +5,7 @@ using System.Web.Hosting;
using System.Xml.Linq;
using Autofac;
using NUnit.Framework;
using Orchard.AspNet.Abstractions;
using Orchard.Caching;
using Orchard.Core.Settings.Descriptor;
using Orchard.Core.Settings.Descriptor.Records;
@@ -18,7 +19,7 @@ using Orchard.Environment.Extensions.Models;
using Orchard.Environment.Features;
using Orchard.Environment.State;
using Orchard.Events;
using Orchard.FileSystems.VirtualPath;
using Orchard.FileSystems.WebSite;
using Orchard.Packaging.Services;
using Orchard.Recipes.Models;
using Orchard.Recipes.RecipeHandlers;
@@ -61,6 +62,8 @@ namespace Orchard.Tests.Modules.Recipes.RecipeHandlers {
builder.RegisterType<ModuleRecipeHandlerTest.StubPackageManager>().As<IPackageManager>();
builder.RegisterType<ShellStateManager>().As<IShellStateManager>().SingleInstance();
builder.RegisterInstance(_testVirtualPathProvider).As<IVirtualPathProvider>();
builder.RegisterType<WebSiteFolder>().As<IWebSiteFolder>();
builder.RegisterType<DefaultVirtualPathMonitor>().As<IVirtualPathMonitor>();
builder.RegisterType<StubEventBus>().As<IEventBus>().SingleInstance();
builder.RegisterType<ThemeService>().As<IThemeService>();
builder.RegisterType<StubOrchardServices>().As<IOrchardServices>();

View File

@@ -5,15 +5,15 @@ using System.Xml;
using Autofac;
using NUnit.Framework;
using Orchard.Caching;
using Orchard.Environment.Compilation.Loaders;
using Orchard.Environment.Extensions;
using Orchard.Environment.Extensions.Folders;
using Orchard.Environment.Extensions.Loaders;
using Orchard.FileSystems.AppData;
using Orchard.FileSystems.WebSite;
using Orchard.Recipes.Models;
using Orchard.Recipes.Services;
using Orchard.Services;
using Orchard.Tests.Stubs;
using Orchard.Time;
namespace Orchard.Tests.Modules.Recipes.Services {
[TestFixture]
@@ -107,7 +107,7 @@ namespace Orchard.Tests.Modules.Recipes.Services {
}
[Test]
public void ParseRecipeLoadsRecipeMetaDataIntoModel() {
public void ParseRecipeLoadsRecipeMetadataIntoModel() {
var recipes = (List<Recipe>) _recipeHarvester.HarvestRecipes("Sample1");
Assert.That(recipes.Count, Is.EqualTo(1));

View File

@@ -10,9 +10,9 @@ using NUnit.Framework;
using Orchard.Caching;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.MetaData.Models;
using Orchard.ContentManagement.MetaData.Services;
using Orchard.ContentManagement.Definition;
using Orchard.ContentManagement.Definition.Models;
using Orchard.ContentManagement.Definition.Services;
using Orchard.ContentManagement.Records;
using Orchard.Core.Settings.Descriptor.Records;
using Orchard.Core.Settings.Handlers;

View File

@@ -8,9 +8,9 @@ using Autofac;
using Moq;
using NUnit.Framework;
using Orchard.Caching;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.MetaData.Models;
using Orchard.ContentManagement.MetaData.Services;
using Orchard.ContentManagement.Definition;
using Orchard.ContentManagement.Definition.Models;
using Orchard.ContentManagement.Definition.Services;
using Orchard.Core.Settings.Metadata;
using Orchard.Data;
using Orchard.DisplayManagement;
@@ -53,9 +53,7 @@ namespace Orchard.Tests.Modules.Users.Controllers {
builder.RegisterType<AccountController>().SingleInstance();
builder.RegisterType<SiteService>().As<ISiteService>();
builder.RegisterType<DefaultContentManager>().As<IContentManager>();
builder.RegisterType(typeof(SettingsFormatter))
.As(typeof(IMapper<XElement, SettingsDictionary>))
.As(typeof(IMapper<SettingsDictionary, XElement>));
builder.RegisterType(typeof(SettingsFormatter)).As<ISettingsFormatter>();
builder.RegisterType<ContentDefinitionManager>().As<IContentDefinitionManager>();
builder.RegisterType<DefaultContentManagerSession>().As<IContentManagerSession>();
builder.RegisterType<DefaultContentQuery>().As<IContentQuery>().InstancePerDependency();

View File

@@ -5,9 +5,9 @@ using Autofac;
using Moq;
using NHibernate;
using NUnit.Framework;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.MetaData.Models;
using Orchard.ContentManagement.MetaData.Services;
using Orchard.ContentManagement.Definition;
using Orchard.ContentManagement.Definition.Models;
using Orchard.ContentManagement.Definition.Services;
using Orchard.Core.Settings.Metadata;
using Orchard.Data;
using Orchard.ContentManagement;
@@ -71,9 +71,7 @@ namespace Orchard.Tests.Modules.Users.Services {
builder.RegisterType<MembershipService>().As<IMembershipService>();
builder.RegisterType<DefaultContentQuery>().As<IContentQuery>();
builder.RegisterType<DefaultContentManager>().As<IContentManager>();
builder.RegisterType(typeof(SettingsFormatter))
.As(typeof(IMapper<XElement, SettingsDictionary>))
.As(typeof(IMapper<SettingsDictionary, XElement>));
builder.RegisterType(typeof(SettingsFormatter)).As<ISettingsFormatter>();
builder.RegisterType<ContentDefinitionManager>().As<IContentDefinitionManager>();
builder.RegisterType<DefaultContentManagerSession>().As<IContentManagerSession>();
builder.RegisterType<UserPartHandler>().As<IContentHandler>();

View File

@@ -6,9 +6,9 @@ using Autofac;
using Moq;
using NHibernate;
using NUnit.Framework;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.MetaData.Models;
using Orchard.ContentManagement.MetaData.Services;
using Orchard.ContentManagement.Definition;
using Orchard.ContentManagement.Definition.Models;
using Orchard.ContentManagement.Definition.Services;
using Orchard.Core.Settings.Metadata;
using Orchard.Data;
using Orchard.ContentManagement;
@@ -25,6 +25,7 @@ using Orchard.Security;
using Orchard.Security.Providers;
using Orchard.Tests.Stubs;
using Orchard.Tests.Utility;
using Orchard.Time;
using Orchard.Users.Handlers;
using Orchard.Users.Models;
using Orchard.Users.Services;
@@ -76,15 +77,13 @@ namespace Orchard.Tests.Modules.Users.Services {
[SetUp]
public void Init() {
var builder = new ContainerBuilder();
//builder.RegisterModule(new ImplicitCollectionSupportModule());
builder.RegisterType<MembershipService>().As<IMembershipService>();
builder.RegisterType<UserService>().As<IUserService>();
builder.RegisterInstance(_clock = new StubClock()).As<IClock>();
builder.RegisterType<DefaultContentQuery>().As<IContentQuery>();
builder.RegisterType<DefaultContentManager>().As<IContentManager>();
builder.RegisterType(typeof(SettingsFormatter))
.As(typeof(IMapper<XElement, SettingsDictionary>))
.As(typeof(IMapper<SettingsDictionary, XElement>));
builder.RegisterType(typeof(SettingsFormatter)).As<ISettingsFormatter>();
builder.RegisterType<ContentDefinitionManager>().As<IContentDefinitionManager>();
builder.RegisterType<DefaultContentManagerSession>().As<IContentManagerSession>();
builder.RegisterType<UserPartHandler>().As<IContentHandler>();

View File

@@ -1,6 +1,5 @@
using System.Security.Cryptography;
using Orchard.Environment.Configuration;
using Orchard.Utility.Extensions;
namespace Orchard.Tests.Modules.Users {
public class ShellSettingsUtility {

View File

@@ -9,11 +9,12 @@ using NUnit.Framework;
using Orchard.Environment.Configuration;
using Orchard.Environment.Warmup;
using Orchard.FileSystems.AppData;
using Orchard.FileSystems.LockFile;
using Orchard.Locking;
using Orchard.Services;
using Orchard.Tests.FileSystems.AppData;
using Orchard.Tests.Stubs;
using Orchard.Tests.UI.Navigation;
using Orchard.Time;
using Orchard.Warmup.Models;
using Orchard.Warmup.Services;
@@ -22,7 +23,7 @@ namespace Orchard.Tests.Modules.Warmup {
protected IContainer _container;
private IWarmupUpdater _warmupUpdater;
private IAppDataFolder _appDataFolder;
private ILockFileManager _lockFileManager;
private ILockManager _lockManager;
private StubClock _clock;
private Mock<IWebDownloader> _webDownloader;
private IOrchardServices _orchardServices;
@@ -60,7 +61,7 @@ namespace Orchard.Tests.Modules.Warmup {
var builder = new ContainerBuilder();
builder.RegisterInstance(_appDataFolder).As<IAppDataFolder>();
builder.RegisterInstance(_orchardServices).As<IOrchardServices>();
builder.RegisterType<DefaultLockFileManager>().As<ILockFileManager>();
builder.RegisterType<DefaultLockManager>().As<ILockManager>();
builder.RegisterType<WarmupUpdater>().As<IWarmupUpdater>();
builder.RegisterType<StubClock>().As<IClock>();
builder.RegisterType<WarmupReportManager>().As<IWarmupReportManager>();
@@ -69,7 +70,7 @@ namespace Orchard.Tests.Modules.Warmup {
builder.RegisterInstance(_webDownloader.Object).As<IWebDownloader>();
_container = builder.Build();
_lockFileManager = _container.Resolve<ILockFileManager>();
_lockManager = _container.Resolve<ILockManager>();
_warmupUpdater = _container.Resolve<IWarmupUpdater>();
_reportManager = _container.Resolve<IWarmupReportManager>();
@@ -85,17 +86,17 @@ namespace Orchard.Tests.Modules.Warmup {
[Test]
public void StampFileShouldBeDeletedToForceAnUpdate() {
_appDataFolder.CreateFile(_warmupFilename, "");
_appDataFolder.StoreFile(_warmupFilename, "");
_warmupUpdater.Generate();
Assert.That(_appDataFolder.ListFiles(WarmupFolder).Count(), Is.EqualTo(0));
}
[Test]
public void GenerateShouldNotRunIfLocked() {
_appDataFolder.CreateFile(_warmupFilename, "");
ILockFile lockFile = null;
_lockFileManager.TryAcquireLock(_lockFilename, ref lockFile);
using(lockFile) {
_appDataFolder.StoreFile(_warmupFilename, "");
var @lock = _lockManager.TryLock(_lockFilename);
using (@lock) {
_warmupUpdater.Generate();
Assert.That(_appDataFolder.ListFiles(WarmupFolder).Count(), Is.EqualTo(0));
}
@@ -325,7 +326,7 @@ namespace Orchard.Tests.Modules.Warmup {
.Returns(new DownloadResult { Content = "Bar", StatusCode = HttpStatusCode.OK });
// Create a static file in the warmup folder
_appDataFolder.CreateFile(_appDataFolder.Combine(WarmupFolder, "foo.txt"), "Foo");
_appDataFolder.StoreFile(_appDataFolder.Combine(WarmupFolder, "foo.txt"), "Foo");
_warmupUpdater.Generate();
var files = _appDataFolder.ListFiles(WarmupFolder).ToList();

View File

@@ -6,7 +6,7 @@ using Moq;
using NUnit.Framework;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.Definition;
using Orchard.ContentManagement.Records;
using Orchard.Core.Common.Models;
using Orchard.Core.Settings.Metadata.Records;

View File

@@ -17,8 +17,8 @@ namespace Orchard.Tests.Modules.XmlRpc.Controllers {
var builder = new ContainerBuilder();
//builder.RegisterModule(new ImplicitCollectionSupportModule());
builder.RegisterType<HomeController>();
builder.RegisterType<XmlRpcReader>().As<IMapper<XElement, XRpcMethodCall>>();
builder.RegisterType<XmlRpcWriter>().As<IMapper<XRpcMethodResponse, XElement>>();
builder.RegisterType<XmlRpcReader>().As<IXmlRpcReader>();
builder.RegisterType<XmlRpcWriter>().As<IXmlRpcWriter>();
builder.RegisterInstance(thing1).As<IXmlRpcHandler>();
builder.RegisterInstance(thing2).As<IXmlRpcHandler>();

View File

@@ -17,8 +17,8 @@ namespace Orchard.Tests.Modules.XmlRpc.Controllers {
var builder = new ContainerBuilder();
builder.RegisterType<LiveWriterController>();
builder.RegisterType<XmlRpcReader>().As<IMapper<XElement, XRpcMethodCall>>();
builder.RegisterType<XmlRpcWriter>().As<IMapper<XRpcMethodResponse, XElement>>();
builder.RegisterType<XmlRpcReader>().As<IXmlRpcReader>();
builder.RegisterType<XmlRpcWriter>().As<IXmlRpcWriter>();
builder.RegisterInstance(thing).As<IXmlRpcHandler>();
builder.RegisterInstance(thingToo).As<IXmlRpcHandler>();

View File

@@ -1,22 +1,16 @@
using System;
using System.Xml.Linq;
using NUnit.Framework;
using Orchard.Core.XmlRpc.Models;
using Orchard.Core.XmlRpc.Services;
namespace Orchard.Tests.Modules.XmlRpc.Services {
[TestFixture]
public class XmlRpcReaderTests {
private IMapper<XElement, XRpcMethodCall> _methodCallMapper;
private IMapper<XElement, XRpcStruct> _structMapper;
private IMapper<XElement, XRpcArray> _arrayMapper;
private IXmlRpcReader _xmlRpcReader;
[SetUp]
public void Init() {
var mapper = new XmlRpcReader();
_methodCallMapper = mapper;
_structMapper = mapper;
_arrayMapper = mapper;
_xmlRpcReader = new XmlRpcReader();
}
[Test]
@@ -26,7 +20,7 @@ namespace Orchard.Tests.Modules.XmlRpc.Services {
<methodName>hello world</methodName>
</methodCall>");
var methodCall = _methodCallMapper.Map(source);
var methodCall = _xmlRpcReader.MapToMethodCall(source);
Assert.That(methodCall, Is.Not.Null);
Assert.That(methodCall.MethodName, Is.EqualTo("hello world"));
}
@@ -48,7 +42,7 @@ namespace Orchard.Tests.Modules.XmlRpc.Services {
</params>
</methodCall>");
var methodCall = _methodCallMapper.Map(source);
var methodCall = _xmlRpcReader.MapToMethodCall(source);
Assert.That(methodCall, Is.Not.Null);
Assert.That(methodCall.Params, Has.Count.EqualTo(8));
Assert.That(methodCall.Params[0].Value, Is.EqualTo(-12));
@@ -57,7 +51,7 @@ namespace Orchard.Tests.Modules.XmlRpc.Services {
Assert.That(methodCall.Params[3].Value, Is.EqualTo(false));
Assert.That(methodCall.Params[4].Value, Is.EqualTo("hello world"));
Assert.That(methodCall.Params[5].Value, Is.EqualTo(-12.214));
Assert.That(methodCall.Params[6].Value, Is.EqualTo(new DateTime(1998,7,17,14,8,55)));
Assert.That(methodCall.Params[6].Value, Is.EqualTo(new DateTime(1998, 7, 17, 14, 8, 55)));
Assert.That(methodCall.Params[7].Value, Is.EqualTo(Convert.FromBase64String("eW91IGNhbid0IHJlYWQgdGhpcyE=")));
}
@@ -75,7 +69,7 @@ namespace Orchard.Tests.Modules.XmlRpc.Services {
<member><name>eight</name><value><base64>eW91IGNhbid0IHJlYWQgdGhpcyE=</base64></value></member>
</struct>");
var xmlStruct = _structMapper.Map(source);
var xmlStruct = _xmlRpcReader.MapToStruct(source);
Assert.That(xmlStruct["one"], Is.EqualTo(-12));
Assert.That(xmlStruct["two"], Is.EqualTo(42));
Assert.That(xmlStruct["three"], Is.EqualTo(true));
@@ -94,7 +88,7 @@ namespace Orchard.Tests.Modules.XmlRpc.Services {
<member><name>seven</name><value><dateTime.iso8601>FOO</dateTime.iso8601></value></member>
</struct>");
var xmlStruct = _structMapper.Map(source);
var xmlStruct = _xmlRpcReader.MapToStruct(source);
Assert.That(xmlStruct["seven"], Is.GreaterThan(DateTime.Now.AddSeconds(-1)));
Assert.That(xmlStruct["seven"], Is.LessThan(DateTime.Now.AddSeconds(1)));
}
@@ -112,7 +106,7 @@ namespace Orchard.Tests.Modules.XmlRpc.Services {
</array>
");
var xmlArray = _arrayMapper.Map(source);
var xmlArray = _xmlRpcReader.MapToArray(source);
Assert.That(xmlArray.Data, Has.Count.EqualTo(4));
Assert.That(xmlArray[0], Is.EqualTo(12));
Assert.That(xmlArray[1], Is.EqualTo("Egypt"));

View File

@@ -9,11 +9,10 @@ namespace Orchard.Tests.Modules.XmlRpc.Services {
[Test]
public void MethodResponseWriterShouldSendParametersWithValues() {
var mapper = new XmlRpcWriter();
IMapper<XRpcMethodResponse, XElement> resposeMapper = mapper;
var response = new XRpcMethodResponse();
response.Params.Add(new XRpcData<int> { Value = 42 });
var element = resposeMapper.Map(response);
var element = mapper.MapMethodResponse(response);
Assert.That(NoSpace(element.ToString()), Is.EqualTo("<methodResponse><params><param><value><int>42</int></value></param></params></methodResponse>"));
}
@@ -21,7 +20,6 @@ namespace Orchard.Tests.Modules.XmlRpc.Services {
[Test]
public void ArrayAndStructShouldWorkAsExpected() {
var mapper = new XmlRpcWriter();
IMapper<XRpcArray, XElement> arrayMapper = mapper;
var arr = new XRpcArray();
var structParam = XRpcData.For(new XRpcStruct());
@@ -31,7 +29,7 @@ namespace Orchard.Tests.Modules.XmlRpc.Services {
structParam.Value.Members.Add("Hello", XRpcData.For("world"));
var element = arrayMapper.Map(arr);
var element = mapper.MapArray(arr);
Assert.That(NoSpace(element.ToString()), Is.EqualTo(NoSpace(@"
<array><data>

View File

@@ -5,6 +5,7 @@ using Autofac;
using Orchard.FileSystems.AppData;
using Orchard.FileSystems.WebSite;
using Orchard.Services;
using Orchard.Time;
namespace Orchard.Tests.Caching {
[TestFixture]

View File

@@ -4,6 +4,7 @@ using NUnit.Framework;
using Orchard.Caching;
using Orchard.Services;
using Orchard.Tests.Stubs;
using Orchard.Time;
namespace Orchard.Tests.Caching {
[TestFixture]

View File

@@ -3,7 +3,7 @@ using Autofac;
using Moq;
using NHibernate;
using NUnit.Framework;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.Definition;
using Orchard.Data;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers;

View File

@@ -5,9 +5,8 @@ using Autofac;
using Moq;
using NHibernate;
using NUnit.Framework;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.MetaData.Builders;
using Orchard.ContentManagement.MetaData.Models;
using Orchard.ContentManagement.Definition;
using Orchard.ContentManagement.Definition.Builders;
using Orchard.Data;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers;
@@ -19,7 +18,6 @@ using Orchard.Tests.ContentManagement.Models;
using Orchard.DisplayManagement.Descriptors;
using Orchard.DisplayManagement.Implementation;
using Orchard.DisplayManagement;
using System.Collections.Generic;
using Orchard.Tests.Stubs;
namespace Orchard.Tests.ContentManagement {
@@ -177,41 +175,6 @@ namespace Orchard.Tests.ContentManagement {
Assert.That(modelRecord.ContentType.Name, Is.EqualTo(DefaultBetaName));
}
/// <summary>
/// Tests that the GetContentTypeDefinitions returns only the registered types.
/// </summary>
[Test]
public void GetContentTypesShouldReturnAllTypes() {
// Register the types and obtain them
ContentTypeDefinition alphaType = new ContentTypeDefinitionBuilder()
.Named(DefaultAlphaName)
.Build();
ContentTypeDefinition betaType = new ContentTypeDefinitionBuilder()
.Named(DefaultBetaName)
.Build();
ContentTypeDefinition gammaType = new ContentTypeDefinitionBuilder()
.Named(DefaultGammaName)
.Build();
ContentTypeDefinition deltaType = new ContentTypeDefinitionBuilder()
.Named(DefaultDeltaName)
.Build();
_contentDefinitionManager.Setup(contentDefinitionManager => contentDefinitionManager.ListTypeDefinitions())
.Returns(new List<ContentTypeDefinition> { alphaType, betaType, gammaType, deltaType });
var types = _manager.GetContentTypeDefinitions();
// Validate that the expected types were obtained
Assert.That(types.Count(), Is.EqualTo(4));
Assert.That(types, Has.Some.With.Property("Name").EqualTo(DefaultAlphaName));
Assert.That(types, Has.Some.With.Property("Name").EqualTo(DefaultBetaName));
Assert.That(types, Has.Some.With.Property("Name").EqualTo(DefaultGammaName));
Assert.That(types, Has.Some.With.Property("Name").EqualTo(DefaultDeltaName));
}
[Test]
public void BigStringsShouldNotBeTruncated() {
var megaRepository = _container.Resolve<IRepository<MegaRecord>>();

View File

@@ -5,8 +5,8 @@ using NUnit.Framework;
using Orchard.ContentManagement;
using Orchard.ContentManagement.FieldStorage;
using Orchard.ContentManagement.FieldStorage.InfosetStorage;
using Orchard.ContentManagement.MetaData.Builders;
using Orchard.ContentManagement.MetaData.Models;
using Orchard.ContentManagement.Definition.Builders;
using Orchard.ContentManagement.Definition.Models;
namespace Orchard.Tests.ContentManagement.Drivers.FieldStorage {
[TestFixture]

View File

@@ -4,8 +4,8 @@ using NUnit.Framework;
using Orchard.ContentManagement;
using Orchard.ContentManagement.FieldStorage;
using Orchard.ContentManagement.FieldStorage.InfosetStorage;
using Orchard.ContentManagement.MetaData.Builders;
using Orchard.ContentManagement.MetaData.Models;
using Orchard.ContentManagement.Definition.Builders;
using Orchard.ContentManagement.Definition.Models;
using Orchard.ContentManagement.Records;
namespace Orchard.Tests.ContentManagement.Drivers.FieldStorage {

View File

@@ -4,7 +4,7 @@ using System.Linq;
using System.Text;
using NUnit.Framework;
using Orchard.ContentManagement;
using Orchard.ContentManagement.MetaData.Models;
using Orchard.ContentManagement.Definition.Models;
namespace Orchard.Tests.ContentManagement {
[TestFixture]

View File

@@ -1,7 +1,7 @@
using NUnit.Framework;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers;
using Orchard.ContentManagement.MetaData.Builders;
using Orchard.ContentManagement.Definition.Builders;
namespace Orchard.Tests.ContentManagement.Handlers {

View File

@@ -7,7 +7,7 @@ using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
using Orchard.ContentManagement.Drivers.Coordinators;
using Orchard.ContentManagement.Handlers;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.Definition;
using Orchard.DisplayManagement;
using Orchard.DisplayManagement.Implementation;

View File

@@ -1,7 +1,7 @@
using NUnit.Framework;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers;
using Orchard.ContentManagement.MetaData.Builders;
using Orchard.ContentManagement.Definition.Builders;
using Orchard.Tests.ContentManagement.Models;
namespace Orchard.Tests.ContentManagement.Handlers {

View File

@@ -1,8 +1,8 @@
using System.Linq;
using NUnit.Framework;
using Orchard.ContentManagement.MetaData.Builders;
using Orchard.ContentManagement.Definition.Builders;
namespace Orchard.Tests.ContentManagement.MetaData.Builders {
namespace Orchard.Tests.ContentManagement.Metadata.Builders {
[TestFixture]
public class ContentTypeDefinitionBuilderTests {
[Test]

View File

@@ -1,11 +1,10 @@
using System.Linq;
using System.Xml.Linq;
using NUnit.Framework;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.MetaData.Builders;
using Orchard.ContentManagement.MetaData.Services;
using Orchard.ContentManagement.Definition.Builders;
using Orchard.ContentManagement.Definition.Services;
namespace Orchard.Tests.ContentManagement.MetaData.Services {
namespace Orchard.Tests.ContentManagement.Metadata.Services {
[TestFixture]
public class ContentDefinitionReaderTests {
private IContentDefinitionReader _reader;

View File

@@ -2,10 +2,10 @@
using System.Xml;
using System.Xml.Linq;
using NUnit.Framework;
using Orchard.ContentManagement.MetaData.Builders;
using Orchard.ContentManagement.MetaData.Services;
using Orchard.ContentManagement.Definition.Builders;
using Orchard.ContentManagement.Definition.Services;
namespace Orchard.Tests.ContentManagement.MetaData.Services {
namespace Orchard.Tests.ContentManagement.Metadata.Services {
[TestFixture]
public class ContentDefinitionWriterTests {
private ContentDefinitionWriter _writer;

View File

@@ -1,5 +1,5 @@
using Orchard.ContentManagement;
using Orchard.ContentManagement.MetaData.Models;
using Orchard.ContentManagement.Definition.Models;
namespace Orchard.Tests.ContentManagement.Models {
public class Phi : ContentField {

View File

@@ -81,7 +81,7 @@ namespace Orchard.Tests.Data {
public void LinqCanBeUsedToSelectObjects() {
CreateThreeFoos();
var foos = from f in _fooRepos.Table
var foos = from f in _fooRepos.Fetch()
where f.Name == "one" || f.Name == "two"
select f;
@@ -94,7 +94,7 @@ namespace Orchard.Tests.Data {
public void LinqExtensionMethodsCanAlsoBeUsedToSelectObjects() {
CreateThreeFoos();
var foos = _fooRepos.Table
var foos = _fooRepos.Fetch()
.Where(f => f.Name == "one" || f.Name == "two");
Assert.That(foos.Count(), Is.EqualTo(2));
@@ -115,31 +115,12 @@ namespace Orchard.Tests.Data {
Assert.That(foos.Skip(1).First().Name, Is.EqualTo("two"));
}
[Test]
public void LinqOrderByCanBeUsedToControlResultsBug() {
CreateThreeFoos();
// If look at the "LinqOrderByCanBeUsedToControlResults", you will see this query
// works fine is the static type of "foos" is "IEnumerable<Foo>"...
IOrderedQueryable<FooRecord> foos =
from f in _fooRepos.Table
where f.Name == "two" || f.Name == "three"
orderby f.Name, f.Id ascending
select f;
Assert.That(foos.Count(), Is.EqualTo(2));
Assert.That(foos.First().Name, Is.EqualTo("three"));
// Looks like a bug in NHib implementation of IOrderedQueryable<T>
Assert.Throws<AssertionException>(() => Assert.That(foos.Skip(1).First().Name, Is.EqualTo("two")));
}
[Test]
public void LinqOrderByCanBeUsedToControlResults() {
CreateThreeFoos();
IEnumerable<FooRecord> foos =
from f in _fooRepos.Table
from f in _fooRepos.Fetch()
where f.Name == "two" || f.Name == "three"
orderby f.Name, f.Id ascending
select f;

View File

@@ -7,7 +7,7 @@ using Moq;
using NHibernate;
using NUnit.Framework;
using Orchard.Caching;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.Definition;
using Orchard.ContentManagement.Records;
using Orchard.Data;
using Orchard.Data.Migration;
@@ -241,7 +241,7 @@ Features:
");
_dataMigrationManager.Update("Feature1");
Assert.That(_repository.Table.Count(), Is.EqualTo(0));
Assert.That(_repository.Fetch().Count(), Is.EqualTo(0));
}
[Test]
@@ -258,7 +258,7 @@ Features:
");
_dataMigrationManager.Update("Feature1");
Assert.That(_repository.Table.Count(), Is.EqualTo(0));
Assert.That(_repository.Fetch().Count(), Is.EqualTo(0));
}
[Test]
@@ -275,9 +275,9 @@ Features:
");
_dataMigrationManager.Update("Feature1");
Assert.That(_repository.Table.Count(), Is.EqualTo(1));
Assert.That(_repository.Table.First().Version, Is.EqualTo(999));
Assert.That(_repository.Table.First().DataMigrationClass, Is.EqualTo("Orchard.Tests.DataMigration.DataMigrationTests+DataMigration11Create"));
Assert.That(_repository.Fetch().Count(), Is.EqualTo(1));
Assert.That(_repository.Fetch().First().Version, Is.EqualTo(999));
Assert.That(_repository.Fetch().First().DataMigrationClass, Is.EqualTo("Orchard.Tests.DataMigration.DataMigrationTests+DataMigration11Create"));
}
[Test]
@@ -294,8 +294,8 @@ Features:
");
_dataMigrationManager.Update("Feature1");
Assert.That(_repository.Table.Count(), Is.EqualTo(1));
Assert.That(_repository.Table.First().Version, Is.EqualTo(666));
Assert.That(_repository.Fetch().Count(), Is.EqualTo(1));
Assert.That(_repository.Fetch().First().Version, Is.EqualTo(666));
}
[Test]
@@ -316,8 +316,8 @@ Features:
});
_dataMigrationManager.Update("Feature1");
Assert.That(_repository.Table.Count(), Is.EqualTo(1));
Assert.That(_repository.Table.First().Version, Is.EqualTo(999));
Assert.That(_repository.Fetch().Count(), Is.EqualTo(1));
Assert.That(_repository.Fetch().First().Version, Is.EqualTo(999));
}
[Test]
@@ -344,7 +344,7 @@ Features:
Description: Feature
");
_dataMigrationManager.Update("Feature1");
Assert.That(_repository.Table.Count(), Is.EqualTo(2));
Assert.That(_repository.Fetch().Count(), Is.EqualTo(2));
Assert.That(_repository.Fetch(d => d.Version == 999).Count(), Is.EqualTo(2));
Assert.That(_repository.Fetch(d => d.DataMigrationClass == "Orchard.Tests.DataMigration.DataMigrationTests+DataMigrationDependenciesModule1").Count(), Is.EqualTo(1));
Assert.That(_repository.Fetch(d => d.DataMigrationClass == "Orchard.Tests.DataMigration.DataMigrationTests+DataMigrationDependenciesModule2").Count(), Is.EqualTo(1));
@@ -364,7 +364,7 @@ Features:
");
_dataMigrationManager.Update("Feature1");
Assert.That(_repository.Table.Count(), Is.EqualTo(1));
Assert.That(_repository.Fetch().Count(), Is.EqualTo(1));
}
[Test]

View File

@@ -10,6 +10,7 @@ using Orchard.Data;
using Orchard.Services;
using Orchard.Tests.Data;
using Orchard.Tests.Stubs;
using Orchard.Time;
namespace Orchard.Tests {
public abstract class DatabaseEnabledTestsBase {

View File

@@ -48,5 +48,13 @@ namespace Orchard.Tests.DisplayManagement.Descriptors {
public class Token : IVolatileToken {
public bool IsCurrent { get; set; }
}
public DateTime GetFileLastWriteTimeUtc(string virtualPath) {
throw new NotImplementedException();
}
public bool TryFileExists(string virtualPath) {
throw new NotImplementedException();
}
}
}

View File

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

View File

@@ -5,13 +5,13 @@ using System.Linq;
using Autofac;
using Moq;
using NUnit.Framework;
using Orchard.AspNet.Abstractions;
using Orchard.Caching;
using Orchard.DisplayManagement.Descriptors;
using Orchard.DisplayManagement.Descriptors.ShapeTemplateStrategy;
using Orchard.Environment.Descriptor.Models;
using Orchard.Environment.Extensions;
using Orchard.Environment.Extensions.Models;
using Orchard.FileSystems.VirtualPath;
using Orchard.Tests.Stubs;
namespace Orchard.Tests.DisplayManagement.Descriptors {
@@ -49,6 +49,10 @@ namespace Orchard.Tests.DisplayManagement.Descriptors {
}
public class TestVirtualPathProvider : IVirtualPathProvider {
public IEnumerable<string> ListFiles(string path) {
return new List<string> {"~/Modules/Alpha/Views/AlphaShape.blah"};
}
public string Combine(params string[] paths) {
throw new NotImplementedException();
}
@@ -57,14 +61,34 @@ namespace Orchard.Tests.DisplayManagement.Descriptors {
throw new NotImplementedException();
}
public string ToAbsolute(string virtualPath) {
throw new NotImplementedException();
}
public string MapPath(string virtualPath) {
throw new NotImplementedException();
}
public string Combine(string basePath, string relativePath) {
throw new NotImplementedException();
}
public bool IsAppRelative(string virtualPath) {
throw new NotImplementedException();
}
public bool IsAbsolute(string virtualPath) {
throw new NotImplementedException();
}
public bool FileExists(string virtualPath) {
throw new NotImplementedException();
}
public bool TryFileExists(string virtualPath) {
throw new NotImplementedException();
}
public Stream OpenFile(string virtualPath) {
throw new NotImplementedException();
}
@@ -101,17 +125,9 @@ namespace Orchard.Tests.DisplayManagement.Descriptors {
throw new NotImplementedException();
}
public IEnumerable<string> ListFiles(string path) {
return new List<string> {"~/Modules/Alpha/Views/AlphaShape.blah"};
}
public IEnumerable<string> ListDirectories(string path) {
throw new NotImplementedException();
}
public bool TryFileExists(string virtualPath) {
throw new NotImplementedException();
}
}
protected override void Resolve(ILifetimeScope container) {

View File

@@ -5,13 +5,13 @@ using System.Linq;
using Autofac;
using Moq;
using NUnit.Framework;
using Orchard.AspNet.Abstractions;
using Orchard.DisplayManagement.Descriptors;
using Orchard.DisplayManagement.Descriptors.ResourceBindingStrategy;
using Orchard.DisplayManagement.Descriptors.ShapeTemplateStrategy;
using Orchard.Environment.Descriptor.Models;
using Orchard.Environment.Extensions;
using Orchard.Environment.Extensions.Models;
using Orchard.FileSystems.VirtualPath;
namespace Orchard.Tests.DisplayManagement.Descriptors {
[TestFixture]
@@ -109,6 +109,23 @@ namespace Orchard.Tests.DisplayManagement.Descriptors {
public bool TryFileExists(string virtualPath) {
throw new NotImplementedException();
}
public string ToAbsolute(string virtualPath) {
throw new NotImplementedException();
}
public string Combine(string basePath, string relativePath) {
throw new NotImplementedException();
}
public bool IsAppRelative(string virtualPath) {
throw new NotImplementedException();
}
public bool IsAbsolute(string virtualPath) {
throw new NotImplementedException();
}
}
protected override void Resolve(ILifetimeScope container) {

View File

@@ -1,10 +1,10 @@
using System.Linq;
using NUnit.Framework;
using Orchard.Environment;
using Orchard.FileSystems.Dependencies;
using Orchard.Environment.Compilation.Dependencies;
using Orchard.Tests.Stubs;
namespace Orchard.Tests.FileSystems.Dependencies {
namespace Orchard.Tests.Environment.Compilation.Dependencies {
[TestFixture]
public class AssemblyProbingFolderTests {

View File

@@ -4,27 +4,28 @@ using System.Linq;
using Autofac;
using NUnit.Framework;
using Orchard.Caching;
using Orchard.Environment.Compilation.Dependencies;
using Orchard.FileSystems.AppData;
using Orchard.FileSystems.Dependencies;
using Orchard.Services;
using Orchard.Tests.Stubs;
using Orchard.Time;
namespace Orchard.Tests.FileSystems.Dependencies {
namespace Orchard.Tests.Environment.Compilation.Dependencies {
[TestFixture]
public class DependenciesFolderTests {
public class DependencyDescriptorManagerTests {
public IContainer BuildContainer() {
var builder = new ContainerBuilder();
builder.RegisterType<StubClock>().As<IClock>().SingleInstance();
builder.RegisterType<StubAppDataFolder>().As<IAppDataFolder>().SingleInstance();
builder.RegisterType<StubCacheManager>().As<ICacheManager>().SingleInstance();
builder.RegisterType<StubParallelCacheContext>().As<IParallelCacheContext>();
builder.RegisterType<DefaultDependenciesFolder>().As<IDependenciesFolder>();
builder.RegisterType<DefaultDependencyDescriptorManager>().As<IDependencyDescriptorManager>();
return builder.Build();
}
[Test]
public void LoadDescriptorsShouldReturnEmptyList() {
var dependenciesFolder = BuildContainer().Resolve<IDependenciesFolder>();
var dependenciesFolder = BuildContainer().Resolve<IDependencyDescriptorManager>();
var e = dependenciesFolder.LoadDescriptors();
Assert.That(e, Is.Empty);
@@ -32,7 +33,7 @@ namespace Orchard.Tests.FileSystems.Dependencies {
[Test]
public void StoreDescriptorsShouldWork() {
var dependenciesFolder = BuildContainer().Resolve<IDependenciesFolder>();
var dependenciesFolder = BuildContainer().Resolve<IDependencyDescriptorManager>();
var d = new DependencyDescriptor {
Name = "name",
@@ -53,7 +54,7 @@ namespace Orchard.Tests.FileSystems.Dependencies {
var container = BuildContainer();
var clock = (StubClock)container.Resolve<IClock>();
var appDataFolder = (StubAppDataFolder)container.Resolve<IAppDataFolder>();
var dependenciesFolder = container.Resolve<IDependenciesFolder>();
var dependenciesFolder = container.Resolve<IDependencyDescriptorManager>();
var d1 = new DependencyDescriptor {
Name = "name1",
@@ -68,11 +69,11 @@ namespace Orchard.Tests.FileSystems.Dependencies {
};
dependenciesFolder.StoreDescriptors(new[] { d1, d2 });
var dateTime1 = appDataFolder.GetLastWriteTimeUtc(Path.Combine("Dependencies", "Dependencies.xml"));
var dateTime1 = appDataFolder.GetLastWriteTimeUtc(appDataFolder.MapPath(Path.Combine("Dependencies", "Dependencies.xml")));
clock.Advance(TimeSpan.FromMinutes(1));
dependenciesFolder.StoreDescriptors(new[] { d2, d1 });
var dateTime2 = appDataFolder.GetLastWriteTimeUtc(Path.Combine("Dependencies", "Dependencies.xml"));
var dateTime2 = appDataFolder.GetLastWriteTimeUtc(appDataFolder.MapPath(Path.Combine("Dependencies", "Dependencies.xml")));
Assert.That(dateTime1, Is.EqualTo(dateTime2));
}
@@ -81,7 +82,7 @@ namespace Orchard.Tests.FileSystems.Dependencies {
var container = BuildContainer();
var clock = (StubClock)container.Resolve<IClock>();
var appDataFolder = (StubAppDataFolder)container.Resolve<IAppDataFolder>();
var dependenciesFolder = container.Resolve<IDependenciesFolder>();
var dependenciesFolder = container.Resolve<IDependencyDescriptorManager>();
var d1 = new DependencyDescriptor {
Name = "name1",
@@ -96,13 +97,13 @@ namespace Orchard.Tests.FileSystems.Dependencies {
};
dependenciesFolder.StoreDescriptors(new[] { d1, d2 });
var dateTime1 = appDataFolder.GetLastWriteTimeUtc(Path.Combine("Dependencies", "Dependencies.xml"));
var dateTime1 = appDataFolder.GetLastWriteTimeUtc(appDataFolder.MapPath(Path.Combine("Dependencies", "Dependencies.xml")));
clock.Advance(TimeSpan.FromMinutes(1));
d1.LoaderName = "bar";
dependenciesFolder.StoreDescriptors(new[] { d2, d1 });
var dateTime2 = appDataFolder.GetLastWriteTimeUtc(Path.Combine("Dependencies", "Dependencies.xml"));
var dateTime2 = appDataFolder.GetLastWriteTimeUtc(appDataFolder.MapPath(Path.Combine("Dependencies", "Dependencies.xml")));
Assert.That(dateTime1 + TimeSpan.FromMinutes(1), Is.EqualTo(dateTime2));
}
@@ -111,7 +112,7 @@ namespace Orchard.Tests.FileSystems.Dependencies {
var container = BuildContainer();
var clock = (StubClock)container.Resolve<IClock>();
var appDataFolder = (StubAppDataFolder)container.Resolve<IAppDataFolder>();
var dependenciesFolder = container.Resolve<IDependenciesFolder>();
var dependenciesFolder = container.Resolve<IDependencyDescriptorManager>();
var d1 = new DependencyDescriptor {
Name = "name1",
@@ -128,7 +129,7 @@ namespace Orchard.Tests.FileSystems.Dependencies {
dependenciesFolder.StoreDescriptors(new[] { d1, d2 });
// Create a new instance over the same appDataFolder
var dependenciesFolder2 = container.Resolve<IDependenciesFolder>();
var dependenciesFolder2 = container.Resolve<IDependencyDescriptorManager>();
Assert.That(dependenciesFolder2, Is.Not.SameAs(dependenciesFolder));
// Ensure descriptors were persisted properly

View File

@@ -1,25 +1,25 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Autofac;
using Moq;
using NUnit.Framework;
using Orchard.AspNet.Abstractions;
using Orchard.Caching;
using Orchard.Environment;
using Orchard.Environment.Extensions.Compilers;
using Orchard.Environment.Extensions.Loaders;
using Orchard.Environment.Compilation.Compilers;
using Orchard.Environment.Compilation.Dependencies;
using Orchard.Environment.Compilation.Loaders;
using Orchard.FileSystems.AppData;
using Orchard.FileSystems.Dependencies;
using Orchard.FileSystems.VirtualPath;
using Orchard.Services;
using Orchard.Tests.Stubs;
using Orchard.Time;
namespace Orchard.Tests.Environment.Loaders {
namespace Orchard.Tests.Environment.Compilation.Loaders {
[TestFixture]
public class DynamicExtensionLoaderTests {
private IContainer _container;
private Mock<IProjectFileParser> _mockedStubProjectFileParser;
private Mock<IDependenciesFolder> _mockedDependenciesFolder;
private Mock<IDependencyDescriptorManager> _mockedDependenciesFolder;
[SetUp]
public void Init() {
@@ -40,8 +40,8 @@ namespace Orchard.Tests.Environment.Loaders {
builder.RegisterInstance(_mockedStubProjectFileParser.Object).As<IProjectFileParser>();
builder.RegisterInstance(new StubFileSystem(new StubClock())).As<StubFileSystem>();
_mockedDependenciesFolder = new Mock<IDependenciesFolder>();
builder.RegisterInstance(_mockedDependenciesFolder.Object).As<IDependenciesFolder>();
_mockedDependenciesFolder = new Mock<IDependencyDescriptorManager>();
builder.RegisterInstance(_mockedDependenciesFolder.Object).As<IDependencyDescriptorManager>();
_container = builder.Build();
}
@@ -150,7 +150,7 @@ namespace Orchard.Tests.Environment.Loaders {
IVirtualPathMonitor virtualPathMonitor,
IHostEnvironment hostEnvironment,
IAssemblyProbingFolder assemblyProbingFolder,
IDependenciesFolder dependenciesFolder,
IDependencyDescriptorManager dependenciesFolder,
IProjectFileParser projectFileParser)
: base(buildManager, virtualPathProvider, virtualPathMonitor, hostEnvironment, assemblyProbingFolder, dependenciesFolder, projectFileParser) {}

View File

@@ -19,7 +19,7 @@ namespace Orchard.Tests.Environment.Configuration {
[Test]
public void SingleSettingsFileShouldComeBackAsExpected() {
_appDataFolder.CreateFile("Sites\\Default\\Settings.txt", "Name: Default\r\nDataProvider: SqlCe\r\nDataConnectionString: something else");
_appDataFolder.StoreFile("Sites\\Default\\Settings.txt", "Name: Default\r\nDataProvider: SqlCe\r\nDataConnectionString: something else");
IShellSettingsManager loader = new ShellSettingsManager(_appDataFolder, new Mock<IShellSettingsManagerEventHandler>().Object);
var settings = loader.LoadSettings().Single();
@@ -33,8 +33,8 @@ namespace Orchard.Tests.Environment.Configuration {
[Test]
public void MultipleFilesCanBeDetected() {
_appDataFolder.CreateFile("Sites\\Default\\Settings.txt", "Name: Default\r\nDataProvider: SqlCe\r\nDataConnectionString: something else");
_appDataFolder.CreateFile("Sites\\Another\\Settings.txt", "Name: Another\r\nDataProvider: SqlCe2\r\nDataConnectionString: something else2");
_appDataFolder.StoreFile("Sites\\Default\\Settings.txt", "Name: Default\r\nDataProvider: SqlCe\r\nDataConnectionString: something else");
_appDataFolder.StoreFile("Sites\\Another\\Settings.txt", "Name: Another\r\nDataProvider: SqlCe2\r\nDataConnectionString: something else2");
IShellSettingsManager loader = new ShellSettingsManager(_appDataFolder, new Mock<IShellSettingsManagerEventHandler>().Object);
var settings = loader.LoadSettings();
@@ -53,7 +53,7 @@ namespace Orchard.Tests.Environment.Configuration {
[Test]
public void NewSettingsCanBeStored() {
_appDataFolder.CreateFile("Sites\\Default\\Settings.txt", "Name: Default\r\nDataProvider: SqlCe\r\nDataConnectionString: something else");
_appDataFolder.StoreFile("Sites\\Default\\Settings.txt", "Name: Default\r\nDataProvider: SqlCe\r\nDataConnectionString: something else");
IShellSettingsManager loader = new ShellSettingsManager(_appDataFolder, new Mock<IShellSettingsManagerEventHandler>().Object);
var foo = new ShellSettings {Name = "Foo", DataProvider = "Bar", DataConnectionString = "Quux"};

View File

@@ -6,6 +6,7 @@ using System.Web.Routing;
using Autofac;
using Autofac.Integration.Web;
using NUnit.Framework;
using Orchard.AspNet.Abstractions;
using Orchard.Caching;
using Orchard.Environment;
using Orchard.Environment.Configuration;
@@ -16,7 +17,6 @@ using Orchard.Environment.ShellBuilders;
using Orchard.Environment.Descriptor;
using Orchard.Environment.Descriptor.Models;
using Orchard.FileSystems.AppData;
using Orchard.FileSystems.VirtualPath;
using Orchard.Mvc.ModelBinders;
using Orchard.Mvc.Routes;
using Orchard.Tests.Environment.TestDependencies;

View File

@@ -5,11 +5,11 @@ using System.Reflection;
using Autofac;
using NUnit.Framework;
using Orchard.Caching;
using Orchard.Environment.Compilation.Dependencies;
using Orchard.Environment.Compilation.Loaders;
using Orchard.Environment.Extensions;
using Orchard.Environment.Extensions.Folders;
using Orchard.Environment.Extensions.Loaders;
using Orchard.Environment.Extensions.Models;
using Orchard.FileSystems.Dependencies;
using Orchard.Tests.Extensions.ExtensionTypes;
using Orchard.Tests.Stubs;

View File

@@ -6,11 +6,11 @@ using System.Reflection;
using Autofac;
using NUnit.Framework;
using Orchard.Caching;
using Orchard.Environment.Compilation.Dependencies;
using Orchard.Environment.Compilation.Loaders;
using Orchard.Environment.Extensions;
using Orchard.Environment.Extensions.Folders;
using Orchard.Environment.Extensions.Loaders;
using Orchard.Environment.Extensions.Models;
using Orchard.FileSystems.Dependencies;
using Orchard.Tests.Extensions.ExtensionTypes;
using Orchard.Tests.Stubs;

View File

@@ -4,6 +4,7 @@ using Autofac;
using NUnit.Framework;
using Orchard.Events;
using System;
using Orchard.Exceptions;
namespace Orchard.Tests.Events {
[TestFixture]
@@ -18,6 +19,7 @@ namespace Orchard.Tests.Events {
var builder = new ContainerBuilder();
builder.RegisterType<DefaultOrchardEventBus>().As<IEventBus>();
builder.RegisterType<StubExceptionPolicy>().As<IExceptionPolicy>();
builder.RegisterType<StubEventHandler2>().As<IEventHandler>();
builder.RegisterInstance(_eventHandler).As<IEventHandler>();
@@ -229,4 +231,10 @@ namespace Orchard.Tests.Events {
}
}
}
class StubExceptionPolicy : IExceptionPolicy {
public bool HandleException(object sender, Exception exception) {
return true;
}
}
}

View File

@@ -82,14 +82,14 @@ namespace Orchard.Tests.FileSystems.AppData {
[Test]
public void CreateFileWillCauseDirectoryToBeCreated() {
Assert.That(Directory.Exists(Path.Combine(_tempFolder, "alpha\\omega\\foo")), Is.False);
_appDataFolder.CreateFile("alpha\\omega\\foo\\bar.txt", "quux");
_appDataFolder.StoreFile("alpha\\omega\\foo\\bar.txt", "quux");
Assert.That(Directory.Exists(Path.Combine(_tempFolder, "alpha\\omega\\foo")), Is.True);
}
[Test]
public void FilesCanBeReadBack() {
_appDataFolder.CreateFile("alpha\\gamma\\foo\\bar.txt", @"
public void FilesCanBeReadBack() {
_appDataFolder.StoreFile("alpha\\gamma\\foo\\bar.txt", @"
this is
a
test");
@@ -99,16 +99,5 @@ this is
a
test"));
}
[Test]
public void FileExistsReturnsFalseForNonExistingFile() {
Assert.That(_appDataFolder.FileExists("notexisting"), Is.False);
}
[Test]
public void FileExistsReturnsTrueForExistingFile() {
_appDataFolder.CreateFile("alpha\\foo\\bar.txt", "");
Assert.That(_appDataFolder.FileExists("alpha\\foo\\bar.txt"), Is.True);
}
}
}

View File

@@ -1,223 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using NUnit.Framework;
using Orchard.FileSystems.AppData;
using Orchard.FileSystems.LockFile;
using Orchard.Tests.Stubs;
namespace Orchard.Tests.FileSystems.LockFile {
[TestFixture]
public class LockFileManagerTests {
private string _tempFolder;
private IAppDataFolder _appDataFolder;
private ILockFileManager _lockFileManager;
private StubClock _clock;
public class StubAppDataFolderRoot : IAppDataFolderRoot {
public string RootPath { get; set; }
public string RootFolder { get; set; }
}
public static IAppDataFolder CreateAppDataFolder(string tempFolder) {
var folderRoot = new StubAppDataFolderRoot {RootPath = "~/App_Data", RootFolder = tempFolder};
var monitor = new StubVirtualPathMonitor();
return new AppDataFolder(folderRoot, monitor);
}
[SetUp]
public void Init() {
_tempFolder = Path.GetTempFileName();
File.Delete(_tempFolder);
_appDataFolder = CreateAppDataFolder(_tempFolder);
_clock = new StubClock();
_lockFileManager = new DefaultLockFileManager(_appDataFolder, _clock);
}
[TearDown]
public void Term() {
Directory.Delete(_tempFolder, true);
}
[Test]
public void LockShouldBeGrantedWhenDoesNotExist() {
ILockFile lockFile = null;
var granted = _lockFileManager.TryAcquireLock("foo.txt.lock", ref lockFile);
Assert.That(granted, Is.True);
Assert.That(lockFile, Is.Not.Null);
Assert.That(_lockFileManager.IsLocked("foo.txt.lock"), Is.True);
Assert.That(_appDataFolder.ListFiles("").Count(), Is.EqualTo(1));
}
[Test]
public void ExistingLockFileShouldPreventGrants() {
ILockFile lockFile = null;
_lockFileManager.TryAcquireLock("foo.txt.lock", ref lockFile);
Assert.That(_lockFileManager.TryAcquireLock("foo.txt.lock", ref lockFile), Is.False);
Assert.That(_lockFileManager.IsLocked("foo.txt.lock"), Is.True);
Assert.That(_appDataFolder.ListFiles("").Count(), Is.EqualTo(1));
}
[Test]
public void ReleasingALockShouldAllowGranting() {
ILockFile lockFile = null;
_lockFileManager.TryAcquireLock("foo.txt.lock", ref lockFile);
using (lockFile) {
Assert.That(_lockFileManager.IsLocked("foo.txt.lock"), Is.True);
Assert.That(_appDataFolder.ListFiles("").Count(), Is.EqualTo(1));
}
Assert.That(_lockFileManager.IsLocked("foo.txt.lock"), Is.False);
Assert.That(_appDataFolder.ListFiles("").Count(), Is.EqualTo(0));
}
[Test]
public void ReleasingAReleasedLockShouldWork() {
ILockFile lockFile = null;
_lockFileManager.TryAcquireLock("foo.txt.lock", ref lockFile);
Assert.That(_lockFileManager.IsLocked("foo.txt.lock"), Is.True);
Assert.That(_appDataFolder.ListFiles("").Count(), Is.EqualTo(1));
lockFile.Release();
Assert.That(_lockFileManager.IsLocked("foo.txt.lock"), Is.False);
Assert.That(_appDataFolder.ListFiles("").Count(), Is.EqualTo(0));
lockFile.Release();
Assert.That(_lockFileManager.IsLocked("foo.txt.lock"), Is.False);
Assert.That(_appDataFolder.ListFiles("").Count(), Is.EqualTo(0));
}
[Test]
public void DisposingLockShouldReleaseIt() {
ILockFile lockFile = null;
_lockFileManager.TryAcquireLock("foo.txt.lock", ref lockFile);
using (lockFile) {
Assert.That(_lockFileManager.IsLocked("foo.txt.lock"), Is.True);
Assert.That(_appDataFolder.ListFiles("").Count(), Is.EqualTo(1));
}
Assert.That(_lockFileManager.IsLocked("foo.txt.lock"), Is.False);
Assert.That(_appDataFolder.ListFiles("").Count(), Is.EqualTo(0));
}
[Test]
public void ExpiredLockShouldBeAvailable() {
ILockFile lockFile = null;
_lockFileManager.TryAcquireLock("foo.txt.lock", ref lockFile);
_clock.Advance(DefaultLockFileManager.Expiration);
Assert.That(_lockFileManager.IsLocked("foo.txt.lock"), Is.False);
Assert.That(_appDataFolder.ListFiles("").Count(), Is.EqualTo(1));
}
[Test]
public void ShouldGrantExpiredLock() {
ILockFile lockFile = null;
_lockFileManager.TryAcquireLock("foo.txt.lock", ref lockFile);
_clock.Advance(DefaultLockFileManager.Expiration);
var granted = _lockFileManager.TryAcquireLock("foo.txt.lock", ref lockFile);
Assert.That(granted, Is.True);
Assert.That(_appDataFolder.ListFiles("").Count(), Is.EqualTo(1));
}
private static int _lockCount;
private static readonly object _synLock = new object();
[Test]
public void AcquiringLockShouldBeThreadSafe() {
var threads = new List<Thread>();
for(var i=0; i<10; i++) {
var t = new Thread(PlayWithAcquire);
t.Start();
threads.Add(t);
}
threads.ForEach(t => t.Join());
Assert.That(_lockCount, Is.EqualTo(0));
}
[Test]
public void IsLockedShouldBeThreadSafe() {
var threads = new List<Thread>();
for (var i = 0; i < 10; i++)
{
var t = new Thread(PlayWithIsLocked);
t.Start();
threads.Add(t);
}
threads.ForEach(t => t.Join());
Assert.That(_lockCount, Is.EqualTo(0));
}
private void PlayWithAcquire() {
var r = new Random(DateTime.Now.Millisecond);
ILockFile lockFile = null;
// loop until the lock has been acquired
for (;;) {
if (!_lockFileManager.TryAcquireLock("foo.txt.lock", ref lockFile)) {
continue;
}
lock (_synLock) {
_lockCount++;
Assert.That(_lockCount, Is.EqualTo(1));
}
// keep the lock for a certain time
Thread.Sleep(r.Next(200));
lock (_synLock) {
_lockCount--;
Assert.That(_lockCount, Is.EqualTo(0));
}
lockFile.Release();
return;
}
}
private void PlayWithIsLocked() {
var r = new Random(DateTime.Now.Millisecond);
ILockFile lockFile = null;
const string path = "foo.txt.lock";
// loop until the lock has been acquired
for (;;) {
if(_lockFileManager.IsLocked(path)) {
continue;
}
if (!_lockFileManager.TryAcquireLock(path, ref lockFile)) {
continue;
}
lock (_synLock) {
_lockCount++;
Assert.That(_lockCount, Is.EqualTo(1));
}
// keep the lock for a certain time
Thread.Sleep(r.Next(200));
lock (_synLock) {
_lockCount--;
Assert.That(_lockCount, Is.EqualTo(0));
}
lockFile.Release();
return;
}
}
}
}

View File

@@ -1,6 +1,6 @@
using Moq;
using NUnit.Framework;
using Orchard.FileSystems.VirtualPath;
using Orchard.AspNet.Abstractions;
namespace Orchard.Tests.FileSystems.VirtualPath {
[TestFixture]

View File

@@ -9,7 +9,7 @@ using NHibernate;
using NUnit.Framework;
using Orchard.Caching;
using Orchard.ContentManagement;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.Definition;
using Orchard.Data;
using Orchard.DisplayManagement;
using Orchard.DisplayManagement.Descriptors;

View File

@@ -0,0 +1,187 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using NUnit.Framework;
using Orchard.Environment.Configuration;
using Orchard.FileSystems.AppData;
using Orchard.Locking;
using Orchard.Tests.Stubs;
namespace Orchard.Tests.Locking {
[TestFixture]
public class LockManagerTests {
private string _tempFolder;
private IAppDataFolder _appDataFolder;
private ILockManager _lockFileManager;
private StubClock _clock;
public class StubAppDataFolderRoot : IAppDataFolderRoot {
public string RootPath { get; set; }
public string RootFolder { get; set; }
}
public static IAppDataFolder CreateAppDataFolder(string tempFolder) {
var folderRoot = new StubAppDataFolderRoot {RootPath = "~/App_Data", RootFolder = tempFolder};
var monitor = new StubVirtualPathMonitor();
return new AppDataFolder(folderRoot, monitor);
}
[SetUp]
public void Init() {
_tempFolder = Path.GetTempFileName();
File.Delete(_tempFolder);
_appDataFolder = CreateAppDataFolder(_tempFolder);
_clock = new StubClock();
_lockFileManager = new DefaultLockManager(_appDataFolder, _clock, new ShellSettings { Name = "Foo" });
}
[TearDown]
public void Term() {
Directory.Delete(_tempFolder, true);
}
private int LockFilesCount() {
return _appDataFolder.ListFiles("Sites/Foo").Where(f => f.EndsWith(".lock")).Count();
}
[Test]
public void LockShouldBeGrantedWhenDoesNotExist() {
var @lock = _lockFileManager.TryLock("foo.txt");
Assert.That(@lock, Is.Not.Null);
Assert.That(_lockFileManager.TryLock("foo.txt"), Is.Null);
Assert.That(LockFilesCount(), Is.EqualTo(1));
}
[Test]
public void ExistingLockFileShouldPreventGrants() {
_lockFileManager.TryLock("foo.txt");
Assert.That(_lockFileManager.TryLock("foo.txt"), Is.Null);
Assert.That(LockFilesCount(), Is.EqualTo(1));
}
[Test]
public void ReleasingALockShouldAllowGranting() {
var @lock = _lockFileManager.TryLock("foo.txt");
using (@lock) {
Assert.That(_lockFileManager.TryLock("foo.txt"), Is.Null);
Assert.That(LockFilesCount(), Is.EqualTo(1));
}
@lock = _lockFileManager.TryLock("foo.txt");
Assert.That(@lock, Is.Not.Null);
@lock.Dispose();
Assert.That(LockFilesCount(), Is.EqualTo(0));
}
[Test]
public void ReleasingAReleasedLockShouldWork() {
var @lock = _lockFileManager.TryLock("foo.txt");
Assert.That(_lockFileManager.TryLock("foo.txt"), Is.Null);
Assert.That(LockFilesCount(), Is.EqualTo(1));
@lock.Dispose();
@lock = _lockFileManager.TryLock("foo.txt");
Assert.That(@lock, Is.Not.Null);
Assert.That(LockFilesCount(), Is.EqualTo(1));
@lock.Dispose();
@lock.Dispose();
@lock = _lockFileManager.TryLock("foo.txt");
Assert.That(@lock, Is.Not.Null);
Assert.That(LockFilesCount(), Is.EqualTo(1));
@lock.Dispose();
Assert.That(LockFilesCount(), Is.EqualTo(0));
}
[Test]
public void DisposingLockShouldReleaseIt() {
var @lock = _lockFileManager.TryLock("foo.txt");
using (@lock) {
Assert.That(_lockFileManager.TryLock("foo.txt"), Is.Null);
Assert.That(LockFilesCount(), Is.EqualTo(1));
}
@lock = _lockFileManager.TryLock("foo.txt");
Assert.That(@lock, Is.Not.Null);
@lock.Dispose();
Assert.That(LockFilesCount(), Is.EqualTo(0));
}
[Test]
public void ExpiredLockShouldBeAvailable() {
_lockFileManager.TryLock("foo.txt");
_clock.Advance(DefaultLockManager.Expiration);
Assert.That(_lockFileManager.TryLock("foo.txt"), Is.Not.Null);
Assert.That(LockFilesCount(), Is.EqualTo(1));
}
[Test]
public void ShouldGrantExpiredLock() {
_lockFileManager.TryLock("foo.txt");
_clock.Advance(DefaultLockManager.Expiration);
var @lock = _lockFileManager.TryLock("foo.txt");
Assert.That(@lock, Is.Not.Null);
Assert.That(LockFilesCount(), Is.EqualTo(1));
}
private static int _lockCount;
private static readonly object _synLock = new object();
[Test]
public void AcquiringLockShouldBeThreadSafe() {
// A number of threads will try to acquire a lock and keep it for
// some random time. Each of them stops when it has acquired the lock once.
var threads = new List<Thread>();
for(var i=0; i<10; i++) {
var t = new Thread(PlayWithAcquire);
t.Start();
threads.Add(t);
}
threads.ForEach(t => t.Join());
Assert.That(_lockCount, Is.EqualTo(0));
}
private void PlayWithAcquire() {
var r = new Random(DateTime.Now.Millisecond);
IDisposable @lock;
// loop until the lock has been acquired
for (;;) {
if (null == (@lock = _lockFileManager.TryLock("foo.txt"))) {
continue;
}
lock (_synLock) {
_lockCount++;
Assert.That(_lockCount, Is.EqualTo(1));
}
// keep the lock for a certain time
Thread.Sleep(r.Next(200));
lock (_synLock) {
_lockCount--;
Assert.That(_lockCount, Is.EqualTo(0));
}
@lock.Dispose();
return;
}
}
}
}

View File

@@ -8,118 +8,6 @@ using System.Collections.Generic;
namespace Orchard.Tests.Mvc.Html {
[TestFixture]
public class HtmlHelperExtensionsTests {
[Test]
public void LinkReturnsIHtmlString() {
//arrange
var viewContext = new ViewContext();
var viewDataContainer = new Mock<IViewDataContainer>();
var html = new HtmlHelper(viewContext, viewDataContainer.Object);
//act
var result = html.Link("test", "http://example.com") as IHtmlString;
//assert
Assert.IsNotNull(result);
}
[Test]
public void LinkHtmlEncodesLinkText() {
//arrange
var viewContext = new ViewContext();
var viewDataContainer = new Mock<IViewDataContainer>();
var html = new HtmlHelper(viewContext, viewDataContainer.Object);
//act
var result = html.Link("<br />", "http://example.com");
//assert
Assert.AreEqual(@"<a href=""http://example.com"">&lt;br /&gt;</a>", result.ToString());
}
[Test]
public void LinkHtmlAttributeEncodesHref() {
//arrange
var viewContext = new ViewContext();
var viewDataContainer = new Mock<IViewDataContainer>();
var html = new HtmlHelper(viewContext, viewDataContainer.Object);
//act
var result = html.Link("test", "<br />");
//assert
Assert.AreEqual(@"<a href=""&lt;br />"">test</a>", result.ToString());
}
[Test]
public void LinkHtmlAttributeEncodesAttributes() {
//arrange
var viewContext = new ViewContext();
var viewDataContainer = new Mock<IViewDataContainer>();
var html = new HtmlHelper(viewContext, viewDataContainer.Object);
//act
var result = html.Link("linkText", "http://example.com", new { title = "<br />" });
//assert
Assert.AreEqual(@"<a href=""http://example.com"" title=""&lt;br />"">linkText</a>", result.ToString());
}
[Test]
public void LinkOrDefaultReturnsIHtmlString() {
//arrange
var viewContext = new ViewContext();
var viewDataContainer = new Mock<IViewDataContainer>();
var html = new HtmlHelper(viewContext, viewDataContainer.Object);
//act
var result = html.LinkOrDefault("test", "http://example.com") as IHtmlString;
//assert
Assert.IsNotNull(result);
}
[Test]
public void LinkOrDefaultHtmlEncodesLinkText() {
//arrange
var viewContext = new ViewContext();
var viewDataContainer = new Mock<IViewDataContainer>();
var html = new HtmlHelper(viewContext, viewDataContainer.Object);
//act
var result = html.LinkOrDefault("<br />", "http://example.com");
//assert
Assert.AreEqual(@"<a href=""http://example.com"">&lt;br /&gt;</a>", result.ToString());
}
[Test]
public void LinkOrDefaultWithoutHrefHtmlEncodesLinkText() {
//arrange
var viewContext = new ViewContext();
var viewDataContainer = new Mock<IViewDataContainer>();
var html = new HtmlHelper(viewContext, viewDataContainer.Object);
//act
var result = html.LinkOrDefault("<br />", null);
//assert
Assert.AreEqual(@"&lt;br /&gt;", result.ToString());
}
[Test]
public void LinkOrDefaultWithHrefHtmlAttributeEncodesHref() {
//arrange
var viewContext = new ViewContext();
var viewDataContainer = new Mock<IViewDataContainer>();
var html = new HtmlHelper(viewContext, viewDataContainer.Object);
//act
var result = html.LinkOrDefault("test", "<br />");
//assert
Assert.AreEqual(@"<a href=""&lt;br />"">test</a>", result.ToString());
}
[Test]
public void SelectOptionHtmlEncodesText() {
//arrange
@@ -133,33 +21,5 @@ namespace Orchard.Tests.Mvc.Html {
//assert
Assert.AreEqual(@"<option value=""value"">&lt;br /&gt;</option>", result.ToString());
}
[Test]
public void UnorderedListWithNullItemsReturnsEmptyHtmlString() {
//arrange
var viewContext = new ViewContext();
var viewDataContainer = new Mock<IViewDataContainer>();
var html = new HtmlHelper(viewContext, viewDataContainer.Object);
//act
var result = html.UnorderedList((IEnumerable<string>)null, (a, b) => MvcHtmlString.Create(""), "test");
//assert
Assert.AreEqual(string.Empty, result.ToString());
}
[Test]
public void UnorderedListWithEmptyItemsReturnsEmptyHtmlString() {
//arrange
var viewContext = new ViewContext();
var viewDataContainer = new Mock<IViewDataContainer>();
var html = new HtmlHelper(viewContext, viewDataContainer.Object);
//act
var result = html.UnorderedList(new string[] { }, (a, b) => MvcHtmlString.Create(""), "test");
//assert
Assert.AreEqual(string.Empty, result.ToString());
}
}
}

View File

@@ -180,9 +180,9 @@
<Compile Include="ContentManagement\Handlers\EpsilonPartHandler.cs" />
<Compile Include="ContentManagement\Handlers\GammaPartHandler.cs" />
<Compile Include="ContentManagement\Handlers\ModelBuilderTests.cs" />
<Compile Include="ContentManagement\MetaData\Builders\ContentTypeDefinitionBuilderTests.cs" />
<Compile Include="ContentManagement\MetaData\Services\ContentDefinitionReaderTests.cs" />
<Compile Include="ContentManagement\MetaData\Services\ContentDefinitionWriterTests.cs" />
<Compile Include="ContentManagement\Metadata\Builders\ContentTypeDefinitionBuilderTests.cs" />
<Compile Include="ContentManagement\Metadata\Services\ContentDefinitionReaderTests.cs" />
<Compile Include="ContentManagement\Metadata\Services\ContentDefinitionWriterTests.cs" />
<Compile Include="ContentManagement\Models\AlphaPart.cs" />
<Compile Include="ContentManagement\Handlers\AlphaPartHandler.cs" />
<Compile Include="ContentManagement\Models\BetaPart.cs" />
@@ -236,7 +236,7 @@
<Compile Include="Environment\DefaultWorkContextAccessorTests.cs" />
<Compile Include="Environment\Extensions\ExtensionLoaderCoordinatorTests.cs" />
<Compile Include="Environment\Features\FeatureManagerTests.cs" />
<Compile Include="Environment\Loaders\DynamicExtensionLoaderTests.cs" />
<Compile Include="Environment\Compilation\Loaders\DynamicExtensionLoaderTests.cs" />
<Compile Include="Environment\State\DefaultProcessingEngineTests.cs" />
<Compile Include="Environment\RunningShellTableTests.cs" />
<Compile Include="Environment\StubHostEnvironment.cs" />
@@ -250,9 +250,9 @@
<Compile Include="Environment\OrchardStarterTests.cs" />
<Compile Include="Environment\ShellBuilders\DefaultShellContainerFactoryTests.cs" />
<Compile Include="Environment\ShellBuilders\DefaultShellContextFactoryTests.cs" />
<Compile Include="FileSystems\LockFile\LockFileManagerTests.cs" />
<Compile Include="FileSystems\Dependencies\AssemblyProbingFolderTests.cs" />
<Compile Include="FileSystems\Dependencies\DependenciesFolderTests.cs" />
<Compile Include="Locking\LockManagerTests.cs" />
<Compile Include="Environment\Compilation\Dependencies\AssemblyProbingFolderTests.cs" />
<Compile Include="Environment\Compilation\Dependencies\DependencyDescriptorManagerTests.cs" />
<Compile Include="FileSystems\VirtualPath\DefaultVirtualPathProviderTests.cs" />
<Compile Include="Localization\CultureManagerTests.cs" />
<Compile Include="Logging\OrchardFileAppenderTests.cs" />
@@ -274,6 +274,7 @@
<Compile Include="Stubs\StubVirtualPathMonitor.cs" />
<Compile Include="Stubs\StubCacheManager.cs" />
<Compile Include="Stubs\StubWebSiteFolder.cs" />
<Compile Include="Time\TimeZoneSelectorTests.cs" />
<Compile Include="UI\Resources\ResourceManagerTests.cs" />
<Compile Include="UI\ShapeTests.cs" />
<Compile Include="Utility\ContainerExtensions.cs" />
@@ -309,8 +310,6 @@
<Compile Include="UI\Navigation\NavigationManagerTests.cs" />
<Compile Include="UI\Navigation\PositionComparerTests.cs" />
<Compile Include="Utility\Extensions\StringExtensionsTests.cs" />
<Compile Include="Utility\ReflectOnTests.cs" />
<Compile Include="Utility\ReflectTests.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Orchard.Web\Core\Orchard.Core.csproj">

View File

@@ -6,7 +6,6 @@ using NUnit.Framework;
using Orchard.Environment.Configuration;
using Orchard.Security;
using Orchard.Security.Providers;
using Orchard.Utility.Extensions;
namespace Orchard.Tests.Security {
[TestFixture]

View File

@@ -53,5 +53,13 @@ namespace Orchard.Tests.Stubs {
public IVolatileToken WhenPathChanges(string virtualPath) {
throw new NotImplementedException();
}
public DateTime GetFileLastWriteTimeUtc(string virtualPath) {
throw new NotImplementedException();
}
public bool TryFileExists(string virtualPath) {
throw new NotImplementedException();
}
}
}

View File

@@ -5,6 +5,7 @@ using System.Linq;
using Orchard.Caching;
using Orchard.FileSystems.AppData;
using Orchard.Services;
using Orchard.Time;
namespace Orchard.Tests.Stubs {
public class StubAppDataFolder : IAppDataFolder {
@@ -36,77 +37,45 @@ namespace Orchard.Tests.Stubs {
return entry.Entries.Where(e => e is StubFileSystem.DirectoryEntry).Select(e => Combine(path, e.Name));
}
public bool FileExists(string path) {
return _fileSystem.GetFileEntry(path) != null;
}
public string Combine(params string[] paths) {
return Path.Combine(paths).Replace(Path.DirectorySeparatorChar, '/');
}
public void CreateFile(string path, string content) {
using (var stream = CreateFile(path)) {
public void StoreFile(string path, string content) {
using (var stream = _fileSystem.CreateFile(path)) {
using (var writer = new StreamWriter(stream)) {
writer.Write(content);
}
}
}
public Stream CreateFile(string path) {
return _fileSystem.CreateFile(path);
}
public string ReadFile(string path) {
using (var stream = OpenFile(path)) {
using (var reader = new StreamReader(stream)) {
return reader.ReadToEnd();
try {
using (var stream = OpenFile(path)) {
using (var reader = new StreamReader(stream)) {
return reader.ReadToEnd();
}
}
}
catch (InvalidOperationException) {
return null;
}
}
public Stream OpenFile(string path) {
return _fileSystem.OpenFile(path);
}
public void StoreFile(string sourceFileName, string destinationPath) {
using (var inputStream = File.OpenRead(sourceFileName)) {
using (var outputStream = _fileSystem.CreateFile(destinationPath)) {
byte[] buffer = new byte[1024];
for (; ; ) {
var count = inputStream.Read(buffer, 0, buffer.Length);
if (count == 0)
break;
outputStream.Write(buffer, 0, count);
}
}
}
}
public void DeleteFile(string path) {
_fileSystem.DeleteFile(path);
}
public DateTime GetFileLastWriteTimeUtc(string path) {
var entry = _fileSystem.GetFileEntry(path);
if (entry == null)
throw new ArgumentException();
return entry.LastWriteTimeUtc;
}
public void CreateDirectory(string path) {
_fileSystem.CreateDirectoryEntry(path);
}
public bool DirectoryExists(string path) {
return _fileSystem.GetDirectoryEntry(path) != null;
}
public IVolatileToken WhenPathChanges(string path) {
return _fileSystem.WhenPathChanges(path);
}
public string MapPath(string path) {
throw new NotImplementedException();
return path;
}
public string GetVirtualPath(string path) {

View File

@@ -1,6 +1,7 @@
using System;
using Orchard.Caching;
using Orchard.Services;
using Orchard.Time;
namespace Orchard.Tests.Stubs {
public class StubClock : IClock {

View File

@@ -5,6 +5,7 @@ using System.IO;
using System.Linq;
using Orchard.Caching;
using Orchard.Services;
using Orchard.Time;
namespace Orchard.Tests.Stubs {
public class StubFileSystem {

View File

@@ -1,5 +1,5 @@
using Orchard.Caching;
using Orchard.FileSystems.VirtualPath;
using Orchard.AspNet.Abstractions;
using Orchard.Caching;
namespace Orchard.Tests.Stubs {
public class StubVirtualPathMonitor : IVirtualPathMonitor {

View File

@@ -2,7 +2,8 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Orchard.FileSystems.VirtualPath;
using System.Web;
using Orchard.AspNet.Abstractions;
namespace Orchard.Tests.Stubs {
public class StubVirtualPathProvider : IVirtualPathProvider {
@@ -110,5 +111,18 @@ namespace Orchard.Tests.Stubs {
return false;
}
}
public string ToAbsolute(string virtualPath) {
throw new NotImplementedException();
}
public bool IsAppRelative(string virtualPath) {
return !string.IsNullOrEmpty(virtualPath) && virtualPath.StartsWith("~");
}
public bool IsAbsolute(string virtualPath) {
return !string.IsNullOrEmpty(virtualPath) && virtualPath.StartsWith("/");
}
}
}

View File

@@ -51,5 +51,13 @@ namespace Orchard.Tests.Stubs {
public class Token : IVolatileToken {
public bool IsCurrent { get; set; }
}
public DateTime GetFileLastWriteTimeUtc(string virtualPath) {
throw new NotImplementedException();
}
public bool TryFileExists(string virtualPath) {
throw new NotImplementedException();
}
}
}

View File

@@ -77,6 +77,11 @@ namespace Orchard.Tests.Stubs {
}
public string BaseUrl { get; set;}
public string SiteTimeZone {
get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); }
}
}
public class StubUser : IUser {

View File

@@ -0,0 +1,79 @@
using System;
using System.Web;
using Autofac;
using NUnit.Framework;
using Orchard.Time;
namespace Orchard.Tests.Time {
[TestFixture]
public class TimeZoneProviderTests {
private IContainer _container;
private IWorkContextStateProvider _workContextStateProvider;
private TestTimeZoneSelector _timeZoneSelector;
[SetUp]
public void Init() {
var builder = new ContainerBuilder();
builder.RegisterInstance(_timeZoneSelector = new TestTimeZoneSelector()).As<ITimeZoneSelector>();
builder.RegisterType<CurrentTimeZoneWorkContext>().As<IWorkContextStateProvider>();
_container = builder.Build();
_workContextStateProvider = _container.Resolve<IWorkContextStateProvider>();
}
[Test]
public void ShouldProvideCurrentTimeZoneOnly() {
_timeZoneSelector.TimeZone = null;
var timeZone = _workContextStateProvider.Get<TimeZoneInfo>("Foo");
Assert.That(timeZone, Is.Null);
}
[Test]
public void DefaultTimeZoneIsUtc() {
_timeZoneSelector.TimeZone = null;
var timeZone = _workContextStateProvider.Get<TimeZoneInfo>("CurrentTimeZone");
Assert.That(timeZone(new StubWorkContext()), Is.EqualTo(TimeZoneInfo.Utc));
}
[Test]
public void TimeZoneProviderReturnsTimeZoneFromSelector() {
_timeZoneSelector.TimeZone = TimeZoneInfo.Local;
var timeZone = _workContextStateProvider.Get<TimeZoneInfo>("CurrentTimeZone");
Assert.That(timeZone(new StubWorkContext()), Is.EqualTo(TimeZoneInfo.Local));
}
}
public class TestTimeZoneSelector : ITimeZoneSelector {
public TimeZoneInfo TimeZone { get; set; }
public int Priority { get; set; }
public TimeZoneSelectorResult GetTimeZone(HttpContextBase context) {
return new TimeZoneSelectorResult {
Priority = Priority,
TimeZone= TimeZone
};
}
}
public class StubWorkContext : WorkContext {
public override T Resolve<T>() {
throw new NotImplementedException();
}
public override bool TryResolve<T>(out T service) {
throw new NotImplementedException();
}
public override T GetState<T>(string name) {
return default(T);
}
public override void SetState<T>(string name, T value) {
}
}
}

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using NUnit.Framework;
using Orchard.UI;
@@ -10,7 +11,7 @@ namespace Orchard.Tests.UI.Navigation {
[SetUp]
public void Init() {
_comparer = new FlatPositionComparer();
_comparer = new PositionComparer();
}
@@ -23,12 +24,43 @@ namespace Orchard.Tests.UI.Navigation {
Assert.That(greaterThan, Is.GreaterThan(0));
}
[Test]
public void AfterIsAlwaysAfter() {
AssertMore("after", null);
AssertMore("after", "");
AssertMore("after", "0");
AssertMore("after", "-1");
AssertMore("after", "foo");
AssertMore("after", int.MaxValue.ToString());
AssertMore("after", "before");
AssertSame("after", "after");
AssertLess("after", "after.");
AssertLess("after", "after.-10");
AssertLess("after", "after.10");
}
[Test]
public void BeforeIsAlways() {
AssertLess("before", null);
AssertLess("before", "");
AssertLess("before", "0");
AssertLess("before", "-1");
AssertLess("before", "foo");
AssertLess("before", int.MaxValue.ToString());
AssertSame("before", "before");
AssertLess("before", "after");
AssertLess("before", "before.");
AssertLess("before", "before.-10");
AssertLess("before", "before.10");
}
[Test]
public void NullIsLessThanEmptyAndEmptyIsLessThanNonEmpty() {
Assert.That(_comparer.Compare(null, ""), Is.LessThan(0));
Assert.That(_comparer.Compare("", "5"), Is.LessThan(0));
Assert.That(_comparer.Compare(null, "5"), Is.LessThan(0));
Assert.That(_comparer.Compare(null, "0"), Is.LessThan(0));
Assert.That(_comparer.Compare("", null), Is.GreaterThan(0));
Assert.That(_comparer.Compare("5", ""), Is.GreaterThan(0));
@@ -36,6 +68,7 @@ namespace Orchard.Tests.UI.Navigation {
Assert.That(_comparer.Compare(null, null), Is.EqualTo(0));
Assert.That(_comparer.Compare("", ""), Is.EqualTo(0));
Assert.That(_comparer.Compare("", "0"), Is.LessThan(0));
}
[Test]
@@ -87,6 +120,12 @@ namespace Orchard.Tests.UI.Navigation {
[Test]
public void NonNumericValuesCompareOrdinallyAndIgnoreCase() {
AssertLess("a", "c");
AssertLess("1", "x");
AssertLess("10", "x");
AssertLess("10", "bar");
AssertLess(int.MaxValue.ToString(), "bar");
AssertSame("x", "X");
AssertLess("rt675x", "rt685x");
AssertMore("ru675x", "rt675x");
@@ -106,6 +145,9 @@ namespace Orchard.Tests.UI.Navigation {
AssertLess("1.rt675x", "1.rt685x");
AssertMore("1.ru675x", "1.rt675x");
AssertLess("1.rt675x", "1.rt675y");
AssertSame("before", "Before");
AssertSame("after", "After");
}
[Test]
@@ -113,7 +155,6 @@ namespace Orchard.Tests.UI.Navigation {
AssertLess("rt675x", "rt675xx");
}
[Test]
public void EmptyBitsAreSafeAndShouldComeFirst() {
AssertSame("1.2.3", "1.2.3");
@@ -132,24 +173,111 @@ namespace Orchard.Tests.UI.Navigation {
[Test]
public void AdditionalNonEmptySegmentsShouldComeLater() {
AssertLess("1.2", "1.2.3");
AssertSame("1.2", "1.2.");
AssertLess("1.2", "1.2.");
AssertLess("a.b", "a.b.c");
AssertSame("a.b", "a.b.");
AssertLess("a.b", "a.b.");
AssertLess("a.b", "a.b.-1");
AssertLess("a.b", "a.b.before");
AssertLess("a.b", "a.b.after");
}
[Test]
public void AfterShouldReturnGreaterValues() {
AssertMore(PositionComparer.After(null), null);
AssertMore(PositionComparer.After(""), "");
AssertMore(PositionComparer.After("-1"), "-1");
AssertMore(PositionComparer.After("before"), "before");
AssertSame(PositionComparer.After("after"), "after");
AssertMore(PositionComparer.After("42"), "42");
AssertMore(PositionComparer.After("foo"), "foo");
AssertMore(PositionComparer.After("a.b"), "a.b");
AssertMore(PositionComparer.After("1.2"), "1.2");
AssertMore(PositionComparer.After("1."), "1.");
AssertMore(PositionComparer.After("-0"), "-0");
}
[Test]
public void BeforeShouldReturnLowerValues() {
AssertLess(PositionComparer.Before(null), null);
AssertLess(PositionComparer.Before(""), "");
AssertLess(PositionComparer.Before("-1"), "-1");
AssertSame(PositionComparer.Before("before"), "before");
AssertLess(PositionComparer.Before("after"), "after");
AssertLess(PositionComparer.Before("42"), "42");
AssertLess(PositionComparer.Before("foo"), "foo");
AssertLess(PositionComparer.Before("a.b"), "a.b");
AssertLess(PositionComparer.Before("1.2"), "1.2");
AssertLess(PositionComparer.Before("1."), "1.");
AssertLess(PositionComparer.Before("-0"), "-0");
}
[Test]
public void MaxShouldReturnTheGreaterValue() {
Assert.That(PositionComparer.Max("1", "2"), Is.EqualTo("2"));
Assert.That(PositionComparer.Max("a", "c"), Is.EqualTo("c"));
}
[Test]
public void MinShouldReturnTheLowerValue() {
Assert.That(PositionComparer.Min("1", "2"), Is.EqualTo("1"));
Assert.That(PositionComparer.Min("a", "c"), Is.EqualTo("a"));
}
[Test]
public void EqualValuesShouldReturnFirstParameter() {
Assert.That(PositionComparer.Between("1.01", "1.001"), Is.EqualTo("1.01"));
Assert.That(PositionComparer.Between("before", "before"), Is.EqualTo("before"));
Assert.That(PositionComparer.Between("before.1", "before.1"), Is.EqualTo("before.1"));
}
[Test]
public void ShouldComputeAverageValues() {
Assert.That(PositionComparer.Between("1", "3"), Is.EqualTo("2"));
Assert.That(PositionComparer.Between("-5", "0005"), Is.EqualTo("0"));
AssertBetween("a", "c");
AssertBetween("-10", "10");
AssertBetween("foo", "bar");
AssertBetween("-10", "bar");
AssertBetween("10", "bar");
AssertBetween("10", "before");
AssertBetween("10", "after");
AssertBetween("after", "before");
// adjacent cases
AssertBetween("1", "2");
AssertBetween("1.1", "1.2");
AssertBetween("ae", "bb");
}
[DebuggerStepThrough]
void AssertLess(string x, string y) {
Assert.That(_comparer.Compare(x, y), Is.LessThan(0));
Assert.That(_comparer.Compare(y, x), Is.GreaterThan(0));
}
[DebuggerStepThrough]
void AssertMore(string x, string y) {
Assert.That(_comparer.Compare(x, y), Is.GreaterThan(0));
Assert.That(_comparer.Compare(y, x), Is.LessThan(0));
}
[DebuggerStepThrough]
void AssertSame(string x, string y) {
Assert.That(_comparer.Compare(x, y), Is.EqualTo(0));
Assert.That(_comparer.Compare(y, x), Is.EqualTo(0));
}
void AssertBetween(string x, string y) {
var min = PositionComparer.Min(x, y);
var max = PositionComparer.Max(x, y);
var mean = PositionComparer.Between(x, y);
AssertLess(mean, max);
AssertMore(mean, min);
}
}
}

View File

@@ -3,6 +3,7 @@ using System.Linq;
using System.Collections.Generic;
using Autofac;
using NUnit.Framework;
using Orchard.AspNet.Abstractions;
using Orchard.DisplayManagement.Implementation;
using Orchard.Tests.Stubs;
using Orchard.UI.Admin;
@@ -42,6 +43,8 @@ namespace Orchard.Tests.UI.Resources {
var builder = new ContainerBuilder();
builder.RegisterType<ResourceManager>().As<IResourceManager>();
builder.RegisterType<TestManifestProvider>().As<IResourceManifestProvider>().SingleInstance();
var stubVpp = new StubVirtualPathProvider(null);
builder.RegisterInstance(stubVpp).As<IVirtualPathProvider>();
_container = builder.Build();
_resourceManager = _container.Resolve<IResourceManager>();
_testManifest = _container.Resolve<IResourceManifestProvider>() as TestManifestProvider;

View File

@@ -69,7 +69,7 @@ namespace Orchard.Tests.Utility.Extensions {
}
[Test]
public void HtmlClassify_SimpleStringReturnsSimpleClassName() {
const string toClassify = "this is something";
const string toClassify = ".this is something";
Assert.That(toClassify.HtmlClassify(), Is.StringMatching("this-is-something"));
}
[Test]
@@ -145,26 +145,5 @@ namespace Orchard.Tests.Utility.Extensions {
const string fullOfTags = null;
Assert.That(fullOfTags.RemoveTags(), Is.StringMatching(""));
}
[Test]
public void ReplaceNewLinesWith_ReplaceCRLFWithHtmlBR() {
const string lotsOfLineFeeds = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\r\nMaecenas sed purus quis purus orci aliquam.";
Assert.That(lotsOfLineFeeds.ReplaceNewLinesWith("<br />"), Is.StringMatching("Lorem ipsum dolor sit amet, consectetur adipiscing elit.<br />Maecenas sed purus quis purus orci aliquam."));
}
[Test]
public void ReplaceNewLinesWith_ReplaceCRLFWithHtmlPsAndCRLF() {
const string lotsOfLineFeeds = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.\r\nMaecenas sed purus quis purus orci aliquam.";
Assert.That(lotsOfLineFeeds.ReplaceNewLinesWith(@"</p>$1<p>"), Is.StringMatching("Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>\r\n<p>Maecenas sed purus quis purus orci aliquam."));
}
[Test]
public void ReplaceNewLinesWith_EmptyStringReturnsEmptyString() {
const string lotsOfLineFeeds = "";
Assert.That(lotsOfLineFeeds.ReplaceNewLinesWith("<br />"), Is.StringMatching(""));
}
[Test]
public void ReplaceNewLinesWith_NullValueReturnsEmptyString() {
const string lotsOfLineFeeds = null;
Assert.That(lotsOfLineFeeds.ReplaceNewLinesWith("<br />"), Is.StringMatching(""));
}
}
}

View File

@@ -1,62 +0,0 @@
using NUnit.Framework;
using Orchard.Utility;
namespace Orchard.Tests.Utility {
[TestFixture]
public class ReflectOnTests {
private class TestClass {
public int MyField;
public int MyField2;
public int MyProperty { get { MyField = 5; return MyField; } }
public int MyProperty2 { get { MyField2 = 5; return MyField2; } }
public void MyMethod(int i) { }
public int MyMethod(string s) { return 5; }
public void MyMethod2(int i) { }
public int MyMethod2(string s) { return 5; }
public TestClass MyTestClass { get { return null; } }
public TestClass this[int i] { get { return null; } }
}
[Test]
public void ReflectOnGetMemberShouldReturnCorrectMemberInfo() {
Assert.That(ReflectOn<TestClass>.GetMember(p => p.MyField).Name, Is.EqualTo("MyField"));
Assert.That(ReflectOn<TestClass>.GetMember(p => p.MyMethod(5)).Name, Is.EqualTo("MyMethod"));
}
[Test]
public void ReflectOnShouldWorkOnFields() {
Assert.That(ReflectOn<TestClass>.GetField(p => p.MyField).Name, Is.EqualTo("MyField"));
Assert.That(ReflectOn<TestClass>.GetField(p => p.MyField2).Name, Is.EqualTo("MyField2"));
}
[Test]
public void ReflectOnShouldWorkOnProperties() {
Assert.That(ReflectOn<TestClass>.GetProperty(p => p.MyProperty).Name, Is.EqualTo("MyProperty"));
Assert.That(ReflectOn<TestClass>.GetProperty(p => p.MyProperty2).Name, Is.EqualTo("MyProperty2"));
}
[Test]
public void ReflectOnShouldWorkOnMethods() {
Assert.That(ReflectOn<TestClass>.GetMethod(p => p.MyMethod(5)).Name, Is.EqualTo("MyMethod"));
Assert.That(ReflectOn<TestClass>.GetMethod(p => p.MyMethod("")).Name, Is.EqualTo("MyMethod"));
Assert.That(ReflectOn<TestClass>.GetMethod(p => p.MyMethod("")).ReturnType, Is.EqualTo(typeof(int)));
Assert.That(ReflectOn<TestClass>.GetMethod(p => p.MyMethod2(5)).Name, Is.EqualTo("MyMethod2"));
Assert.That(ReflectOn<TestClass>.GetMethod(p => p.MyMethod2("")).Name, Is.EqualTo("MyMethod2"));
Assert.That(ReflectOn<TestClass>.GetMethod(p => p.MyMethod2("")).ReturnType, Is.EqualTo(typeof(int)));
}
[Test]
public void ReflectOnShouldWorkOnDottedProperties() {
Assert.That(ReflectOn<TestClass>.NameOf(p => p.MyTestClass.MyTestClass.MyProperty), Is.EqualTo("MyTestClass.MyTestClass.MyProperty"));
}
[Test]
public void ReflectOnShouldWorkOnIndexers() {
Assert.That(ReflectOn<TestClass>.NameOf(p => p[0].MyTestClass[1].MyProperty), Is.EqualTo("[0].MyTestClass[1].MyProperty"));
int j = 5;
int index = j;
Assert.That(ReflectOn<TestClass>.NameOf(p => p.MyTestClass[index].MyProperty), Is.EqualTo("MyTestClass[5].MyProperty"));
}
}
}

View File

@@ -1,47 +0,0 @@
using NUnit.Framework;
using Orchard.Utility;
namespace Orchard.Tests.Utility {
[TestFixture]
public class ReflectTests {
private class TestClass {
public static int MyField;
public static int MyField2;
public static int MyProperty { get { MyField = 5; return MyField; } }
public static int MyProperty2 { get { MyField2 = 5; return MyField2; } }
public static void MyMethod(int i) { }
public static int MyMethod(string s) { return 5; }
public static void MyMethod2(int i) { }
public static int MyMethod2(string s) { return 5; }
}
[Test]
public void ReflectGetMemberShouldReturnCorrectMemberInfo() {
Assert.That(Reflect.GetMember(() => TestClass.MyField).Name, Is.EqualTo("MyField"));
Assert.That(Reflect.GetMember(() => TestClass.MyMethod(5)).Name, Is.EqualTo("MyMethod"));
}
[Test]
public void ReflectShouldWorkOnFields() {
Assert.That(Reflect.GetField(() => TestClass.MyField).Name, Is.EqualTo("MyField"));
Assert.That(Reflect.GetField(() => TestClass.MyField2).Name, Is.EqualTo("MyField2"));
}
[Test]
public void ReflectShouldWorkOnProperties() {
Assert.That(Reflect.GetProperty(() => TestClass.MyProperty).Name, Is.EqualTo("MyProperty"));
Assert.That(Reflect.GetProperty(() => TestClass.MyProperty2).Name, Is.EqualTo("MyProperty2"));
}
[Test]
public void ReflectShouldWorkOnMethods() {
Assert.That(Reflect.GetMethod(() => TestClass.MyMethod(5)).Name, Is.EqualTo("MyMethod"));
Assert.That(Reflect.GetMethod(() => TestClass.MyMethod("")).Name, Is.EqualTo("MyMethod"));
Assert.That(Reflect.GetMethod(() => TestClass.MyMethod("")).ReturnType, Is.EqualTo(typeof(int)));
Assert.That(Reflect.GetMethod(() => TestClass.MyMethod2(5)).Name, Is.EqualTo("MyMethod2"));
Assert.That(Reflect.GetMethod(() => TestClass.MyMethod2("")).Name, Is.EqualTo("MyMethod2"));
Assert.That(Reflect.GetMethod(() => TestClass.MyMethod2("")).ReturnType, Is.EqualTo(typeof(int)));
}
}
}

View File

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

View File

@@ -1,8 +1,8 @@
using System.Collections.Generic;
using Orchard.ContentManagement;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.MetaData.Builders;
using Orchard.ContentManagement.MetaData.Models;
using Orchard.ContentManagement.Definition;
using Orchard.ContentManagement.Definition.Builders;
using Orchard.ContentManagement.Definition.Models;
using Orchard.ContentManagement.ViewModels;
namespace Orchard.Core.Common.DateEditor {

View File

@@ -1,9 +1,9 @@
using System.Collections.Generic;
using System.Linq;
using System.Web;
using JetBrains.Annotations;
using System.Web.Mvc;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Aspects;
using Orchard.ContentManagement.Parts;
using Orchard.ContentManagement.Drivers;
using Orchard.Core.Common.Models;
using Orchard.Core.Common.Settings;
@@ -12,7 +12,6 @@ using Orchard.Core.Routable.Models;
using Orchard.Services;
namespace Orchard.Core.Common.Drivers {
[UsedImplicitly]
public class BodyPartDriver : ContentPartDriver<BodyPart> {
private readonly IEnumerable<IHtmlFilter> _htmlFilters;
@@ -72,8 +71,7 @@ namespace Orchard.Core.Common.Drivers {
private static BodyEditorViewModel BuildEditorViewModel(BodyPart part) {
return new BodyEditorViewModel {
BodyPart = part,
EditorFlavor = GetFlavor(part),
AddMediaPath = new PathBuilder(part).AddContentType().AddContainerSlug().AddSlug().ToString()
EditorFlavor = GetFlavor(part)
};
}
@@ -83,55 +81,5 @@ namespace Orchard.Core.Common.Drivers {
? typePartSettings.Flavor
: part.PartDefinition.Settings.GetModel<BodyPartSettings>().FlavorDefault;
}
class PathBuilder {
private readonly IContent _content;
private string _path;
public PathBuilder(IContent content) {
_content = content;
_path = "";
}
public override string ToString() {
return _path;
}
public PathBuilder AddContentType() {
Add(_content.ContentItem.ContentType);
return this;
}
public PathBuilder AddContainerSlug() {
var common = _content.As<ICommonPart>();
if (common == null)
return this;
var routable = common.Container.As<RoutePart>();
if (routable == null)
return this;
Add(routable.Slug);
return this;
}
public PathBuilder AddSlug() {
var routable = _content.As<RoutePart>();
if (routable == null)
return this;
Add(routable.Slug);
return this;
}
private void Add(string segment) {
if (string.IsNullOrEmpty(segment))
return;
if (string.IsNullOrEmpty(_path))
_path = segment;
else
_path = _path + "/" + segment;
}
}
}
}

View File

@@ -1,10 +1,8 @@
using JetBrains.Annotations;
using Orchard.ContentManagement.Drivers;
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,11 +1,9 @@
using JetBrains.Annotations;
using Orchard.ContentManagement;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Drivers;
using Orchard.ContentManagement.Handlers;
using Orchard.Core.Common.Fields;
namespace Orchard.Core.Common.Drivers {
[UsedImplicitly]
public class TextFieldDriver : ContentFieldDriver<TextField> {
public TextFieldDriver(IOrchardServices services) {
Services = services;

View File

@@ -1,10 +1,8 @@
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,17 +1,14 @@
using System;
using System.Linq;
using JetBrains.Annotations;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.Definition;
using Orchard.Core.Common.Models;
using Orchard.Data;
using Orchard.Localization;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers;
using Orchard.Security;
using Orchard.Services;
using Orchard.Time;
namespace Orchard.Core.Common.Handlers {
[UsedImplicitly]
public class CommonPartHandler : ContentHandler {
private readonly IClock _clock;
private readonly IAuthenticationService _authenticationService;
@@ -124,8 +121,8 @@ 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.OwnerField.Loader(value => _contentManager.Get<IUser>(part.Record.OwnerId));
part.ContainerField.Loader(value => part.Record.Container == null ? null : _contentManager.Get(part.Record.Container.Id));
}
protected static void PropertySetHandlers(ActivatedContentContext context, CommonPart part) {

View File

@@ -1,12 +1,10 @@
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) {
Filters.Add(StorageFilter.For(identityRepository));

View File

@@ -1,5 +1,5 @@
using System;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.Definition;
using Orchard.Core.Contents.Extensions;
using Orchard.Data.Migration;

View File

@@ -1,8 +1,8 @@
using System;
using Orchard.Core.Common.Utilities;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Aspects;
using Orchard.ContentManagement.Parts;
using Orchard.Security;
using Orchard.Utility;
namespace Orchard.Core.Common.Models {
public class CommonPart : ContentPart<CommonPartRecord>, ICommonPart {

View File

@@ -4,7 +4,7 @@ Author: The Orchard Team
Website: http://orchardproject.net
Version: 1.2.0
OrchardVersion: 1.2.0
Description: The common module introduces content parts that are going to be used by most content types (common, body and routable).
Description: The common module introduces content parts that are going to be used by most content types (common, body and route).
FeatureDescription: Core content parts.
Dependencies: Settings
Category: Core

View File

@@ -1,8 +1,8 @@
using System.Collections.Generic;
using Orchard.ContentManagement;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.MetaData.Builders;
using Orchard.ContentManagement.MetaData.Models;
using Orchard.ContentManagement.Definition;
using Orchard.ContentManagement.Definition.Builders;
using Orchard.ContentManagement.Definition.Models;
using Orchard.ContentManagement.ViewModels;
namespace Orchard.Core.Common.OwnerEditor {

View File

@@ -1,8 +1,8 @@
using System.Collections.Generic;
using Orchard.ContentManagement;
using Orchard.ContentManagement.MetaData;
using Orchard.ContentManagement.MetaData.Builders;
using Orchard.ContentManagement.MetaData.Models;
using Orchard.ContentManagement.Definition;
using Orchard.ContentManagement.Definition.Builders;
using Orchard.ContentManagement.Definition.Models;
using Orchard.ContentManagement.ViewModels;
namespace Orchard.Core.Common.Settings {

View File

@@ -23,12 +23,12 @@ namespace Orchard.Core.Common {
}
[Shape]
public IHtmlString PublishedState(HtmlHelper html, DateTime createdDateTimeUtc, DateTime? publisheddateTimeUtc) {
public IHtmlString PublishedState(dynamic Display, DateTime createdDateTimeUtc, DateTime? publisheddateTimeUtc) {
if (!publisheddateTimeUtc.HasValue) {
return T("Draft");
}
return html.DateTime(createdDateTimeUtc);
return Display.DateTime(DateTimeUtc: createdDateTimeUtc);
}
[Shape]
@@ -36,7 +36,7 @@ namespace Orchard.Core.Common {
if (dateTimeUtc == null)
return T("as a Draft");
return Display.DateTimeRelative(dateTimeUtc: dateTimeUtc);
return Display.DateTimeRelative(DateTimeUtc: dateTimeUtc);
}
}
}

View File

@@ -1,40 +0,0 @@
using System;
namespace Orchard.Core.Common.Utilities {
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);}
}
public void Loader(Func<T> loader) {
_loader = loader;
}
public void Setter(Func<T, T> setter) {
_setter = setter;
}
private T GetValue() {
if (_loader != null) {
_value = _loader();
_loader = null;
}
return _value;
}
private void SetValue(T value) {
_loader = null;
if (_setter != null) {
_value = _setter(value);
}
else {
_value = value;
}
}
}
}

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