Example #1
0
        public void MoveItemThrowsIfItemDefinitionNotFound(
            [Greedy] FakeDataProvider sut,
            ItemDefinition itemDefinition,
            ItemDefinition destination)
        {
            Action action = () => sut.MoveItem(itemDefinition, destination, null);

            action.ShouldThrow <InvalidOperationException>()
            .WithMessage("Unable to move item. The item '{0}' is not found.".FormatWith(itemDefinition.ID));
        }
Example #2
0
        public void MoveItemThrowsIfDestinationNotFound(
            [Greedy] FakeDataProvider sut,
            ItemDefinition itemDefinition,
            ItemDefinition destination,
            DbItem item)
        {
            sut.DataStorage.GetFakeItem(itemDefinition.ID).Returns(item);
            Action action = () => sut.MoveItem(itemDefinition, destination, null);

            action.ShouldThrow <InvalidOperationException>()
            .WithMessage("Unable to move item. The destination item '{0}' is not found.".FormatWith(destination.ID));
        }
Example #3
0
        public void MoveItemToNewDestinationReturnsTrue(
            [Greedy] FakeDataProvider sut,
            ItemDefinition itemDefinition,
            ItemDefinition destination,
            DbItem item,
            DbItem newDestination)
        {
            sut.DataStorage.GetFakeItem(itemDefinition.ID).Returns(item);
            sut.DataStorage.GetFakeItem(destination.ID).Returns(newDestination);

            sut.MoveItem(itemDefinition, destination, null).Should().BeTrue();

            newDestination.Children.Single().Should().BeSameAs(item);
            item.ParentID.Should().Be(newDestination.ID);
        }
Example #4
0
        public void MoveItemRemovesFromOldParentChildrenIfExists(
            [Greedy] FakeDataProvider sut,
            ItemDefinition itemDefinition,
            ItemDefinition destination,
            DbItem item,
            DbItem newDestination,
            DbItem oldParent)
        {
            oldParent.Children.Add(item);
            sut.DataStorage.GetFakeItem(itemDefinition.ID).Returns(item);
            sut.DataStorage.GetFakeItem(destination.ID).Returns(newDestination);
            sut.DataStorage.GetFakeItem(item.ParentID).Returns(oldParent);

            sut.MoveItem(itemDefinition, destination, null);

            oldParent.Children.Should().BeEmpty();
        }
Example #5
0
        public void MoveItemThrowsIfDestinationIsNull(FakeDataProvider sut, ItemDefinition itemDefinition)
        {
            Action action = () => sut.MoveItem(itemDefinition, null, null);

            action.ShouldThrow <ArgumentNullException>().WithMessage("*destination");
        }