public void T012_EstateSettingsRandomStorage()
        {
            TestHelpers.InMethod();

            // Letting estate store generate rows to database for us
            EstateSettings originalSettings = db.LoadEstateSettings(REGION_ID, true);

            new PropertyScrambler <EstateSettings>()
            .DontScramble(x => x.EstateID)
            .Scramble(originalSettings);

            // Saving settings.
            db.StoreEstateSettings(originalSettings);

            // Loading settings to another instance variable.
            EstateSettings loadedSettings = db.LoadEstateSettings(REGION_ID, true);

            // Checking that loaded values are correct.
            Assert.That(loadedSettings, Constraints.PropertyCompareConstraint(originalSettings));
        }
Ejemplo n.º 2
0
        public void T020_CheckForWeirdCreatorID()
        {
            TestHelpers.InMethod();

            // It is expected that eventually the CreatorID might be an arbitrary string (an URI)
            // rather than a valid UUID (?).  This test is to make sure that the database layer does not
            // attempt to convert CreatorID to GUID, but just passes it both ways as a string.
            AssetBase a1 = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture, critter1);
            AssetBase a2 = new AssetBase(uuid2, "asset two", (sbyte)AssetType.Texture, "This is not a GUID!");
            AssetBase a3 = new AssetBase(uuid3, "asset three", (sbyte)AssetType.Texture, "");

            a1.Data = data1;
            a2.Data = data1;
            a3.Data = data1;

            m_db.StoreAsset(a1);
            a1.UploadAttempts = 0;
            m_db.StoreAsset(a2);
            a2.UploadAttempts = 0;
            m_db.StoreAsset(a3);
            a3.UploadAttempts = 0;

            AssetBase a1a = m_db.GetAsset(uuid1);

            a1a.UploadAttempts = 0;
            Assert.That(a1a, Constraints.PropertyCompareConstraint(a1));

            AssetBase a2a = m_db.GetAsset(uuid2);

            a2a.UploadAttempts = 0;
            Assert.That(a2a, Constraints.PropertyCompareConstraint(a2));

            AssetBase a3a = m_db.GetAsset(uuid3);

            a3a.UploadAttempts = 0;
            Assert.That(a3a, Constraints.PropertyCompareConstraint(a3));
        }
Ejemplo n.º 3
0
        public void T010_StoreReadVerifyAssets()
        {
            TestHelpers.InMethod();

            AssetBase a1 = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture, critter1.ToString());
            AssetBase a2 = new AssetBase(uuid2, "asset two", (sbyte)AssetType.Texture, critter2.ToString());
            AssetBase a3 = new AssetBase(uuid3, "asset three", (sbyte)AssetType.Texture, critter3.ToString());

            a1.Data = data1;
            a2.Data = data1;
            a3.Data = data1;

            scrambler.Scramble(a1);
            scrambler.Scramble(a2);
            scrambler.Scramble(a3);

            m_db.StoreAsset(a1);
            m_db.StoreAsset(a2);
            m_db.StoreAsset(a3);
            a1.UploadAttempts = 0;
            a2.UploadAttempts = 0;
            a3.UploadAttempts = 0;

            AssetBase a1a = m_db.GetAsset(uuid1);

            a1a.UploadAttempts = 0;
            Assert.That(a1a, Constraints.PropertyCompareConstraint(a1));

            AssetBase a2a = m_db.GetAsset(uuid2);

            a2a.UploadAttempts = 0;
            Assert.That(a2a, Constraints.PropertyCompareConstraint(a2));

            AssetBase a3a = m_db.GetAsset(uuid3);

            a3a.UploadAttempts = 0;
            Assert.That(a3a, Constraints.PropertyCompareConstraint(a3));

            scrambler.Scramble(a1a);
            scrambler.Scramble(a2a);
            scrambler.Scramble(a3a);

            m_db.StoreAsset(a1a);
            m_db.StoreAsset(a2a);
            m_db.StoreAsset(a3a);
            a1a.UploadAttempts = 0;
            a2a.UploadAttempts = 0;
            a3a.UploadAttempts = 0;

            AssetBase a1b = m_db.GetAsset(uuid1);

            a1b.UploadAttempts = 0;
            Assert.That(a1b, Constraints.PropertyCompareConstraint(a1a));

            AssetBase a2b = m_db.GetAsset(uuid2);

            a2b.UploadAttempts = 0;
            Assert.That(a2b, Constraints.PropertyCompareConstraint(a2a));

            AssetBase a3b = m_db.GetAsset(uuid3);

            a3b.UploadAttempts = 0;
            Assert.That(a3b, Constraints.PropertyCompareConstraint(a3a));

            bool[] exist = m_db.AssetsExist(new[] { uuid1, uuid2, uuid3 });
            Assert.IsTrue(exist[0]);
            Assert.IsTrue(exist[1]);
            Assert.IsTrue(exist[2]);

            List <AssetMetadata> metadatas = m_db.FetchAssetMetadataSet(0, 1000);

            Assert.That(metadatas.Count >= 3, "FetchAssetMetadataSet() should have returned at least 3 assets!");

            // It is possible that the Asset table is filled with data, in which case we don't try to find "our"
            // assets there:
            if (metadatas.Count < 1000)
            {
                AssetMetadata metadata = metadatas.Find(x => x.FullID == uuid1);
                Assert.That(metadata.Name, Is.EqualTo(a1b.Name));
                Assert.That(metadata.Description, Is.EqualTo(a1b.Description));
                Assert.That(metadata.Type, Is.EqualTo(a1b.Type));
                Assert.That(metadata.Temporary, Is.EqualTo(a1b.Temporary));
                Assert.That(metadata.FullID, Is.EqualTo(a1b.FullID));
            }
        }
        public void T104_RandomUpdateItem()
        {
            TestHelpers.InMethod();

            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.CreatorIdentification)
                        .IgnoreProperty(x => x.CreatorData));

            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.CreatorIdentification)
                        .IgnoreProperty(x => x.CreatorData));
        }