Ejemplo n.º 1
0
        public void T104_RandomUpdateItem()
        {
            PropertyScrambler <InventoryFolderBase> folderScrambler =
                new PropertyScrambler <InventoryFolderBase>()
                .DontScramble(x => x.Owner)
                .DontScramble(x => x.ParentID)
                .DontScramble(x => x.ID);
            UUID owner             = UUID.Random();
            UUID folder            = UUID.Random();
            UUID rootId            = UUID.Random();
            UUID rootAsset         = UUID.Random();
            InventoryFolderBase f1 = NewFolder(folder, zero, owner, name1);

            folderScrambler.Scramble(f1);

            db.addInventoryFolder(f1);
            InventoryFolderBase f1a = db.getUserRootFolder(owner);

            Assert.That(f1a, Constraints.PropertyCompareConstraint(f1));

            folderScrambler.Scramble(f1a);

            db.updateInventoryFolder(f1a);

            InventoryFolderBase f1b = db.getUserRootFolder(owner);

            Assert.That(f1b, Constraints.PropertyCompareConstraint(f1a));

            //Now we have a valid folder to insert into, we can insert the item.
            PropertyScrambler <InventoryItemBase> inventoryScrambler =
                new PropertyScrambler <InventoryItemBase>()
                .DontScramble(x => x.ID)
                .DontScramble(x => x.AssetID)
                .DontScramble(x => x.Owner)
                .DontScramble(x => x.Folder);
            InventoryItemBase root = NewItem(rootId, folder, owner, iname1, rootAsset);

            inventoryScrambler.Scramble(root);
            db.addInventoryItem(root);

            InventoryItemBase expected = db.getInventoryItem(rootId);

            Assert.That(expected, Constraints.PropertyCompareConstraint(root)
                        .IgnoreProperty(x => x.InvType)
                        .IgnoreProperty(x => x.CreatorIdAsUuid)
                        .IgnoreProperty(x => x.Description)
                        .IgnoreProperty(x => x.CreatorId));

            inventoryScrambler.Scramble(expected);
            db.updateInventoryItem(expected);

            InventoryItemBase actual = db.getInventoryItem(rootId);

            Assert.That(actual, Constraints.PropertyCompareConstraint(expected)
                        .IgnoreProperty(x => x.InvType)
                        .IgnoreProperty(x => x.CreatorIdAsUuid)
                        .IgnoreProperty(x => x.Description)
                        .IgnoreProperty(x => x.CreatorId));
        }