Ejemplo n.º 1
0
        public void ProcessThrowsIfArgsIsNull()
        {
            var    sut    = new CopyParentId();
            Action action = () => sut.Process(null);

            action.ShouldThrow <ArgumentNullException>().WithMessage("*args");
        }
Ejemplo n.º 2
0
        public void ProcessThrowsIfSyncItemIsNull()
        {
            var sut         = new CopyParentId();
            var dsitem      = Substitute.For <IDsDbItem>();
            var dataStorage = Substitute.For <DataStorage>(Database.GetDatabase("master"));
            var args        = new DsItemLoadingArgs(dsitem, dataStorage);

            Action action = () => sut.Process(args);

            action.ShouldThrow <ArgumentNullException>().WithMessage("*SyncItem");
        }
        public void ProcessThrowsIfSyncItemParentIdIsNotIdentifier()
        {
            var sut    = new CopyParentId();
            var dsitem = Substitute.For <IDsDbItem>();

            dsitem.SyncItem.Returns(new SyncItem {
                ParentID = "not an id"
            });
            var dataStorage = Substitute.For <DataStorage>(Database.GetDatabase("master"));
            var args        = new DsItemLoadingArgs(dsitem, dataStorage);

            Action action = () => sut.Process(args);

            action.ShouldThrow <ArgumentException>().WithMessage("Unable to copy ParentId. Valid identifier expected.*");
        }
        public void ProcessIgnoresParentIdIfNoParentItemFound()
        {
            var sut      = new CopyParentId();
            var dsitem   = Substitute.For <IDsDbItem, DbItem>("item");
            var parentId = ID.NewID;

            dsitem.SyncItem.Returns(new SyncItem {
                ParentID = parentId.ToString()
            });
            var dataStorage = Substitute.For <DataStorage>(Database.GetDatabase("master"));
            var args        = new DsItemLoadingArgs(dsitem, dataStorage);

            sut.Process(args);

            ((DbItem)dsitem).ParentID.Should().BeNull();
        }
Ejemplo n.º 5
0
        public void ProcessSetsParentId()
        {
            var sut      = new CopyParentId();
            var dsitem   = Substitute.For <IDsDbItem, DbItem>("item");
            var parentId = ID.NewID;

#pragma warning disable 618
            dsitem.SyncItem.Returns(new SyncItem {
                ParentID = parentId.ToString()
            });
#pragma warning restore 618
            var dataStorage = Substitute.For <DataStorage>(Database.GetDatabase("master"));
            dataStorage.GetFakeItem(parentId).Returns(new DbItem("Parent"));
            var args = new DsItemLoadingArgs(dsitem, dataStorage);

            sut.Process(args);

            ((DbItem)dsitem).ParentID.Should().Be(parentId);
        }