コード例 #1
0
        public void ShouldRemoveVersionFromFakeDbFields()
        {
            // arrange
            var itemId = ID.NewID;
            var dbitem = new DbItem("item")
            {
                Fields = { new DbField("Title")
                           {
                               { "en", "Hello!" }
                           } }
            };

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

            var item = ItemHelper.CreateInstance(this.database, itemId);

            var command = new OpenRemoveVersionCommand();

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

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

            // assert
            result.Should().BeTrue();
            dbitem.Fields.Single().Values["en"].Values.Should().BeEmpty();
        }
コード例 #2
0
    public void ShouldCreateInstance()
    {
      // arrange
      var command = new OpenRemoveVersionCommand();
      command.Initialize(this.dataStorage);

      // act & assert
      command.CreateInstance().Should().BeOfType<RemoveVersionCommand>();
    }
コード例 #3
0
    public void ShouldNotRemoveVersionIfNoVersionFoundInSpecificLanguage()
    {
      // arrange
      var itemId = ID.NewID;
      var dbitem = new DbItem("item") { Fields = { new DbField("Title") } };
      this.dataStorage.GetFakeItem(itemId).Returns(dbitem);

      var item = ItemHelper.CreateInstance(this.database, itemId);

      var command = new OpenRemoveVersionCommand();
      command.Initialize(item);
      command.Initialize(this.dataStorage);

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

      // assert
      result.Should().BeFalse();
    }
コード例 #4
0
        public void ShouldCreateInstance()
        {
            // arrange
            var command = new OpenRemoveVersionCommand();

            command.Initialize(this.dataStorage);

            // act & assert
            command.CreateInstance().Should().BeOfType <RemoveVersionCommand>();
        }
コード例 #5
0
    public void ShouldRemoveVersionFromFakeDbFields()
    {
      // arrange
      var itemId = ID.NewID;
      var dbitem = new DbItem("item") { Fields = { new DbField("Title") { { "en", "Hello!" } } } };
      this.dataStorage.GetFakeItem(itemId).Returns(dbitem);

      var item = ItemHelper.CreateInstance(this.database, itemId);

      var command = new OpenRemoveVersionCommand();
      command.Initialize(item);
      command.Initialize(this.dataStorage);

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

      // assert
      result.Should().BeTrue();
      dbitem.Fields.Single().Values["en"].Values.Should().BeEmpty();
    }
コード例 #6
0
    public void ShouldDecreaseFakeItemVersionCount()
    {
      // arrange
      var itemId = ID.NewID;
      var dbitem = new DbItem("item");
      dbitem.VersionsCount.Add("en", 2);

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

      var item = ItemHelper.CreateInstance(this.database, itemId);

      var command = new OpenRemoveVersionCommand();
      command.Initialize(item);
      command.Initialize(this.dataStorage);

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

      // assert
      result.Should().BeTrue();
      dbitem.VersionsCount["en"].Should().Be(1);
    }
コード例 #7
0
        public void ShouldDecreaseFakeItemVersionCount()
        {
            // arrange
            var itemId = ID.NewID;
            var dbitem = new DbItem("item");

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

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

            var item = ItemHelper.CreateInstance(this.database, itemId);

            var command = new OpenRemoveVersionCommand();

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

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

            // assert
            result.Should().BeTrue();
            dbitem.VersionsCount["en"].Should().Be(1);
        }
コード例 #8
0
        public void ShouldNotRemoveVersionIfNoVersionFoundInSpecificLanguage()
        {
            // arrange
            var itemId = ID.NewID;
            var dbitem = new DbItem("item")
            {
                Fields = { new DbField("Title") }
            };

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

            var item = ItemHelper.CreateInstance(this.database, itemId);

            var command = new OpenRemoveVersionCommand();

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

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

            // assert
            result.Should().BeFalse();
        }