コード例 #1
0
    public void ShouldReturnNullIfNoParentFound(GetParentCommand sut, Item item)
    {
      // arrange
      sut.Initialize(item);

      // act
      var result = ReflectionUtil.CallMethod(sut, "DoExecute");

      // assert
      result.Should().BeNull();
      sut.DataStorage.DidNotReceiveWithAnyArgs().GetSitecoreItem(null, null);
    }
コード例 #2
0
    public void ShouldReturnRootItem(GetParentCommand sut, Item parentItem, Item childItem)
    {
      // arrange
      sut.DataStorage.GetFakeItem(childItem.ID).Returns(new DbItem("child", childItem.ID) { ParentID = parentItem.ID });
      sut.DataStorage.GetSitecoreItem(parentItem.ID, parentItem.Language).Returns(parentItem);

      sut.Initialize(childItem);

      // act
      var result = ReflectionUtil.CallMethod(sut, "DoExecute");

      // assert
      result.Should().Be(parentItem);
    }
コード例 #3
0
    public void ShouldNotTryToLocateParentForSitecoreRoot(GetParentCommand sut, DbItem dbitem)
    {
      // arrange
      var rootId = ItemIDs.RootID;
      var item = ItemHelper.CreateInstance(rootId);

      sut.DataStorage.GetFakeItem(rootId).Returns(dbitem);
      sut.Initialize(item);

      // act
      var result = ReflectionUtil.CallMethod(sut, "DoExecute");

      // assert
      result.Should().BeNull();
      sut.DataStorage.DidNotReceiveWithAnyArgs().GetSitecoreItem(null, null);
    }