aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/Tests/BasicAssetTest.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/Tests/BasicAssetTest.cs78
1 files changed, 44 insertions, 34 deletions
diff --git a/OpenSim/Data/Tests/BasicAssetTest.cs b/OpenSim/Data/Tests/BasicAssetTest.cs
index e85a6a7..09131c1 100644
--- a/OpenSim/Data/Tests/BasicAssetTest.cs
+++ b/OpenSim/Data/Tests/BasicAssetTest.cs
@@ -26,20 +26,19 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic;
29using log4net.Config; 30using log4net.Config;
30using NUnit.Framework; 31using NUnit.Framework;
31using NUnit.Framework.SyntaxHelpers; 32using NUnit.Framework.SyntaxHelpers;
32using OpenMetaverse; 33using OpenMetaverse;
33using OpenSim.Framework; 34using OpenSim.Framework;
34using log4net; 35using log4net;
35using System.Reflection;
36 36
37namespace OpenSim.Data.Tests 37namespace OpenSim.Data.Tests
38{ 38{
39 public class BasicAssetTest 39 public class BasicAssetTest
40 { 40 {
41 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 41 public IAssetDataPlugin db;
42 public AssetDataBase db;
43 public UUID uuid1; 42 public UUID uuid1;
44 public UUID uuid2; 43 public UUID uuid2;
45 public UUID uuid3; 44 public UUID uuid3;
@@ -47,14 +46,7 @@ namespace OpenSim.Data.Tests
47 46
48 public void SuperInit() 47 public void SuperInit()
49 { 48 {
50 try 49 OpenSim.Tests.Common.TestLogging.LogToConsole();
51 {
52 XmlConfigurator.Configure();
53 }
54 catch (Exception)
55 {
56 // I don't care, just leave log4net off
57 }
58 50
59 uuid1 = UUID.Random(); 51 uuid1 = UUID.Random();
60 uuid2 = UUID.Random(); 52 uuid2 = UUID.Random();
@@ -81,41 +73,59 @@ namespace OpenSim.Data.Tests
81 a2.Data = asset1; 73 a2.Data = asset1;
82 a3.Data = asset1; 74 a3.Data = asset1;
83 75
76 PropertyScrambler<AssetBase> scrambler = new PropertyScrambler<AssetBase>()
77 .DontScramble(x => x.Data)
78 .DontScramble(x => x.ID)
79 .DontScramble(x => x.FullID)
80 .DontScramble(x => x.Metadata.ID)
81 .DontScramble(x => x.Metadata.FullID);
82
83 scrambler.Scramble(a1);
84 scrambler.Scramble(a2);
85 scrambler.Scramble(a3);
86
84 db.CreateAsset(a1); 87 db.CreateAsset(a1);
85 db.CreateAsset(a2); 88 db.CreateAsset(a2);
86 db.CreateAsset(a3); 89 db.CreateAsset(a3);
87 90
88 AssetBase a1a = db.FetchAsset(uuid1); 91 AssetBase a1a = db.FetchAsset(uuid1);
89 Assert.That(a1.ID, Is.EqualTo(a1a.ID), "Assert.That(a1.ID, Is.EqualTo(a1a.ID))"); 92 Assert.That(a1a, Constraints.PropertyCompareConstraint(a1));
90 Assert.That(a1.Name, Is.EqualTo(a1a.Name), "Assert.That(a1.Name, Is.EqualTo(a1a.Name))");
91 93
92 AssetBase a2a = db.FetchAsset(uuid2); 94 AssetBase a2a = db.FetchAsset(uuid2);
93 Assert.That(a2.ID, Is.EqualTo(a2a.ID), "Assert.That(a2.ID, Is.EqualTo(a2a.ID))"); 95 Assert.That(a2a, Constraints.PropertyCompareConstraint(a2));
94 Assert.That(a2.Name, Is.EqualTo(a2a.Name), "Assert.That(a2.Name, Is.EqualTo(a2a.Name))");
95 96
96 AssetBase a3a = db.FetchAsset(uuid3); 97 AssetBase a3a = db.FetchAsset(uuid3);
97 Assert.That(a3.ID, Is.EqualTo(a3a.ID), "Assert.That(a3.ID, Is.EqualTo(a3a.ID))"); 98 Assert.That(a3a, Constraints.PropertyCompareConstraint(a3));
98 Assert.That(a3.Name, Is.EqualTo(a3a.Name), "Assert.That(a3.Name, Is.EqualTo(a3a.Name))"); 99
99 } 100 scrambler.Scramble(a1a);
101 scrambler.Scramble(a2a);
102 scrambler.Scramble(a3a);
103
104 db.UpdateAsset(a1a);
105 db.UpdateAsset(a2a);
106 db.UpdateAsset(a3a);
107
108 AssetBase a1b = db.FetchAsset(uuid1);
109 Assert.That(a1b, Constraints.PropertyCompareConstraint(a1a));
110
111 AssetBase a2b = db.FetchAsset(uuid2);
112 Assert.That(a2b, Constraints.PropertyCompareConstraint(a2a));
113
114 AssetBase a3b = db.FetchAsset(uuid3);
115 Assert.That(a3b, Constraints.PropertyCompareConstraint(a3a));
100 116
101 [Test]
102 public void T011_ExistsSimpleAsset()
103 {
104 Assert.That(db.ExistsAsset(uuid1), Is.True); 117 Assert.That(db.ExistsAsset(uuid1), Is.True);
105 Assert.That(db.ExistsAsset(uuid2), Is.True); 118 Assert.That(db.ExistsAsset(uuid2), Is.True);
106 Assert.That(db.ExistsAsset(uuid3), Is.True); 119 Assert.That(db.ExistsAsset(uuid3), Is.True);
107 }
108 120
109 // this has questionable use, but it is in the interface at the moment. 121 List<AssetMetadata> metadatas = db.FetchAssetMetadataSet(0, 1000);
110 // [Test] 122
111 // public void T012_DeleteAsset() 123 AssetMetadata metadata = metadatas.Find(x => x.FullID == uuid1);
112 // { 124 Assert.That(metadata.Name, Is.EqualTo(a1b.Name));
113 // db.DeleteAsset(uuid1); 125 Assert.That(metadata.Description, Is.EqualTo(a1b.Description));
114 // db.DeleteAsset(uuid2); 126 Assert.That(metadata.Type, Is.EqualTo(a1b.Type));
115 // db.DeleteAsset(uuid3); 127 Assert.That(metadata.Temporary, Is.EqualTo(a1b.Temporary));
116 // Assert.That(db.ExistsAsset(uuid1), Is.False); 128 Assert.That(metadata.FullID, Is.EqualTo(a1b.FullID));
117 // Assert.That(db.ExistsAsset(uuid2), Is.False); 129 }
118 // Assert.That(db.ExistsAsset(uuid3), Is.False);
119 // }
120 } 130 }
121} 131}