public void ShouldNotSetDataStorageIfNoIRequireDataStorageCommandFound()
    {
      // arrange
      var commands = database.Engines.DataEngine.Commands;

      commands.AddFromTemplatePrototype = Substitute.For<Sitecore.Data.Engines.DataCommands.AddFromTemplateCommand>();
      commands.CreateItemPrototype = Substitute.For<Sitecore.Data.Engines.DataCommands.CreateItemCommand>();
      commands.DeletePrototype = Substitute.For<Sitecore.Data.Engines.DataCommands.DeleteItemCommand>();
      commands.GetChildrenPrototype = Substitute.For<Sitecore.Data.Engines.DataCommands.GetChildrenCommand>();
      commands.GetItemPrototype = Substitute.For<Sitecore.Data.Engines.DataCommands.GetItemCommand>();
      commands.GetParentPrototype = Substitute.For<Sitecore.Data.Engines.DataCommands.GetParentCommand>();
      commands.GetRootItemPrototype = Substitute.For<Sitecore.Data.Engines.DataCommands.GetRootItemCommand>();
      commands.HasChildrenPrototype = Substitute.For<Sitecore.Data.Engines.DataCommands.HasChildrenCommand>();
      commands.ResolvePathPrototype = Substitute.For<Sitecore.Data.Engines.DataCommands.ResolvePathCommand>();
      commands.SaveItemPrototype = Substitute.For<Sitecore.Data.Engines.DataCommands.SaveItemCommand>();

      var args = new InitDbArgs(database, dataStorage);
      var processor = new InitDataEngineCommands();

      // act
      Action action = () => processor.Process(args);

      // assert
      action.ShouldNotThrow();
    }
    public void ShouldSetDataStorageForIRequireDataStorageCommands()
    {
      // arrange
      var commands = database.Engines.DataEngine.Commands;

      commands.AddFromTemplatePrototype = Substitute.For<Sitecore.Data.Engines.DataCommands.AddFromTemplateCommand, IDataEngineCommand>();
      commands.CreateItemPrototype = Substitute.For<Sitecore.Data.Engines.DataCommands.CreateItemCommand, IDataEngineCommand>();
      commands.DeletePrototype = Substitute.For<Sitecore.Data.Engines.DataCommands.DeleteItemCommand, IDataEngineCommand>();
      commands.GetChildrenPrototype = Substitute.For<Sitecore.Data.Engines.DataCommands.GetChildrenCommand, IDataEngineCommand>();
      commands.GetItemPrototype = Substitute.For<Sitecore.Data.Engines.DataCommands.GetItemCommand, IDataEngineCommand>();
      commands.GetParentPrototype = Substitute.For<Sitecore.Data.Engines.DataCommands.GetParentCommand, IDataEngineCommand>();
      commands.GetRootItemPrototype = Substitute.For<Sitecore.Data.Engines.DataCommands.GetRootItemCommand, IDataEngineCommand>();
      commands.HasChildrenPrototype = Substitute.For<Sitecore.Data.Engines.DataCommands.HasChildrenCommand, IDataEngineCommand>();
      commands.ResolvePathPrototype = Substitute.For<Sitecore.Data.Engines.DataCommands.ResolvePathCommand, IDataEngineCommand>();
      commands.SaveItemPrototype = Substitute.For<Sitecore.Data.Engines.DataCommands.SaveItemCommand, IDataEngineCommand>();

      var args = new InitDbArgs(database, dataStorage);
      var processor = new InitDataEngineCommands();

      // act
      processor.Process(args);

      // assert
      ((IDataEngineCommand)commands.AddFromTemplatePrototype).Received().Initialize(Arg.Is<DataEngineCommand>(c => c.DataStorage == dataStorage));
      ((IDataEngineCommand)commands.CreateItemPrototype).Received().Initialize(Arg.Is<DataEngineCommand>(c => c.DataStorage == dataStorage));
      ((IDataEngineCommand)commands.DeletePrototype).Received().Initialize(Arg.Is<DataEngineCommand>(c => c.DataStorage == dataStorage));
      ((IDataEngineCommand)commands.GetChildrenPrototype).Received().Initialize(Arg.Is<DataEngineCommand>(c => c.DataStorage == dataStorage));
      ((IDataEngineCommand)commands.GetItemPrototype).Received().Initialize(Arg.Is<DataEngineCommand>(c => c.DataStorage == dataStorage));
      ((IDataEngineCommand)commands.GetParentPrototype).Received().Initialize(Arg.Is<DataEngineCommand>(c => c.DataStorage == dataStorage));
      ((IDataEngineCommand)commands.GetRootItemPrototype).Received().Initialize(Arg.Is<DataEngineCommand>(c => c.DataStorage == dataStorage));
      ((IDataEngineCommand)commands.HasChildrenPrototype).Received().Initialize(Arg.Is<DataEngineCommand>(c => c.DataStorage == dataStorage));
      ((IDataEngineCommand)commands.ResolvePathPrototype).Received().Initialize(Arg.Is<DataEngineCommand>(c => c.DataStorage == dataStorage));
      ((IDataEngineCommand)commands.SaveItemPrototype).Received().Initialize(Arg.Is<DataEngineCommand>(c => c.DataStorage == dataStorage));
    }
Beispiel #3
0
    /// <summary>
    /// Initializes a new instance of the <see cref="Db"/> class with the specified database.
    /// </summary>
    /// <param name="databaseName">The database name.</param>
    public Db(string databaseName)
    {
      Assert.ArgumentNotNullOrEmpty(databaseName, "databaseName");

      this.database = Database.GetDatabase(databaseName);
      this.dataStorage = new DataStorage(this.database);
      this.dataStorageSwitcher = new DataStorageSwitcher(this.dataStorage);
      this.databaseSwitcher = new DatabaseSwitcher(this.database);

      var args = new InitDbArgs(this.database, this.dataStorage);
      CorePipeline.Run("initFakeDb", args);
    }
Beispiel #4
0
    public Db(string databaseName)
    {
      this.database = Database.GetDatabase(databaseName);
      this.dataStorage = new DataStorage(this.database);

      var config = Factory.GetConfiguration();
      this.configuration = new DbConfiguration(config);
      this.pipelineWatcher = new PipelineWatcher(config);

      var args = new InitDbArgs(this.database, this.dataStorage);
      CorePipeline.Run("initFakeDb", args);
    }
    public void ShouldSetDatabaseAndDataStorage()
    {
      // arrange
      var database = Database.GetDatabase("master");
      var dataStorage = Substitute.For<DataStorage>(database);

      // act
      var args = new InitDbArgs(database, dataStorage);

      // assert
      args.Database.Should().Be(database);
      args.DataStorage.Should().Be(dataStorage);
    }
    public void ShouldSetDataStorageForIRequireDataStorageCommands()
    {
      // arrange
      var commands = this.database.Engines.DataEngine.Commands;

      commands.AddFromTemplatePrototype = Substitute.For<Sitecore.Data.Engines.DataCommands.AddFromTemplateCommand, IDataEngineCommand>();
      commands.AddVersionPrototype = Substitute.For<Sitecore.Data.Engines.DataCommands.AddVersionCommand, IDataEngineCommand>();
      commands.BlobStreamExistsPrototype = Substitute.For<Sitecore.Data.Engines.DataCommands.BlobStreamExistsCommand, IDataEngineCommand>();
      commands.CopyItemPrototype = Substitute.For<Sitecore.Data.Engines.DataCommands.CopyItemCommand, IDataEngineCommand>();
      commands.CreateItemPrototype = Substitute.For<Sitecore.Data.Engines.DataCommands.CreateItemCommand, IDataEngineCommand>();
      commands.DeletePrototype = Substitute.For<Sitecore.Data.Engines.DataCommands.DeleteItemCommand, IDataEngineCommand>();
      commands.GetBlobStreamPrototype = Substitute.For<Sitecore.Data.Engines.DataCommands.GetBlobStreamCommand, IDataEngineCommand>();
      commands.GetChildrenPrototype = Substitute.For<Sitecore.Data.Engines.DataCommands.GetChildrenCommand, IDataEngineCommand>();
      commands.GetItemPrototype = Substitute.For<Sitecore.Data.Engines.DataCommands.GetItemCommand, IDataEngineCommand>();
      commands.GetParentPrototype = Substitute.For<Sitecore.Data.Engines.DataCommands.GetParentCommand, IDataEngineCommand>();
      commands.GetRootItemPrototype = Substitute.For<Sitecore.Data.Engines.DataCommands.GetRootItemCommand, IDataEngineCommand>();
      commands.GetVersionsPrototype = Substitute.For<Sitecore.Data.Engines.DataCommands.GetVersionsCommand, IDataEngineCommand>();
      commands.HasChildrenPrototype = Substitute.For<Sitecore.Data.Engines.DataCommands.HasChildrenCommand, IDataEngineCommand>();
      commands.MoveItemPrototype = Substitute.For<Sitecore.Data.Engines.DataCommands.MoveItemCommand, IDataEngineCommand>();
      commands.RemoveVersionPrototype = Substitute.For<Sitecore.Data.Engines.DataCommands.RemoveVersionCommand, IDataEngineCommand>();
      commands.ResolvePathPrototype = Substitute.For<Sitecore.Data.Engines.DataCommands.ResolvePathCommand, IDataEngineCommand>();
      commands.SaveItemPrototype = Substitute.For<Sitecore.Data.Engines.DataCommands.SaveItemCommand, IDataEngineCommand>();
      commands.SetBlobStreamPrototype = Substitute.For<Sitecore.Data.Engines.DataCommands.SetBlobStreamCommand, IDataEngineCommand>();

      var args = new InitDbArgs(this.database, this.dataStorage);
      var processor = new InitDataEngineCommands();

      // act
      processor.Process(args);

      // assert
      ((IDataEngineCommand)commands.AddFromTemplatePrototype).Received().Initialize(Arg.Is<DataStorage>(ds => ds == this.dataStorage));
      ((IDataEngineCommand)commands.AddVersionPrototype).Received().Initialize(Arg.Is<DataStorage>(ds => ds == this.dataStorage));
      ((IDataEngineCommand)commands.BlobStreamExistsPrototype).Received().Initialize(Arg.Is<DataStorage>(ds => ds == this.dataStorage));
      ((IDataEngineCommand)commands.CopyItemPrototype).Received().Initialize(Arg.Is<DataStorage>(ds => ds == this.dataStorage));
      ((IDataEngineCommand)commands.CreateItemPrototype).Received().Initialize(Arg.Is<DataStorage>(ds => ds == this.dataStorage));
      ((IDataEngineCommand)commands.DeletePrototype).Received().Initialize(Arg.Is<DataStorage>(ds => ds == this.dataStorage));
      ((IDataEngineCommand)commands.GetBlobStreamPrototype).Received().Initialize(Arg.Is<DataStorage>(ds => ds == this.dataStorage));
      ((IDataEngineCommand)commands.GetChildrenPrototype).Received().Initialize(Arg.Is<DataStorage>(ds => ds == this.dataStorage));
      ((IDataEngineCommand)commands.GetItemPrototype).Received().Initialize(Arg.Is<DataStorage>(ds => ds == this.dataStorage));
      ((IDataEngineCommand)commands.GetParentPrototype).Received().Initialize(Arg.Is<DataStorage>(ds => ds == this.dataStorage));
      ((IDataEngineCommand)commands.GetRootItemPrototype).Received().Initialize(Arg.Is<DataStorage>(ds => ds == this.dataStorage));
      ((IDataEngineCommand)commands.GetVersionsPrototype).Received().Initialize(Arg.Is<DataStorage>(ds => ds == this.dataStorage));
      ((IDataEngineCommand)commands.HasChildrenPrototype).Received().Initialize(Arg.Is<DataStorage>(ds => ds == this.dataStorage));
      ((IDataEngineCommand)commands.MoveItemPrototype).Received().Initialize(Arg.Is<DataStorage>(ds => ds == this.dataStorage));
      ((IDataEngineCommand)commands.RemoveVersionPrototype).Received().Initialize(Arg.Is<DataStorage>(ds => ds == this.dataStorage));
      ((IDataEngineCommand)commands.ResolvePathPrototype).Received().Initialize(Arg.Is<DataStorage>(ds => ds == this.dataStorage));
      ((IDataEngineCommand)commands.SaveItemPrototype).Received().Initialize(Arg.Is<DataStorage>(ds => ds == this.dataStorage));
      ((IDataEngineCommand)commands.SetBlobStreamPrototype).Received().Initialize(Arg.Is<DataStorage>(ds => ds == this.dataStorage));
    }
    /// <summary>
    /// Initializes a new instance of the <see cref="Db"/> class with the specified database.
    /// </summary>
    /// <param name="databaseName">The database name.</param>
    public Db(string databaseName)
    {
      Assert.ArgumentNotNullOrEmpty(databaseName, "databaseName");

      this.database = Database.GetDatabase(databaseName);
      this.dataStorage = new DataStorage(this.database);
      this.dataStorageSwitcher = new DataStorageSwitcher(this.dataStorage);
      this.databaseSwitcher = new DatabaseSwitcher(this.database);
      this.databaseLanguages = new Stack<Switcher<DbLanguages>>();
      this.databaseLanguages.Push(
                  new Switcher<DbLanguages>(
                          new DbLanguages(Language.Parse("en"))));

      var args = new InitDbArgs(this.database, this.dataStorage);
      CorePipeline.Run("initFakeDb", args);
    }
    public override void Process(InitDbArgs args)
    {
      var commands = args.Database.Engines.DataEngine.Commands;
      var innerCommand = new DataEngineCommand(args.DataStorage);

      this.InitializeCommand(commands.AddFromTemplatePrototype, innerCommand);
      this.InitializeCommand(commands.AddVersionPrototype, innerCommand);
      this.InitializeCommand(commands.CreateItemPrototype, innerCommand);
      this.InitializeCommand(commands.DeletePrototype, innerCommand);
      this.InitializeCommand(commands.GetChildrenPrototype, innerCommand);
      this.InitializeCommand(commands.GetItemPrototype, innerCommand);
      this.InitializeCommand(commands.GetParentPrototype, innerCommand);
      this.InitializeCommand(commands.GetRootItemPrototype, innerCommand);
      this.InitializeCommand(commands.GetVersionsPrototype, innerCommand);
      this.InitializeCommand(commands.HasChildrenPrototype, innerCommand);
      this.InitializeCommand(commands.ResolvePathPrototype, innerCommand);
      this.InitializeCommand(commands.SaveItemPrototype, innerCommand);
    }
    public void ShouldNotSetDataStorageIfNoIRequireDataStorageProviderFound()
    {
      // arrange
      var database = Database.GetDatabase("master");
      var provider = Substitute.For<DataProvider>();
      typeof(Database).GetField("_dataProviders", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(database, new DataProviderCollection { provider });

      var dataStorage = Substitute.For<DataStorage>(database);

      var args = new InitDbArgs(database, dataStorage);
      var processor = new InitDataProviders();

      // act
      Action action = () => processor.Process(args);

      // assert
      action.ShouldNotThrow();
    }
    public void ShouldSetDataStorageForIRequireDataStorageProviders()
    {
      // arrange
      var database = Database.GetDatabase("master");
      var provider = Substitute.For<DataProvider, IRequireDataStorage>();
      typeof(Database).GetField("_dataProviders", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(database, new DataProviderCollection { provider });

      var dataStorage = Substitute.For<DataStorage>(database);

      var args = new InitDbArgs(database, dataStorage);
      var processor = new InitDataProviders();

      // act
      processor.Process(args);

      // assert
      ((IRequireDataStorage)provider).Received().SetDataStorage(dataStorage);
    }
        public override void Process(InitDbArgs args)
        {
            var commands    = args.Database.Engines.DataEngine.Commands;
            var dataStorage = args.DataStorage;

            this.InitializeCommand(commands.AddFromTemplatePrototype, dataStorage);
            this.InitializeCommand(commands.AddVersionPrototype, dataStorage);
            this.InitializeCommand(commands.BlobStreamExistsPrototype, dataStorage);
            this.InitializeCommand(commands.CopyItemPrototype, dataStorage);
            this.InitializeCommand(commands.CreateItemPrototype, dataStorage);
            this.InitializeCommand(commands.DeletePrototype, dataStorage);
            this.InitializeCommand(commands.GetBlobStreamPrototype, dataStorage);
            this.InitializeCommand(commands.GetChildrenPrototype, dataStorage);
            this.InitializeCommand(commands.GetItemPrototype, dataStorage);
            this.InitializeCommand(commands.GetParentPrototype, dataStorage);
            this.InitializeCommand(commands.GetRootItemPrototype, dataStorage);
            this.InitializeCommand(commands.GetVersionsPrototype, dataStorage);
            this.InitializeCommand(commands.HasChildrenPrototype, dataStorage);
            this.InitializeCommand(commands.MoveItemPrototype, dataStorage);
            this.InitializeCommand(commands.RemoveVersionPrototype, dataStorage);
            this.InitializeCommand(commands.ResolvePathPrototype, dataStorage);
            this.InitializeCommand(commands.SaveItemPrototype, dataStorage);
            this.InitializeCommand(commands.SetBlobStreamPrototype, dataStorage);
        }
 public override void Process(InitDbArgs args)
 {
   this.SetDataStorage(StandardValuesManager.Provider, args.DataStorage);
 }
Beispiel #13
0
 public override void Process(InitDbArgs args)
 {
     this.SetDataStorage(StandardValuesManager.Provider, args.DataStorage);
 }
Beispiel #14
0
 public abstract void Process(InitDbArgs args);
 public override void Process(InitDbArgs args)
 {
   this.SetDataStorage(AuthorizationManager.Provider, args.DataStorage);
 }
 public abstract void Process(InitDbArgs args);