public override void Process(InitDbArgs args)
 {
   foreach (var provider in args.Database.GetDataProviders())
   {
     this.SetDataStorage(provider, args.DataStorage);
   }
 }
Exemple #2
0
 public override void Process(InitDbArgs args)
 {
     foreach (var provider in args.Database.GetDataProviders())
     {
         this.SetDataStorage(provider, args.DataStorage);
     }
 }
Exemple #3
0
        public Db(string databaseName)
        {
            Assert.ArgumentNotNullOrEmpty(databaseName, "databaseName");

            this.database    = Database.GetDatabase(databaseName);
            this.dataStorage = new DataStorage(this.database);

            this.databaseSwitcher = new DatabaseSwitcher(this.database);

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

            CorePipeline.Run("initFakeDb", args);
        }
Exemple #4
0
        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)
 {
   Globals.Load();
 }
Exemple #8
0
 public override void Process(InitDbArgs args)
 {
     Globals.Load();
 }