public void ShouldGetItemVersionsCount()
        {
            // arrange
            var itemId        = ID.NewID;
            var versionedItem = new DbItem("item");

            versionedItem.VersionsCount.Add("en", 2);

            this.dataStorage.GetFakeItem(itemId).Returns(versionedItem);

            var item     = ItemHelper.CreateInstance(this.database, itemId);
            var language = Language.Parse("en");

            var command = new OpenGetVersionsCommand();

            command.Initialize(item, language);
            command.Initialize(this.dataStorage);

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

            // assert
            versionCollection.Count.Should().Be(2);
            versionCollection.Should().BeEquivalentTo(new[] { new Version(1), new Version(2) });
        }
    public void ShouldCreateInstance()
    {
      // arrange
      var command = new OpenGetVersionsCommand();
      command.Initialize(this.dataStorage);

      // act & assert
      command.CreateInstance().Should().BeOfType<GetVersionsCommand>();
    }
    public void ShouldGetVersionCollectionWinthSingleVersion()
    {
      // arrange
      var itemId = ID.NewID;
      this.dataStorage.GetFakeItem(itemId).Returns(new DbItem("item"));

      var item = ItemHelper.CreateInstance(itemId, this.database);
      var language = Language.Parse("en");

      var command = new OpenGetVersionsCommand();
      command.Initialize(item, language);
      command.Initialize(this.innerCommand);

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

      // assert
      versionCollection.Should().ContainSingle(v => v.Number == 1);
    }
        public void ShouldCreateInstance()
        {
            // arrange
            var command = new OpenGetVersionsCommand();

            command.Initialize(this.dataStorage);

            // act & assert
            command.CreateInstance().Should().BeOfType <GetVersionsCommand>();
        }
    public void ShouldGetEmptyVersionCollection()
    {
      // arrange
      var itemId = ID.NewID;
      this.dataStorage.GetFakeItem(itemId).Returns(new DbItem("item"));

      var item = ItemHelper.CreateInstance(this.database, itemId);
      var language = Language.Parse("en");

      var command = new OpenGetVersionsCommand();
      command.Initialize(item, language);
      command.Initialize(this.dataStorage);

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

      // assert
      versionCollection.Should().BeEmpty();
    }
    public void ShouldGetItemVersionsForLanguage()
    {
      // arrange
      var itemId = ID.NewID;
      var versionedItem = new DbItem("item") { Fields = { new DbField("Title") { { "en", 1, "value1" }, { "en", 2, "value2" } } } };
      this.dataStorage.GetFakeItem(itemId).Returns(versionedItem);

      var item = ItemHelper.CreateInstance(itemId, this.database);
      var language = Language.Parse("en");

      var command = new OpenGetVersionsCommand();
      command.Initialize(item, language);
      command.Initialize(this.innerCommand);

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

      // assert
      versionCollection.Count.Should().Be(2);
      versionCollection.Should().BeEquivalentTo(new[] { new Version(1), new Version(2) });
    }
    public void ShouldCreateInstance()
    {
      // arrange
      var createdCommand = Substitute.For<GetVersionsCommand>();
      this.innerCommand.CreateInstance<Sitecore.Data.Engines.DataCommands.GetVersionsCommand, GetVersionsCommand>().Returns(createdCommand);

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

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

            this.dataStorage.GetFakeItem(itemId).Returns(new DbItem("item"));

            var item     = ItemHelper.CreateInstance(this.database, itemId);
            var language = Language.Parse("en");

            var command = new OpenGetVersionsCommand();

            command.Initialize(item, language);
            command.Initialize(this.dataStorage);

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

            // assert
            versionCollection.Should().BeEmpty();
        }