- Timestamp:
- 09/14/11 13:59:25 (13 years ago)
- Location:
- branches/PersistenceSpeedUp
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PersistenceSpeedUp
- Property svn:ignore
-
old new 12 12 *.psess 13 13 *.vsp 14 *.docstates
-
- Property svn:mergeinfo changed
- Property svn:ignore
-
branches/PersistenceSpeedUp/HeuristicLab.Persistence
- Property svn:mergeinfo changed
-
branches/PersistenceSpeedUp/HeuristicLab.Persistence/3.3/Tests/UseCases.cs
r6737 r6760 39 39 using HeuristicLab.Persistence.Interfaces; 40 40 using Microsoft.VisualStudio.TestTools.UnitTesting; 41 using System.Threading.Tasks; 42 using HeuristicLab.Algorithms.GeneticAlgorithm; 41 43 42 44 namespace HeuristicLab.Persistence_33.Tests { … … 1111 1113 public OneWayTest() { this.value = "default"; } 1112 1114 public string value; 1113 [Storable(AllowOneWay =true)]1115 [Storable(AllowOneWay = true)] 1114 1116 public string ReadOnly { 1115 1117 get { return "ReadOnly"; } 1116 1118 } 1117 [Storable(AllowOneWay =true)]1119 [Storable(AllowOneWay = true)] 1118 1120 public string WriteOnly { 1119 1121 set { this.value = value; } … … 1183 1185 } 1184 1186 1185 1187 [TestMethod] 1188 public void FontTest() { 1189 List<Font> fonts = new List<Font>() { 1190 new Font(FontFamily.GenericSansSerif, 12), 1191 new Font("Times New Roman", 21, FontStyle.Bold, GraphicsUnit.Pixel), 1192 new Font("Courier New", 10, FontStyle.Underline, GraphicsUnit.Document), 1193 new Font("Helvetica", 21, FontStyle.Strikeout, GraphicsUnit.Inch, 0, true), 1194 }; 1195 XmlGenerator.Serialize(fonts, tempFile); 1196 var newFonts = XmlParser.Deserialize<List<Font>>(tempFile); 1197 Assert.AreEqual(fonts[0], newFonts[0]); 1198 Assert.AreEqual(fonts[1], newFonts[1]); 1199 Assert.AreEqual(fonts[2], newFonts[2]); 1200 Assert.AreEqual(fonts[3], newFonts[3]); 1201 } 1202 1203 [TestMethod] 1204 public void ConcurrencyTest() { 1205 int n = 20; 1206 Task[] tasks = new Task[n]; 1207 for (int i = 0; i < n; i++) { 1208 tasks[i] = Task.Factory.StartNew((idx) => { 1209 byte[] data; 1210 using(var stream = new MemoryStream()) { 1211 XmlGenerator.Serialize(new GeneticAlgorithm(), stream); 1212 data = stream.ToArray(); 1213 } 1214 }, i); 1215 } 1216 Task.WaitAll(tasks); 1217 } 1218 1219 [TestMethod] 1220 public void ConcurrentBitmapTest() { 1221 Bitmap b = new Bitmap(300, 300); 1222 Random r = new Random(); 1223 for (int x = 0; x<b.Height; x++) { 1224 for (int y = 0; y<b.Width; y++) { 1225 b.SetPixel(x, y, Color.FromArgb(r.Next())); 1226 } 1227 } 1228 Task[] tasks = new Task[20]; 1229 byte[][] datas = new byte[tasks.Length][]; 1230 for (int i = 0; i<tasks.Length; i++) { 1231 tasks[i] = Task.Factory.StartNew((idx) => { 1232 using (var stream = new MemoryStream()) { 1233 XmlGenerator.Serialize(b, stream); 1234 datas[(int)idx] = stream.ToArray(); 1235 } 1236 }, i); 1237 } 1238 Task.WaitAll(tasks); 1239 } 1186 1240 1187 1241 [ClassInitialize]
Note: See TracChangeset
for help on using the changeset viewer.