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); m_db.StoreAsset(a2); m_db.StoreAsset(a3); AssetBase a1a = m_db.GetAsset(uuid1); Assert.That(a1a, Constraints.PropertyCompareConstraint(a1)); AssetBase a2a = m_db.GetAsset(uuid2); Assert.That(a2a, Constraints.PropertyCompareConstraint(a2)); AssetBase a3a = m_db.GetAsset(uuid3); Assert.That(a3a, Constraints.PropertyCompareConstraint(a3)); }
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)); }
public void TestColors() { Color actual = Color.Red; Color expected = Color.FromArgb(actual.A, actual.R, actual.G, actual.B); var constraint = Constraints.PropertyCompareConstraint(expected); Assert.That(constraint.Matches(actual), Is.True); }
public void UUIDShouldNotMatch() { UUID uuid1 = UUID.Random(); UUID uuid2 = UUID.Random(); var constraint = Constraints.PropertyCompareConstraint(uuid1); Assert.That(constraint.Matches(uuid2), Is.False); }
public void UUIDShouldMatch() { UUID uuid1 = UUID.Random(); UUID uuid2 = UUID.Parse(uuid1.ToString()); var constraint = Constraints.PropertyCompareConstraint(uuid1); Assert.That(constraint.Matches(uuid2), Is.True); }
public void AssetShouldNotMatch2() { UUID uuid1 = UUID.Random(); AssetBase actual = new AssetBase(uuid1, "asset one", (sbyte)AssetType.Texture, UUID.Zero.ToString()); AssetBase expected = new AssetBase(uuid1, "asset two", (sbyte)AssetType.Texture, UUID.Zero.ToString()); var constraint = Constraints.PropertyCompareConstraint(expected); Assert.That(constraint.Matches(actual), Is.False); }
public void ErrorsOutOnRecursive() { Recursive parent = new Recursive(); Recursive child = new Recursive(); parent.Other = child; child.Other = parent; var constraint = Constraints.PropertyCompareConstraint(child); Assert.That(constraint.Matches(child), Is.False); }
public void IntShouldIgnore() { HasInt actual = new HasInt { TheValue = 5 }; HasInt expected = new HasInt { TheValue = 4 }; var constraint = Constraints.PropertyCompareConstraint(expected).IgnoreProperty(x => x.TheValue); Assert.That(constraint.Matches(actual), Is.True); }
public void IntShouldNotMatch() { HasInt actual = new HasInt { TheValue = 5 }; HasInt expected = new HasInt { TheValue = 4 }; var constraint = Constraints.PropertyCompareConstraint(expected); Assert.That(constraint.Matches(actual), Is.False); }
public void ShouldFailToCompareListsThatAreDifferentLengths() { List <int> expected = new List <int> { 1, 2, 3 }; List <int> actual = new List <int> { 1, 2 }; var constraint = Constraints.PropertyCompareConstraint(expected); Assert.That(constraint.Matches(actual), Is.False); }
public void ShouldCompareLists() { List <int> expected = new List <int> { 1, 2, 3 }; List <int> actual = new List <int> { 1, 2, 3 }; var constraint = Constraints.PropertyCompareConstraint(expected); Assert.That(constraint.Matches(actual), Is.True); }
public void T012_EstateSettingsRandomStorage() { // 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)); }
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)); } }