public void ShouldCreateItem()
        {
            // arrange
            var itemId     = ID.NewID;
            var templateId = ID.NewID;

            var item        = ItemHelper.CreateInstance(this.database);
            var destination = ItemHelper.CreateInstance(this.database);

            this.dataStorage.GetSitecoreItem(itemId).Returns(item);

            var command = new OpenAddFromTemplateCommand {
                Engine = new DataEngine(database)
            };

            command.Initialize("home", templateId, destination, itemId);
            command.Initialize(this.dataStorage);

            // act
            var result = command.DoExecute();

            // assert
            result.Should().Be(item);
            this.dataStorage.Received().Create("home", itemId, templateId, destination, true);
        }
        public void ShouldCreateItem()
        {
            // arrange
            var itemId     = ID.NewID;
            var templateId = ID.NewID;

            var item        = ItemHelper.CreateInstance(this.database);
            var destination = ItemHelper.CreateInstance(this.database);

            this.dataStorage.GetSitecoreItem(itemId).Returns(item);

            var command = new OpenAddFromTemplateCommand {
                Engine = new DataEngine(database)
            };

            command.Initialize("home", templateId, destination, itemId);
            command.Initialize(this.dataStorage);

            // act
            var result = command.DoExecute();

            // assert
            result.Should().Be(item);
            this.dataStorage.Received().AddFakeItem(Arg.Is <DbItem>(i => i.Name == "home" &&
                                                                    i.ID == itemId &&
                                                                    i.TemplateID == templateId &&
                                                                    i.ParentID == destination.ID));
        }
        public void ShouldCreateInstance()
        {
            // arrange
            var command = new OpenAddFromTemplateCommand();

            command.Initialize(this.dataStorage);

            // act & assert
            command.CreateInstance().Should().BeOfType <AddFromTemplateCommand>();
        }
    public void ShouldCreateInstance()
    {
      // arrange
      var createdCommand = Substitute.For<AddFromTemplateCommand>();
      this.innerCommand.CreateInstance<Sitecore.Data.Engines.DataCommands.AddFromTemplateCommand, AddFromTemplateCommand>().Returns(createdCommand);

      var command = new OpenAddFromTemplateCommand();
      command.Initialize(this.innerCommand);

      // act & assert
      command.CreateInstance().Should().Be(createdCommand);
    }
    public void ShouldCreateItem()
    {
      // arrange
      var itemId = ID.NewID;
      var templateId = ID.NewID;

      var item = ItemHelper.CreateInstance(this.database);
      var destination = ItemHelper.CreateInstance(this.database);

      var itemCreator = Substitute.For<ItemCreator>(this.dataStorage);
      itemCreator.Create("home", itemId, templateId, database, destination).Returns(item);

      var command = new OpenAddFromTemplateCommand { Engine = new DataEngine(database), ItemCreator = itemCreator };
      command.Initialize("home", templateId, destination, itemId);
      command.Initialize(this.innerCommand);

      // act
      var result = command.DoExecute();

      // assert
      result.Should().Be(item);
    }