mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 03:25:23 +08:00
Roughing in tests around topology descriptor manager
Implementation in settings module intended to live inside shell with access to current irepostory<> orm Basic tests around serial numbers and initial conditions and update behaviors Also sets expectations around event raising --HG-- branch : dev
This commit is contained in:
@@ -124,7 +124,10 @@
|
||||
<Compile Include="Settings\Drivers\SiteSettingsDriver.cs" />
|
||||
<Compile Include="Settings\Models\SiteSettingsRecord.cs" />
|
||||
<Compile Include="Settings\Permissions.cs" />
|
||||
<Compile Include="Settings\Services\TopologyDescriptorManager.cs" />
|
||||
<Compile Include="Settings\Topology\Records\TopologyFeatureRecord.cs" />
|
||||
<Compile Include="Settings\Topology\Records\TopologyParameterRecord.cs" />
|
||||
<Compile Include="Settings\Topology\Records\TopologyRecord.cs" />
|
||||
<Compile Include="Settings\Topology\TopologyDescriptorManager.cs" />
|
||||
<Compile Include="Themes\DesignerNotes\ZoneManagerEvents.cs" />
|
||||
<Compile Include="Themes\Preview\IPreviewTheme.cs" />
|
||||
<Compile Include="Themes\Preview\PreviewThemeFilter.cs" />
|
||||
|
@@ -1,18 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Orchard.Environment.Topology;
|
||||
using Orchard.Environment.Topology.Models;
|
||||
|
||||
namespace Orchard.Core.Settings.Services {
|
||||
public class TopologyDescriptorManager : ITopologyDescriptorManager {
|
||||
public ShellTopologyDescriptor GetTopologyDescriptor() {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public void UpdateTopologyDescriptor(int priorSerialNumber, IEnumerable<TopologyFeature> enabledFeatures, IEnumerable<TopologyParameter> parameters) {
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
namespace Orchard.Core.Settings.Topology.Records {
|
||||
public class TopologyFeatureRecord {
|
||||
public virtual int Id { get; set; }
|
||||
public virtual TopologyRecord TopologyRecord { get; set; }
|
||||
public virtual string Name { get; set; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
namespace Orchard.Core.Settings.Topology.Records {
|
||||
public class TopologyParameterRecord {
|
||||
public virtual int Id { get; set; }
|
||||
public virtual TopologyRecord TopologyRecord { get; set; }
|
||||
public virtual string Component { get; set; }
|
||||
public virtual string Name { get; set; }
|
||||
public virtual string Value { get; set; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Orchard.Core.Settings.Topology.Records {
|
||||
public class TopologyRecord {
|
||||
public virtual int Id { get; set; }
|
||||
public virtual int SerialNumber { get; set; }
|
||||
public virtual IList<TopologyFeatureRecord> EnabledFeatures { get; set; }
|
||||
public virtual IList<TopologyParameterRecord> Parameters { get; set; }
|
||||
}
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Orchard.Core.Settings.Topology.Records;
|
||||
using Orchard.Data;
|
||||
using Orchard.Environment.Topology;
|
||||
using Orchard.Environment.Topology.Models;
|
||||
using Orchard.Events;
|
||||
|
||||
namespace Orchard.Core.Settings.Topology {
|
||||
public class TopologyDescriptorManager : ITopologyDescriptorManager {
|
||||
private readonly IRepository<TopologyRecord> _repository;
|
||||
private readonly IEventBus _eventBus;
|
||||
private int _serialNumber;
|
||||
|
||||
public TopologyDescriptorManager(
|
||||
IRepository<TopologyRecord> repository,
|
||||
IEventBus eventBus) {
|
||||
_repository = repository;
|
||||
_eventBus = eventBus;
|
||||
}
|
||||
|
||||
public ShellTopologyDescriptor GetTopologyDescriptor() {
|
||||
return _serialNumber == 0 ? null : new ShellTopologyDescriptor { SerialNumber = _serialNumber };
|
||||
}
|
||||
|
||||
public void UpdateTopologyDescriptor(int priorSerialNumber, IEnumerable<TopologyFeature> enabledFeatures, IEnumerable<TopologyParameter> parameters) {
|
||||
if (priorSerialNumber != _serialNumber)
|
||||
throw new Exception();
|
||||
|
||||
++_serialNumber;
|
||||
_eventBus.Notify(
|
||||
typeof(ITopologyDescriptorManager).FullName + ".UpdateTopologyDescriptor",
|
||||
null);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user