mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Merge branch '1.9.x' into dev
Conflicts: src/Orchard.Tests.Modules/Users/Services/MembershipServiceTests.cs
This commit is contained in:
@@ -74,7 +74,6 @@ namespace Orchard.Tests.Modules.Users.Controllers {
|
|||||||
builder.RegisterType<UserPartHandler>().As<IContentHandler>();
|
builder.RegisterType<UserPartHandler>().As<IContentHandler>();
|
||||||
builder.RegisterType<OrchardServices>().As<IOrchardServices>();
|
builder.RegisterType<OrchardServices>().As<IOrchardServices>();
|
||||||
|
|
||||||
builder.RegisterInstance(new TestTransactionManager(_session)).As<ITransactionManager>();
|
|
||||||
builder.RegisterInstance(new Work<IEnumerable<IShapeTableEventHandler>>(resolve => _container.Resolve<IEnumerable<IShapeTableEventHandler>>())).AsSelf();
|
builder.RegisterInstance(new Work<IEnumerable<IShapeTableEventHandler>>(resolve => _container.Resolve<IEnumerable<IShapeTableEventHandler>>())).AsSelf();
|
||||||
builder.RegisterType<DefaultShapeTableManager>().As<IShapeTableManager>();
|
builder.RegisterType<DefaultShapeTableManager>().As<IShapeTableManager>();
|
||||||
builder.RegisterType<DefaultShapeFactory>().As<IShapeFactory>();
|
builder.RegisterType<DefaultShapeFactory>().As<IShapeFactory>();
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ using Orchard.UI.PageClass;
|
|||||||
using Orchard.Users.Handlers;
|
using Orchard.Users.Handlers;
|
||||||
using Orchard.Users.Models;
|
using Orchard.Users.Models;
|
||||||
using Orchard.Users.Services;
|
using Orchard.Users.Services;
|
||||||
|
using Orchard.Tests.ContentManagement;
|
||||||
using Orchard.Services;
|
using Orchard.Services;
|
||||||
|
|
||||||
namespace Orchard.Tests.Modules.Users.Services {
|
namespace Orchard.Tests.Modules.Users.Services {
|
||||||
@@ -41,19 +42,6 @@ namespace Orchard.Tests.Modules.Users.Services {
|
|||||||
private ISession _session;
|
private ISession _session;
|
||||||
private IContainer _container;
|
private IContainer _container;
|
||||||
private StubClock _clock;
|
private StubClock _clock;
|
||||||
|
|
||||||
public class TestSessionLocator : ISessionLocator {
|
|
||||||
private readonly ISession _session;
|
|
||||||
|
|
||||||
public TestSessionLocator(ISession session) {
|
|
||||||
_session = session;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ISession For(Type entityType) {
|
|
||||||
return _session;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestFixtureSetUp]
|
[TestFixtureSetUp]
|
||||||
public void InitFixture() {
|
public void InitFixture() {
|
||||||
var databaseFileName = System.IO.Path.GetTempFileName();
|
var databaseFileName = System.IO.Path.GetTempFileName();
|
||||||
@@ -98,12 +86,19 @@ namespace Orchard.Tests.Modules.Users.Services {
|
|||||||
builder.RegisterType<InfosetHandler>().As<IContentHandler>();
|
builder.RegisterType<InfosetHandler>().As<IContentHandler>();
|
||||||
|
|
||||||
_session = _sessionFactory.OpenSession();
|
_session = _sessionFactory.OpenSession();
|
||||||
builder.RegisterInstance(new TestSessionLocator(_session)).As<ISessionLocator>();
|
builder.RegisterInstance(new TestTransactionManager(_session)).As<ITransactionManager>();
|
||||||
|
|
||||||
_container = builder.Build();
|
_container = builder.Build();
|
||||||
_membershipValidationService = _container.Resolve<IMembershipValidationService>();
|
_membershipValidationService = _container.Resolve<IMembershipValidationService>();
|
||||||
_membershipService = _container.Resolve<IMembershipService>();
|
_membershipService = _container.Resolve<IMembershipService>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TearDown]
|
||||||
|
public void Cleanup() {
|
||||||
|
if (_container != null)
|
||||||
|
_container.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void CreateUserShouldAllocateModelAndCreateRecords() {
|
public void CreateUserShouldAllocateModelAndCreateRecords() {
|
||||||
var user = _membershipService.CreateUser(new CreateUserParams("a", "b", "c", null, null, true));
|
var user = _membershipService.CreateUser(new CreateUserParams("a", "b", "c", null, null, true));
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ using Orchard.Users.Services;
|
|||||||
using Orchard.Services;
|
using Orchard.Services;
|
||||||
using Orchard.Tests.Messaging;
|
using Orchard.Tests.Messaging;
|
||||||
using Orchard.Tests.Modules.Stubs;
|
using Orchard.Tests.Modules.Stubs;
|
||||||
|
using Orchard.Tests.ContentManagement;
|
||||||
|
|
||||||
namespace Orchard.Tests.Modules.Users.Services {
|
namespace Orchard.Tests.Modules.Users.Services {
|
||||||
[TestFixture]
|
[TestFixture]
|
||||||
@@ -47,19 +48,6 @@ namespace Orchard.Tests.Modules.Users.Services {
|
|||||||
private IContainer _container;
|
private IContainer _container;
|
||||||
private CultureInfo _currentCulture;
|
private CultureInfo _currentCulture;
|
||||||
|
|
||||||
|
|
||||||
public class TestSessionLocator : ISessionLocator {
|
|
||||||
private readonly ISession _session;
|
|
||||||
|
|
||||||
public TestSessionLocator(ISession session) {
|
|
||||||
_session = session;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ISession For(Type entityType) {
|
|
||||||
return _session;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestFixtureSetUp]
|
[TestFixtureSetUp]
|
||||||
public void InitFixture() {
|
public void InitFixture() {
|
||||||
_currentCulture = Thread.CurrentThread.CurrentCulture;
|
_currentCulture = Thread.CurrentThread.CurrentCulture;
|
||||||
@@ -109,9 +97,8 @@ namespace Orchard.Tests.Modules.Users.Services {
|
|||||||
builder.RegisterInstance(ShellSettingsUtility.CreateEncryptionEnabled());
|
builder.RegisterInstance(ShellSettingsUtility.CreateEncryptionEnabled());
|
||||||
|
|
||||||
_session = _sessionFactory.OpenSession();
|
_session = _sessionFactory.OpenSession();
|
||||||
_session.BeginTransaction();
|
builder.RegisterInstance(new TestTransactionManager(_session)).As<ITransactionManager>();
|
||||||
|
|
||||||
builder.RegisterInstance(new TestSessionLocator(_session)).As<ISessionLocator>();
|
|
||||||
_container = builder.Build();
|
_container = builder.Build();
|
||||||
_membershipService = _container.Resolve<IMembershipService>();
|
_membershipService = _container.Resolve<IMembershipService>();
|
||||||
_userService = _container.Resolve<IUserService>();
|
_userService = _container.Resolve<IUserService>();
|
||||||
@@ -119,8 +106,8 @@ namespace Orchard.Tests.Modules.Users.Services {
|
|||||||
|
|
||||||
[TearDown]
|
[TearDown]
|
||||||
public void TearDown() {
|
public void TearDown() {
|
||||||
_session.Transaction.Commit();
|
if (_container != null)
|
||||||
_session.Transaction.Dispose();
|
_container.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
|||||||
@@ -498,10 +498,10 @@ namespace Orchard.Core.Shapes {
|
|||||||
|
|
||||||
var totalPageCount = pageSize > 0 ? (int)Math.Ceiling(TotalItemCount / pageSize) : 1;
|
var totalPageCount = pageSize > 0 ? (int)Math.Ceiling(TotalItemCount / pageSize) : 1;
|
||||||
|
|
||||||
var firstText = FirstText ?? T("<<");
|
var firstText = FirstText ?? T("<<");
|
||||||
var previousText = PreviousText ?? T("<");
|
var previousText = PreviousText ?? T("<");
|
||||||
var nextText = NextText ?? T(">");
|
var nextText = NextText ?? T(">");
|
||||||
var lastText = LastText ?? T(">>");
|
var lastText = LastText ?? T(">>");
|
||||||
var gapText = GapText ?? T("...");
|
var gapText = GapText ?? T("...");
|
||||||
|
|
||||||
var routeData = new RouteValueDictionary(Html.ViewContext.RouteData.Values);
|
var routeData = new RouteValueDictionary(Html.ViewContext.RouteData.Values);
|
||||||
|
|||||||
@@ -53,7 +53,10 @@ namespace Orchard.Localization.Controllers {
|
|||||||
var contentItemTranslation = _contentManager.New<LocalizationPart>(masterContentItem.ContentType);
|
var contentItemTranslation = _contentManager.New<LocalizationPart>(masterContentItem.ContentType);
|
||||||
contentItemTranslation.MasterContentItem = masterContentItem;
|
contentItemTranslation.MasterContentItem = masterContentItem;
|
||||||
|
|
||||||
var content = _contentManager.BuildEditor(contentItemTranslation);
|
// build the editor using the master content item so that
|
||||||
|
// the form is pre-populated with the original values
|
||||||
|
|
||||||
|
var content = _contentManager.BuildEditor(masterContentItem);
|
||||||
|
|
||||||
return View(content);
|
return View(content);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ using StackExchange.Redis;
|
|||||||
namespace Orchard.Redis.Configuration {
|
namespace Orchard.Redis.Configuration {
|
||||||
|
|
||||||
public class RedisConnectionProvider : IRedisConnectionProvider {
|
public class RedisConnectionProvider : IRedisConnectionProvider {
|
||||||
private static ConcurrentDictionary<string, ConnectionMultiplexer> _connectionMultiplexers = new ConcurrentDictionary<string, ConnectionMultiplexer>();
|
private static ConcurrentDictionary<string, Lazy<ConnectionMultiplexer>> _connectionMultiplexers = new ConcurrentDictionary<string, Lazy<ConnectionMultiplexer>>();
|
||||||
private readonly ShellSettings _shellSettings;
|
private readonly ShellSettings _shellSettings;
|
||||||
|
|
||||||
public RedisConnectionProvider(ShellSettings shellSettings) {
|
public RedisConnectionProvider(ShellSettings shellSettings) {
|
||||||
@@ -37,12 +37,16 @@ namespace Orchard.Redis.Configuration {
|
|||||||
throw new ArgumentNullException("connectionString");
|
throw new ArgumentNullException("connectionString");
|
||||||
}
|
}
|
||||||
|
|
||||||
var connectionMultiplexer = _connectionMultiplexers.GetOrAdd(connectionString, cfg => {
|
// when using ConcurrentDictionary, multiple threads can create the value
|
||||||
Logger.Debug("Creating a new cache client for: {0}", connectionString);
|
// at the same time, so we need to pass a Lazy so that it's only
|
||||||
return ConnectionMultiplexer.Connect(connectionString);
|
// the object which is added that will create a ConnectionMultiplexer,
|
||||||
});
|
// even when a delegate is passed
|
||||||
|
|
||||||
return connectionMultiplexer;
|
return _connectionMultiplexers.GetOrAdd(connectionString,
|
||||||
|
new Lazy<ConnectionMultiplexer>(() => {
|
||||||
|
Logger.Debug("Creating a new cache client for: {0}", connectionString);
|
||||||
|
return ConnectionMultiplexer.Connect(connectionString);
|
||||||
|
})).Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,7 +15,7 @@ namespace Orchard.Redis.OutputCache {
|
|||||||
|
|
||||||
[OrchardFeature("Orchard.Redis.OutputCache")]
|
[OrchardFeature("Orchard.Redis.OutputCache")]
|
||||||
[OrchardSuppressDependency("Orchard.OutputCache.Services.DefaultCacheStorageProvider")]
|
[OrchardSuppressDependency("Orchard.OutputCache.Services.DefaultCacheStorageProvider")]
|
||||||
public class RedisOutputCacheStorageProvider : Component, IOutputCacheStorageProvider {
|
public class RedisOutputCacheStorageProvider : IOutputCacheStorageProvider {
|
||||||
|
|
||||||
private readonly ShellSettings _shellSettings;
|
private readonly ShellSettings _shellSettings;
|
||||||
private readonly IRedisConnectionProvider _redisConnectionProvider;
|
private readonly IRedisConnectionProvider _redisConnectionProvider;
|
||||||
@@ -23,18 +23,22 @@ namespace Orchard.Redis.OutputCache {
|
|||||||
|
|
||||||
public const string ConnectionStringKey = "Orchard.Redis.OutputCache";
|
public const string ConnectionStringKey = "Orchard.Redis.OutputCache";
|
||||||
private readonly string _connectionString;
|
private readonly string _connectionString;
|
||||||
|
private readonly ConnectionMultiplexer _connectionMultiplexer;
|
||||||
|
|
||||||
public RedisOutputCacheStorageProvider(ShellSettings shellSettings, IRedisConnectionProvider redisConnectionProvider) {
|
public RedisOutputCacheStorageProvider(ShellSettings shellSettings, IRedisConnectionProvider redisConnectionProvider) {
|
||||||
_shellSettings = shellSettings;
|
_shellSettings = shellSettings;
|
||||||
_redisConnectionProvider = redisConnectionProvider;
|
_redisConnectionProvider = redisConnectionProvider;
|
||||||
_connectionString = _redisConnectionProvider.GetConnectionString(ConnectionStringKey);
|
_connectionString = _redisConnectionProvider.GetConnectionString(ConnectionStringKey);
|
||||||
|
_connectionMultiplexer = _redisConnectionProvider.GetConnection(_connectionString);
|
||||||
|
|
||||||
Logger = NullLogger.Instance;
|
Logger = NullLogger.Instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ILogger Logger { get; set; }
|
||||||
|
|
||||||
public IDatabase Database {
|
public IDatabase Database {
|
||||||
get {
|
get {
|
||||||
return _redisConnectionProvider.GetConnection(_connectionString).GetDatabase();
|
return _connectionMultiplexer.GetDatabase();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,9 +101,8 @@ namespace Orchard.Redis.OutputCache {
|
|||||||
_keysCache = new HashSet<string>();
|
_keysCache = new HashSet<string>();
|
||||||
var prefix = GetLocalizedKey("");
|
var prefix = GetLocalizedKey("");
|
||||||
|
|
||||||
var connection = _redisConnectionProvider.GetConnection(_connectionString);
|
foreach (var endPoint in _connectionMultiplexer.GetEndPoints()) {
|
||||||
foreach (var endPoint in connection.GetEndPoints()) {
|
var server = _connectionMultiplexer.GetServer(endPoint);
|
||||||
var server = connection.GetServer(endPoint);
|
|
||||||
foreach (var key in server.Keys(pattern: GetLocalizedKey("*"))) {
|
foreach (var key in server.Keys(pattern: GetLocalizedKey("*"))) {
|
||||||
_keysCache.Add(key.ToString().Substring(prefix.Length));
|
_keysCache.Add(key.ToString().Substring(prefix.Length));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
@{
|
@{
|
||||||
Model.PreviousText = T("<");
|
Model.PreviousText = T("<");
|
||||||
Model.NextText = T(">");
|
Model.NextText = T(">");
|
||||||
|
|
||||||
var routeData = new RouteValueDictionary(ViewContext.RouteData.Values);
|
var routeData = new RouteValueDictionary(ViewContext.RouteData.Values);
|
||||||
var queryString = ViewContext.HttpContext.Request.QueryString;
|
var queryString = ViewContext.HttpContext.Request.QueryString;
|
||||||
|
|||||||
Reference in New Issue
Block a user