- Timestamp:
- 07/07/19 23:40:10 (5 years ago)
- Location:
- stable
- Files:
-
- 3 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
stable
-
stable/HeuristicLab.Tests
- Property svn:mergeinfo changed
-
stable/HeuristicLab.Tests/HeuristicLab.Persistence.Attic/UseCases.cs
r16559 r17097 35 35 using HeuristicLab.Persistence.Core; 36 36 using HeuristicLab.Persistence.Default.Xml; 37 using HeuristicLab.Tests; 37 38 using Microsoft.VisualStudio.TestTools.UnitTesting; 38 39 … … 132 133 } 133 134 135 private void CreateAllSamples() { 136 var asm = this.GetType().Assembly; 137 foreach (var t in asm.GetTypes()) { 138 var attrs = t.GetCustomAttributes<TestClassAttribute>(); 139 if (attrs.Any()) { 140 try { 141 var testObj = Activator.CreateInstance(t); 142 foreach (var mi in t.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)) { 143 var mAttrs = mi.GetCustomAttributes<TestCategoryAttribute>(); 144 var testCategories = mAttrs.SelectMany(mattr => mattr.TestCategories); 145 if (testCategories.Any(tc => tc == "Samples.Create")) { 146 mi.Invoke(testObj, new object[0]); 147 } 148 } 149 } catch (Exception) { } 150 } 151 } 152 } 134 153 135 154 [TestMethod] … … 137 156 [TestProperty("Time", "long")] 138 157 public void TestLoadingSamples() { 139 var path = @"C:\reps\hl-core\branches\2520_PersistenceReintegration\HeuristicLab.Optimizer\3.3\Documents"; 158 CreateAllSamples(); 159 var path = SamplesUtils.SamplesDirectory; 140 160 var serializer = new ProtoBufSerializer(); 141 161 foreach (var fileName in Directory.EnumerateFiles(path, "*.hl")) { … … 162 182 var newVersion = serializer.Deserialize(fileName + ".proto"); 163 183 Console.WriteLine("File: " + fileName); 164 } 165 } 166 } 184 File.Delete(fileName + ".proto"); 185 } 186 } 187 } 188 167 189 [TestMethod] 168 190 [TestCategory("Persistence.Attic")] 169 191 [TestProperty("Time", "long")] 170 192 public void TestLoadingRunAndStoreSamples() { 171 var path = @"C:\reps\hl-core\branches\2520_PersistenceReintegration\HeuristicLab.Optimizer\3.3\Documents"; 193 CreateAllSamples(); 194 var path = SamplesUtils.SamplesDirectory; 172 195 var serializer = new ProtoBufSerializer(); 173 196 foreach (var fileName in Directory.EnumerateFiles(path, "*.hl")) { … … 178 201 exec.Paused += (sender, e) => { 179 202 serializer.Serialize(exec, fileName + "_paused.proto"); 180 Console.WriteLine("Paused File: " + fileName); 203 Console.WriteLine("Serialized paused file: " + fileName); 204 File.Delete(fileName + "_paused.proto"); 181 205 }; 182 206 exec.Stopped += (sender, e) => { 183 207 serializer.Serialize(exec, fileName + "_stopped.proto"); 184 Console.WriteLine("Stopped File: " + fileName); 208 Console.WriteLine("Serialized stopped file: " + fileName); 209 File.Delete(fileName + "_stopped.proto"); 185 210 }; 186 211 var t = exec.StartAsync();
Note: See TracChangeset
for help on using the changeset viewer.