Merge lp:~john-park-west/concordion-net/builderconfig into lp:concordion-net

Proposed by John Park West
Status: Approved
Approved by: jeffreycameron@gmail.com
Approved revision: 83
Proposed branch: lp:~john-park-west/concordion-net/builderconfig
Merge into: lp:concordion-net
Diff against target: 1162 lines (+669/-75)
26 files modified
Concordion.Spec/Concordion/Command/AssertEquals/ExceptionsTest.cs (+0/-1)
Concordion.msbuild (+26/-11)
Concordion.sln (+6/-0)
Concordion/Internal/ClassNameBasedSpecificationLocator.cs (+10/-3)
Concordion/Internal/ConcordionBuilder.cs (+1/-1)
Concordion/Internal/ConcordionConfig.cs (+42/-6)
Concordion/Internal/ConcordionConfigParser.cs (+29/-1)
Concordion/Internal/Runner/DefaultConcordionRunner.cs (+33/-13)
Concordion/Internal/SpecificationConfig.cs (+8/-0)
Concordion/Properties/AssemblyInfo.cs (+0/-2)
Concordion_Config.Spec/Builder/ExtendedBuilder.cs (+21/-0)
Concordion_Config.Spec/Command/BannedWordCommand.cs (+58/-0)
Concordion_Config.Spec/Command/ScreenshotCommand.cs (+70/-0)
Concordion_Config.Spec/Concordion.config (+4/-0)
Concordion_Config.Spec/Concordion_Config.Spec.config (+5/-0)
Concordion_Config.Spec/Concordion_Config.Spec.csproj (+94/-0)
Concordion_Config.Spec/CustomCommand/AbstractFixture.cs (+23/-0)
Concordion_Config.Spec/CustomCommand/CustomCommands.cs (+15/-0)
Concordion_Config.Spec/CustomCommand/Run.cs (+13/-0)
Concordion_Config.Spec/Properties/AssemblyInfo.cs (+38/-0)
Concordion_Config.Spec/Spec/CustomCommand/CustomCommands.html (+22/-0)
Concordion_Config.Spec/Spec/CustomCommand/Run.html (+10/-0)
Concordion_Config.Spec/concordion.css (+81/-0)
Gallio.ConcordionAdapter/Model/ConcordionTest.cs (+0/-18)
Gallio.ConcordionAdapter/Model/ConcordionTestController.cs (+26/-2)
Gallio.ConcordionAdapter/Model/ConcordionTestExplorer.cs (+34/-17)
To merge this branch: bzr merge lp:~john-park-west/concordion-net/builderconfig
Reviewer Review Type Date Requested Status
jeffreycameron@gmail.com Pending
Review via email: mp+37360@code.launchpad.net

Description of the change

(1) New config "Builder" in Concordion.config to allow you to choose your own builder class instead of using ConcordionBuilder, this will allow you to specify your own derived class (if this config is not present it will default to ConcordionBuilder class.)
(2) Code for BaseInputDirectory allowing you to put html specs in different directory.

To post a comment you must log in.
83. By John Park West

ConcordionTestExplorer to obtain full name ( otherwise unable to obtain the fullname in Gallio RunnerExtension and Teamcity build).

Unmerged revisions

83. By John Park West

ConcordionTestExplorer to obtain full name ( otherwise unable to obtain the fullname in Gallio RunnerExtension and Teamcity build).

82. By John Park West

removed use of xhtml namespace

81. By John Park West

Updates to allow user commands via new config "Builder" in Concordion.config and implemention of BaseInputDirectory

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Concordion.Spec/Concordion/Command/AssertEquals/ExceptionsTest.cs'
2--- Concordion.Spec/Concordion/Command/AssertEquals/ExceptionsTest.cs 2009-04-18 17:22:05 +0000
3+++ Concordion.Spec/Concordion/Command/AssertEquals/ExceptionsTest.cs 2010-10-16 22:42:45 +0000
4@@ -9,7 +9,6 @@
5 [ConcordionTest]
6 public class ExceptionsTest
7 {
8- string successCount;
9
10 public object countsFromExecutingSnippetWithSimulatedEvaluationResult(string snippet, string simulatedResult)
11 {
12
13=== modified file 'Concordion.msbuild'
14--- Concordion.msbuild 2010-09-12 13:10:47 +0000
15+++ Concordion.msbuild 2010-10-16 22:42:45 +0000
16@@ -70,14 +70,14 @@
17 <ItemGroup>
18 <ConcordionFiles Include="Concordion\bin\Release\Concordion.dll" />
19 <ConcordionFiles Include="Concordion\bin\Release\Concordion.pdb" />
20- <!--<ConcordionFiles Include="Concordion\bin\Release\Concordion.xml" />-->
21- <ConcordionFiles Include="Concordion\bin\Release\Concordion.config" />
22+
23 <ConcordionFiles Include="Concordion\bin\Release\OGNL.dll" />
24 </ItemGroup>
25
26 <ItemGroup>
27 <ConcordionSpecFiles Include="Concordion.Spec\bin\Release\Concordion.Spec.dll" />
28 <ConcordionSpecFiles Include="Concordion.Spec\bin\Release\Concordion.Spec.pdb" />
29+ <ConcordionSpecFiles Include="Concordion.Spec\bin\Release\Concordion.config" />
30 <ConcordionSpecFiles Include="Concordion.Spec\bin\Release\Concordion.Spec.config" />
31 </ItemGroup>
32
33@@ -120,19 +120,34 @@
34 </Target>
35
36 <ItemGroup>
37- <TestAssemblies Include="Concordion.Spec\bin\Release\Concordion.Spec.dll" />
38+ <ConcordionSpecAssemblies Include="Concordion.Spec\bin\Release\Concordion.Spec.dll" />
39+ <ConcordionSpecConfigAssemblies Include="Concordion_Config.Spec\bin\Release\Concordion_Config.Spec.dll" />
40 <Plugins Include="Gallio.ConcordionAdapter\bin\Release" />
41 </ItemGroup>
42
43+
44+
45 <Target Name="Test-Specs" DependsOnTargets="Staging">
46- <Gallio Files="@(TestAssemblies)"
47- PluginDirectories="@(Plugins)"
48- ReportDirectory="Reports"
49- WorkingDirectory="."
50- ReportTypes="XHtml"
51- ShowReports="false"
52- IgnoreFailures="true"
53- RunnerType="Local" />
54+ <Gallio Files="@(ConcordionSpecAssemblies)"
55+ PluginDirectories="@(Plugins)"
56+ ReportDirectory="Reports"
57+ WorkingDirectory="."
58+ ReportTypes="XHtml"
59+ ShowReports="false"
60+ IgnoreFailures="true"
61+ RunnerType="Local" />
62+ <!--Tests 'Builder' config in Concordion.config and 'BaseInputDirectory' config in Concordion_Config.Spec.config-->
63+ <Gallio Files="@(ConcordionSpecConfigAssemblies)"
64+ PluginDirectories="@(Plugins)"
65+ ReportDirectory="Reports"
66+ WorkingDirectory="."
67+ ReportTypes="XHtml"
68+ ShowReports="false"
69+ IgnoreFailures="true"
70+ RunnerType="Local" />
71+
72+
73+
74 </Target>
75
76 <Target Name="Package" DependsOnTargets="Test-Specs">
77
78=== modified file 'Concordion.sln'
79--- Concordion.sln 2009-05-18 19:18:24 +0000
80+++ Concordion.sln 2010-10-16 22:42:45 +0000
81@@ -9,6 +9,8 @@
82 EndProject
83 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gallio.ConcordionAdapter", "Gallio.ConcordionAdapter\Gallio.ConcordionAdapter.csproj", "{57D6B2E4-69A8-42A6-8220-AAE6EDFB902D}"
84 EndProject
85+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Concordion_Config.Spec", "Concordion_Config.Spec\Concordion_Config.Spec.csproj", "{A24F1363-9318-490D-9778-5E6B42EBBCFA}"
86+EndProject
87 Global
88 GlobalSection(SolutionConfigurationPlatforms) = preSolution
89 Debug|Any CPU = Debug|Any CPU
90@@ -31,6 +33,10 @@
91 {57D6B2E4-69A8-42A6-8220-AAE6EDFB902D}.Debug|Any CPU.Build.0 = Debug|Any CPU
92 {57D6B2E4-69A8-42A6-8220-AAE6EDFB902D}.Release|Any CPU.ActiveCfg = Release|Any CPU
93 {57D6B2E4-69A8-42A6-8220-AAE6EDFB902D}.Release|Any CPU.Build.0 = Release|Any CPU
94+ {A24F1363-9318-490D-9778-5E6B42EBBCFA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
95+ {A24F1363-9318-490D-9778-5E6B42EBBCFA}.Debug|Any CPU.Build.0 = Debug|Any CPU
96+ {A24F1363-9318-490D-9778-5E6B42EBBCFA}.Release|Any CPU.ActiveCfg = Release|Any CPU
97+ {A24F1363-9318-490D-9778-5E6B42EBBCFA}.Release|Any CPU.Build.0 = Release|Any CPU
98 EndGlobalSection
99 GlobalSection(SolutionProperties) = preSolution
100 HideSolutionNode = FALSE
101
102=== modified file 'Concordion/Internal/ClassNameBasedSpecificationLocator.cs'
103--- Concordion/Internal/ClassNameBasedSpecificationLocator.cs 2010-09-23 03:04:34 +0000
104+++ Concordion/Internal/ClassNameBasedSpecificationLocator.cs 2010-10-16 22:42:45 +0000
105@@ -17,6 +17,7 @@
106 using System.Linq;
107 using System.Text;
108 using Concordion.Api;
109+using System.IO;
110
111 namespace Concordion.Internal
112 {
113@@ -26,15 +27,21 @@
114
115 public Resource LocateSpecification(object fixture)
116 {
117- var fixtureName = fixture.GetType().ToString();
118+ var fixtureType = fixture.GetType();
119+ var fixtureName = fixtureType.ToString();
120+ var assemblyName = fixtureType.Assembly.GetName().Name;
121+ var specConfig = new SpecificationConfig().Load(fixtureType);
122+ var specInputDirectory = specConfig.BaseInputDirectory;
123+ if (specInputDirectory != Directory.GetCurrentDirectory())
124+ {
125+ fixtureName = fixtureName.Replace(assemblyName, assemblyName + "\\" + specInputDirectory);
126+ }
127 fixtureName = fixtureName.Replace(".", "\\");
128 if (fixtureName.EndsWith("Test"))
129 {
130 fixtureName = fixtureName.Remove(fixtureName.Length - 4);
131 }
132-
133 var path = fixtureName + ".html";
134-
135 return new Resource(path);
136 }
137
138
139=== modified file 'Concordion/Internal/ConcordionBuilder.cs'
140--- Concordion/Internal/ConcordionBuilder.cs 2009-05-08 12:54:38 +0000
141+++ Concordion/Internal/ConcordionBuilder.cs 2010-10-16 22:42:45 +0000
142@@ -276,7 +276,7 @@
143 {
144 RunCommand.Runners.Add("concordion", new DefaultConcordionRunner(Source, Target));
145
146- var config = new ConcordionConfig().Load();
147+ var config = ConcordionConfig.Load();
148
149 foreach (var runner in config.Runners)
150 {
151
152=== modified file 'Concordion/Internal/ConcordionConfig.cs'
153--- Concordion/Internal/ConcordionConfig.cs 2009-05-08 12:54:38 +0000
154+++ Concordion/Internal/ConcordionConfig.cs 2010-10-16 22:42:45 +0000
155@@ -27,6 +27,8 @@
156 /// </summary>
157 public class ConcordionConfig
158 {
159+ private static Dictionary<string, ConcordionConfig> configs = new Dictionary<string, ConcordionConfig>();
160+
161 #region Properties
162
163 /// <summary>
164@@ -37,7 +39,13 @@
165 {
166 get;
167 set;
168- }
169+ }
170+
171+ public Type BuilderType
172+ {
173+ get;
174+ set;
175+ }
176
177 #endregion
178
179@@ -46,9 +54,10 @@
180 /// <summary>
181 /// Initializes a new instance of the <see cref="ConcordionConfig"/> class.
182 /// </summary>
183- public ConcordionConfig()
184+ private ConcordionConfig()
185 {
186 Runners = new Dictionary<string, IRunner>();
187+ BuilderType = typeof(ConcordionBuilder);
188 }
189
190 #endregion
191@@ -58,12 +67,39 @@
192 /// <summary>
193 /// Loads this instance.
194 /// </summary>
195- public ConcordionConfig Load()
196+ public static ConcordionConfig Load()
197 {
198+ /*
199 var defaultConfigFile = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + @"\Concordion.config";
200- Load(defaultConfigFile);
201-
202- return this;
203+
204+ ConcordionConfig config;
205+ configs.TryGetValue(defaultConfigFile, out config);
206+ if (config == null)
207+ {
208+ config = new ConcordionConfig();
209+ config.Load(defaultConfigFile);
210+ configs.Add(defaultConfigFile, config);
211+ }
212+ //Load(defaultConfigFile);
213+ return config;
214+ */
215+ return Load(Assembly.GetExecutingAssembly());
216+ }
217+
218+ public static ConcordionConfig Load(Assembly assembly)
219+ {
220+ var defaultConfigFile = Path.GetDirectoryName(assembly.Location) + @"\Concordion.config";
221+
222+ ConcordionConfig config;
223+ configs.TryGetValue(defaultConfigFile, out config);
224+ if (config == null)
225+ {
226+ config = new ConcordionConfig();
227+ config.Load(defaultConfigFile);
228+ configs.Add(defaultConfigFile, config);
229+ }
230+ //Load(defaultConfigFile);
231+ return config;
232 }
233
234 /// <summary>
235
236=== modified file 'Concordion/Internal/ConcordionConfigParser.cs'
237--- Concordion/Internal/ConcordionConfigParser.cs 2009-05-08 12:54:38 +0000
238+++ Concordion/Internal/ConcordionConfigParser.cs 2010-10-16 22:42:45 +0000
239@@ -77,6 +77,7 @@
240 if (configElement.Name == "Concordion")
241 {
242 LoadRunners(configElement);
243+ LoadBuilder(configElement);
244 }
245 }
246
247@@ -110,7 +111,34 @@
248 }
249 }
250 }
251- }
252+ }
253+
254+ private void LoadBuilder(XElement element)
255+ {
256+ var builder = element.Element("Builder");
257+ if (builder != null)
258+ {
259+ var builderTypeText = builder.Attribute("type");
260+ if (builderTypeText != null)
261+ {
262+ Type builderType = Type.GetType(builderTypeText.Value);
263+ //var builderObject = Activator.CreateInstance(builderTypeText);
264+ if (builderType != null)
265+ {
266+ Config.BuilderType = builderType;
267+ }
268+ else
269+ {
270+ throw new ApplicationException("Invalid Builder type [" + builderTypeText.Value + "]");
271+ }
272+
273+ }
274+ else
275+ {
276+ throw new ApplicationException("No 'type' specified for the builder");
277+ }
278+ }
279+ }
280
281 #endregion
282 }
283
284=== modified file 'Concordion/Internal/Runner/DefaultConcordionRunner.cs'
285--- Concordion/Internal/Runner/DefaultConcordionRunner.cs 2010-09-18 23:09:52 +0000
286+++ Concordion/Internal/Runner/DefaultConcordionRunner.cs 2010-10-16 22:42:45 +0000
287@@ -19,6 +19,7 @@
288 using Concordion.Api;
289 using System.Text.RegularExpressions;
290 using System.Reflection;
291+using System.IO;
292
293 namespace Concordion.Internal.Runner
294 {
295@@ -64,9 +65,14 @@
296
297 public RunnerResult Execute(object callingFixture, Resource resource, string href)
298 {
299- var runnerFixture = GetFixture(resource, href, callingFixture);
300-
301- var concordion = new ConcordionBuilder()
302+ var callingFixtureType = callingFixture.GetType();
303+ var callingFixtureAssembly = callingFixtureType.Assembly;
304+ var specConfig = new SpecificationConfig().Load(callingFixtureType);
305+ var runnerFixture = GetFixture(specConfig, resource, href, callingFixtureAssembly, callingFixture);
306+ ConcordionConfig concordionConfig = ConcordionConfig.Load(callingFixtureAssembly);
307+ var builderType = concordionConfig.BuilderType;
308+ ConcordionBuilder builder = CreateConcordionBuilder(builderType);
309+ var concordion = builder
310 .WithSource(Source)
311 .WithTarget(Target)
312 .Build();
313@@ -90,15 +96,21 @@
314 return new RunnerResult(result);
315 }
316
317- private static object GetFixture(Resource resource, string href, object callingFixture)
318- {
319- var fixtureName = GetNameOfFixtureToRun(resource, href);
320- return GetFixtureToRun(callingFixture, fixtureName);
321- }
322-
323- private static object GetFixtureToRun(object fixture, string fixtureName)
324- {
325- var fixtureAssembly = fixture.GetType().Assembly;
326+ private ConcordionBuilder CreateConcordionBuilder(Type builderType)
327+ {
328+ ConstructorInfo constructor = builderType.GetConstructor(Type.EmptyTypes);
329+ var builder = constructor.Invoke(new object[] { }) as ConcordionBuilder;
330+ return builder;
331+ }
332+
333+ private static object GetFixture(SpecificationConfig specConfig, Resource resource, string href, Assembly fixtureAssembly,object callingFixture)
334+ {
335+ var fixtureName = GetNameOfFixtureToRun(specConfig,fixtureAssembly,resource, href);
336+ return GetFixtureToRun(fixtureAssembly, fixtureName);
337+ }
338+
339+ private static object GetFixtureToRun(Assembly fixtureAssembly, string fixtureName)
340+ {
341 var fixtureType = fixtureAssembly.GetType(fixtureName, false, true);
342 if (fixtureType == null)
343 {
344@@ -112,10 +124,18 @@
345 return null;
346 }
347
348- private static string GetNameOfFixtureToRun(Resource resource, string href)
349+ private static string GetNameOfFixtureToRun(SpecificationConfig specConfig,Assembly fixtureAssembly,Resource resource, string href)
350 {
351 Resource hrefResource = resource.GetRelativeResource(href);
352 var fixturePath = hrefResource.Path;
353+ var specInputDirectory=specConfig.BaseInputDirectory;
354+ var assemblyNameWithSlashes = fixtureAssembly.GetName().Name.Replace(".", "\\");
355+
356+ if (specInputDirectory != Directory.GetCurrentDirectory())
357+ {
358+ fixturePath = fixturePath.Replace(assemblyNameWithSlashes + "\\" + specInputDirectory, assemblyNameWithSlashes);
359+ }
360+
361 var fixtureFullyQualifiedPath = fixturePath.Replace("\\", ".");
362 var fixtureName = fixtureFullyQualifiedPath.Replace(".html", "");
363
364
365=== modified file 'Concordion/Internal/SpecificationConfig.cs'
366--- Concordion/Internal/SpecificationConfig.cs 2009-05-23 11:51:58 +0000
367+++ Concordion/Internal/SpecificationConfig.cs 2010-10-16 22:42:45 +0000
368@@ -49,6 +49,12 @@
369 set;
370 }
371
372+ public bool ConfigFileFound
373+ {
374+ get;
375+ set;
376+ }
377+
378 #endregion
379
380 #region Constructors
381@@ -57,6 +63,7 @@
382 {
383 this.BaseInputDirectory = Directory.GetCurrentDirectory();
384 this.BaseOutputDirectory = Environment.GetEnvironmentVariable("TEMP");
385+ this.ConfigFileFound = false;
386 }
387
388 #endregion
389@@ -95,6 +102,7 @@
390 var configFileName = pathToAssembly.Replace(".dll", ".config");
391 if (File.Exists(configFileName))
392 {
393+ ConfigFileFound = true;
394 var specificationConfigParser = new SpecificationConfigParser(this);
395 specificationConfigParser.Parse(new StreamReader(configFileName));
396 }
397
398=== modified file 'Concordion/Properties/AssemblyInfo.cs'
399--- Concordion/Properties/AssemblyInfo.cs 2010-09-12 12:44:48 +0000
400+++ Concordion/Properties/AssemblyInfo.cs 2010-10-16 22:42:45 +0000
401@@ -22,7 +22,5 @@
402 [assembly: ComVisible(false)]
403 [assembly: CLSCompliant(true)]
404 [assembly: Guid("923eb1d8-0d6a-4a05-896c-16f127f2944f")]
405-[assembly: AssemblyVersion("0.1.99.9999")]
406-[assembly: AssemblyFileVersion("0.1.99.9999")]
407
408
409
410=== added directory 'Concordion_Config.Spec'
411=== added directory 'Concordion_Config.Spec/Builder'
412=== added file 'Concordion_Config.Spec/Builder/ExtendedBuilder.cs'
413--- Concordion_Config.Spec/Builder/ExtendedBuilder.cs 1970-01-01 00:00:00 +0000
414+++ Concordion_Config.Spec/Builder/ExtendedBuilder.cs 2010-10-16 22:42:45 +0000
415@@ -0,0 +1,21 @@
416+using System;
417+using System.Collections.Generic;
418+using System.Linq;
419+using System.Text;
420+using Concordion.Internal;
421+using Concordion_Config.Spec.Command;
422+
423+namespace Concordion_Config.Spec.Builder
424+{
425+ public class ExtendedBuilder : ConcordionBuilder
426+ {
427+ private string EXTENSION_COMMAND_NAMESPACE = "http://www.fictioushostname.abc/2007/extension-commands";
428+
429+ public ExtendedBuilder()
430+ {
431+ WithCommand(EXTENSION_COMMAND_NAMESPACE, "bannedword", new BannedWordCommand());
432+ WithCommand(EXTENSION_COMMAND_NAMESPACE, "screenshot", new ScreenshotCommand());
433+
434+ }
435+ }
436+}
437
438=== added directory 'Concordion_Config.Spec/Command'
439=== added file 'Concordion_Config.Spec/Command/BannedWordCommand.cs'
440--- Concordion_Config.Spec/Command/BannedWordCommand.cs 1970-01-01 00:00:00 +0000
441+++ Concordion_Config.Spec/Command/BannedWordCommand.cs 2010-10-16 22:42:45 +0000
442@@ -0,0 +1,58 @@
443+using System;
444+using System.Collections.Generic;
445+using System.Linq;
446+using System.Text;
447+using Concordion.Internal.Commands;
448+using Concordion.Api;
449+using Concordion.Internal;
450+using Concordion.Internal.Util;
451+using System.Data;
452+using System.Text.RegularExpressions;
453+using System.Reflection;
454+
455+namespace Concordion_Config.Spec.Command
456+{
457+ public class BannedWordCommand : AbstractCommand
458+ {
459+ public override void Execute(CommandCall commandCall, IEvaluator evaluator, IResultRecorder resultRecorder)
460+ {
461+ String commandName = GetType().Name;
462+ Check.IsFalse(commandCall.HasChildCommands, "Nesting commands inside a '" + commandName + "' is not supported");
463+ var evalString=commandCall.Expression;
464+ Element element = commandCall.Element;
465+ Check.NotNull(evalString, "The " + commandName + " attribute must be set for an element containing " + commandName);
466+
467+ object fixture = evaluator.Fixture;
468+ MethodInfo theMethod = fixture.GetType().GetMethod(evalString, new Type[] { typeof(string) });
469+ if (theMethod == null)
470+ {
471+ throw new Exception("Fixture: " + fixture.GetType().FullName + " does not contain method named [" + evalString + "(string)]");
472+ }
473+ object result=theMethod.Invoke(fixture,new object[]{element.Text});
474+ if (result == null)
475+ {
476+ element.AddStyleClass("success");
477+ resultRecorder.Record(Result.Success);
478+ return;
479+ }
480+ String bannedWord = result as String;
481+ if (bannedWord == null)
482+ {
483+ throw new Exception("Method method named [" + evalString + "(string)] in " + fixture.GetType().FullName + " did not return string");
484+ }
485+ else
486+ {
487+ element.AddStyleClass("failure");
488+ resultRecorder.Record(Result.Failure);
489+ Element span=new Element("span");
490+ span.AddStyleClass("commentary");
491+ span.AppendText("Banned word ["+bannedWord+"] used");
492+ element.AppendChild(span);
493+ }
494+
495+ }
496+
497+ public override void Setup(CommandCall commandCall, IEvaluator evaluator, IResultRecorder resultRecorder) { }
498+ public override void Verify(CommandCall commandCall, IEvaluator evaluator, IResultRecorder resultRecorder) { }
499+ }
500+}
501
502=== added file 'Concordion_Config.Spec/Command/ScreenshotCommand.cs'
503--- Concordion_Config.Spec/Command/ScreenshotCommand.cs 1970-01-01 00:00:00 +0000
504+++ Concordion_Config.Spec/Command/ScreenshotCommand.cs 2010-10-16 22:42:45 +0000
505@@ -0,0 +1,70 @@
506+using System;
507+using System.Collections.Generic;
508+using System.Linq;
509+using System.Text;
510+using Concordion.Internal.Commands;
511+using Concordion.Internal;
512+using Concordion.Api;
513+using Concordion.Internal.Util;
514+using System.IO;
515+using System.Drawing;
516+using System.Drawing.Imaging;
517+using System.Windows.Forms;
518+
519+namespace Concordion_Config.Spec.Command
520+{
521+ public class ScreenshotCommand : AbstractCommand
522+ {
523+ public override void Execute(CommandCall commandCall, IEvaluator evaluator, IResultRecorder resultRecorder)
524+ {
525+ object fixture = evaluator.Fixture;
526+ Element element = commandCall.Element;
527+ String fileName = commandCall.Expression;
528+ Check.NotEmpty(fileName, "fileName cannot be null");
529+ Resource res = commandCall.Resource;
530+ var p=new SpecificationConfig().Load(fixture.GetType().Assembly);
531+ var directoryPath = Path.Combine(p.BaseOutputDirectory, StripLeadingBackslash(res.Parent.Path));
532+ DirectoryInfo directoryInfo = new DirectoryInfo(directoryPath);
533+ if (!directoryInfo.Exists)
534+ {
535+ Directory.CreateDirectory(directoryPath);
536+ }
537+ var imageFileName = Path.Combine(directoryPath, fileName);
538+ var size=CaptureDesktop(imageFileName);
539+ Element imgElement = new Element("img");
540+ imgElement.AddAttribute("src", fileName);
541+ imgElement.AddAttribute("width", Convert.ToString(size.Width));
542+ imgElement.AddAttribute("height", Convert.ToString(size.Height));
543+ element.AppendChild(imgElement);
544+ }
545+
546+
547+ private static string StripLeadingBackslash(string path)
548+ {
549+ var strippedPath = path;
550+ if (strippedPath.StartsWith("\\"))
551+ {
552+ strippedPath = strippedPath.Remove(0, 1);
553+ }
554+ return strippedPath;
555+ }
556+
557+
558+
559+ private Size CaptureDesktop(string imageFileName)
560+ {
561+ Bitmap screenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb);
562+ Graphics gfxScreenshot = Graphics.FromImage(screenshot);
563+ gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
564+ screenshot.Save(imageFileName, ImageFormat.Jpeg);
565+ var size=screenshot.Size;
566+ gfxScreenshot.Dispose();
567+ screenshot.Dispose();
568+ return size;
569+
570+ }
571+
572+ public override void Setup(CommandCall commandCall, IEvaluator evaluator, IResultRecorder resultRecorder) { }
573+ public override void Verify(CommandCall commandCall, IEvaluator evaluator, IResultRecorder resultRecorder) { }
574+ }
575+}
576
577=== added file 'Concordion_Config.Spec/Concordion.config'
578--- Concordion_Config.Spec/Concordion.config 1970-01-01 00:00:00 +0000
579+++ Concordion_Config.Spec/Concordion.config 2010-10-16 22:42:45 +0000
580@@ -0,0 +1,4 @@
581+<?xml version="1.0" encoding="utf-8" ?>
582+<Concordion>
583+ <Builder type="Concordion_Config.Spec.Builder.ExtendedBuilder, Concordion_Config.Spec, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
584+</Concordion>
585\ No newline at end of file
586
587=== added file 'Concordion_Config.Spec/Concordion_Config.Spec.config'
588--- Concordion_Config.Spec/Concordion_Config.Spec.config 1970-01-01 00:00:00 +0000
589+++ Concordion_Config.Spec/Concordion_Config.Spec.config 2010-10-16 22:42:45 +0000
590@@ -0,0 +1,5 @@
591+<?xml version="1.0" encoding="utf-8" ?>
592+<Specification>
593+ <BaseInputDirectory path="Spec" />
594+ <BaseOutputDirectory path="Spec-Output" />
595+</Specification>
596\ No newline at end of file
597
598=== added file 'Concordion_Config.Spec/Concordion_Config.Spec.csproj'
599--- Concordion_Config.Spec/Concordion_Config.Spec.csproj 1970-01-01 00:00:00 +0000
600+++ Concordion_Config.Spec/Concordion_Config.Spec.csproj 2010-10-16 22:42:45 +0000
601@@ -0,0 +1,94 @@
602+<?xml version="1.0" encoding="utf-8"?>
603+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
604+ <PropertyGroup>
605+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
606+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
607+ <ProductVersion>8.0.30703</ProductVersion>
608+ <SchemaVersion>2.0</SchemaVersion>
609+ <ProjectGuid>{A24F1363-9318-490D-9778-5E6B42EBBCFA}</ProjectGuid>
610+ <OutputType>Library</OutputType>
611+ <AppDesignerFolder>Properties</AppDesignerFolder>
612+ <RootNamespace>Concordion_Config.Spec</RootNamespace>
613+ <AssemblyName>Concordion_Config.Spec</AssemblyName>
614+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
615+ <FileAlignment>512</FileAlignment>
616+ </PropertyGroup>
617+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
618+ <DebugSymbols>true</DebugSymbols>
619+ <DebugType>full</DebugType>
620+ <Optimize>false</Optimize>
621+ <OutputPath>bin\Debug\</OutputPath>
622+ <DefineConstants>DEBUG;TRACE</DefineConstants>
623+ <ErrorReport>prompt</ErrorReport>
624+ <WarningLevel>4</WarningLevel>
625+ </PropertyGroup>
626+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
627+ <DebugType>pdbonly</DebugType>
628+ <Optimize>true</Optimize>
629+ <OutputPath>bin\Release\</OutputPath>
630+ <DefineConstants>TRACE</DefineConstants>
631+ <ErrorReport>prompt</ErrorReport>
632+ <WarningLevel>4</WarningLevel>
633+ </PropertyGroup>
634+ <ItemGroup>
635+ <Reference Include="Gallio, Version=3.2.0.0, Culture=neutral, PublicKeyToken=eb9cfa67ee6ab36e, processorArchitecture=MSIL" />
636+ <Reference Include="MbUnit, Version=3.2.0.0, Culture=neutral, PublicKeyToken=eb9cfa67ee6ab36e, processorArchitecture=MSIL" />
637+ <Reference Include="System" />
638+ <Reference Include="System.Core" />
639+ <Reference Include="System.Drawing" />
640+ <Reference Include="System.Windows.Forms" />
641+ <Reference Include="System.Xml.Linq" />
642+ <Reference Include="System.Data.DataSetExtensions" />
643+ <Reference Include="System.Data" />
644+ <Reference Include="System.Xml" />
645+ </ItemGroup>
646+ <ItemGroup>
647+ <Compile Include="Builder\ExtendedBuilder.cs" />
648+ <Compile Include="Command\ScreenshotCommand.cs" />
649+ <Compile Include="CustomCommand\AbstractFixture.cs" />
650+ <Compile Include="Command\BannedWordCommand.cs" />
651+ <Compile Include="CustomCommand\CustomCommands.cs" />
652+ <Compile Include="CustomCommand\Run.cs" />
653+ <Compile Include="Properties\AssemblyInfo.cs" />
654+ </ItemGroup>
655+ <ItemGroup>
656+ <None Include="Concordion.config">
657+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
658+ <SubType>Designer</SubType>
659+ </None>
660+ </ItemGroup>
661+ <ItemGroup>
662+ <None Include="Concordion_Config.Spec.config">
663+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
664+ </None>
665+ </ItemGroup>
666+ <ItemGroup>
667+ <ProjectReference Include="..\Concordion\Concordion.csproj">
668+ <Project>{F401D347-5762-49DA-B7DF-4C6C9E79E08A}</Project>
669+ <Name>Concordion</Name>
670+ </ProjectReference>
671+ </ItemGroup>
672+ <ItemGroup>
673+ <EmbeddedResource Include="Spec\CustomCommand\CustomCommands.html">
674+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
675+ </EmbeddedResource>
676+ </ItemGroup>
677+ <ItemGroup>
678+ <EmbeddedResource Include="Spec\CustomCommand\Run.html">
679+ <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
680+ </EmbeddedResource>
681+ </ItemGroup>
682+ <ItemGroup>
683+ <EmbeddedResource Include="concordion.css">
684+ <CopyToOutputDirectory>Always</CopyToOutputDirectory>
685+ </EmbeddedResource>
686+ </ItemGroup>
687+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
688+ <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
689+ Other similar extension points exist, see Microsoft.Common.targets.
690+ <Target Name="BeforeBuild">
691+ </Target>
692+ <Target Name="AfterBuild">
693+ </Target>
694+ -->
695+</Project>
696\ No newline at end of file
697
698=== added directory 'Concordion_Config.Spec/CustomCommand'
699=== added file 'Concordion_Config.Spec/CustomCommand/AbstractFixture.cs'
700--- Concordion_Config.Spec/CustomCommand/AbstractFixture.cs 1970-01-01 00:00:00 +0000
701+++ Concordion_Config.Spec/CustomCommand/AbstractFixture.cs 2010-10-16 22:42:45 +0000
702@@ -0,0 +1,23 @@
703+using System;
704+using System.Collections.Generic;
705+using System.Linq;
706+using System.Text;
707+
708+namespace Concordion_Config.Spec.CustomCommand
709+{
710+ public class AbstractFixture
711+ {
712+ public string BannedWordCheckerMethod(string text)
713+ {
714+ string[] bannedwords = new string[] { "click", "doubleClick" };
715+ foreach (string word in bannedwords)
716+ {
717+ if (text.Contains(word))
718+ {
719+ return word;
720+ }
721+ }
722+ return null;
723+ }
724+ }
725+}
726
727=== added file 'Concordion_Config.Spec/CustomCommand/CustomCommands.cs'
728--- Concordion_Config.Spec/CustomCommand/CustomCommands.cs 1970-01-01 00:00:00 +0000
729+++ Concordion_Config.Spec/CustomCommand/CustomCommands.cs 2010-10-16 22:42:45 +0000
730@@ -0,0 +1,15 @@
731+using System;
732+using System.Collections.Generic;
733+using System.Linq;
734+using System.Text;
735+using Concordion.Integration;
736+
737+
738+namespace Concordion_Config.Spec.CustomCommand
739+{
740+ [ConcordionTest]
741+ public class CustomCommands : AbstractFixture
742+ {
743+
744+ }
745+}
746
747=== added file 'Concordion_Config.Spec/CustomCommand/Run.cs'
748--- Concordion_Config.Spec/CustomCommand/Run.cs 1970-01-01 00:00:00 +0000
749+++ Concordion_Config.Spec/CustomCommand/Run.cs 2010-10-16 22:42:45 +0000
750@@ -0,0 +1,13 @@
751+using System;
752+using System.Collections.Generic;
753+using System.Linq;
754+using System.Text;
755+using Concordion.Integration;
756+
757+namespace Concordion_Config.Spec.CustomCommand
758+{
759+ [ConcordionTest]
760+ public class Run : AbstractFixture
761+ {
762+ }
763+}
764
765=== added directory 'Concordion_Config.Spec/Properties'
766=== added file 'Concordion_Config.Spec/Properties/AssemblyInfo.cs'
767--- Concordion_Config.Spec/Properties/AssemblyInfo.cs 1970-01-01 00:00:00 +0000
768+++ Concordion_Config.Spec/Properties/AssemblyInfo.cs 2010-10-16 22:42:45 +0000
769@@ -0,0 +1,38 @@
770+using System.Reflection;
771+using System.Runtime.CompilerServices;
772+using System.Runtime.InteropServices;
773+using Concordion.Integration;
774+
775+// General Information about an assembly is controlled through the following
776+// set of attributes. Change these attribute values to modify the information
777+// associated with an assembly.
778+[assembly: AssemblyTitle("Concordion-Config.Spec")]
779+[assembly: AssemblyDescription("")]
780+[assembly: AssemblyConfiguration("")]
781+[assembly: AssemblyCompany("Microsoft")]
782+[assembly: AssemblyProduct("Concordion-Config.Spec")]
783+[assembly: AssemblyCopyright("Copyright © Microsoft 2010")]
784+[assembly: AssemblyTrademark("")]
785+[assembly: AssemblyCulture("")]
786+
787+// Setting ComVisible to false makes the types in this assembly not visible
788+// to COM components. If you need to access a type in this assembly from
789+// COM, set the ComVisible attribute to true on that type.
790+[assembly: ComVisible(false)]
791+
792+// The following GUID is for the ID of the typelib if this project is exposed to COM
793+[assembly: Guid("7250c3b4-df8a-4ea8-a254-9c80edc3299b")]
794+
795+// Version information for an assembly consists of the following four values:
796+//
797+// Major Version
798+// Minor Version
799+// Build Number
800+// Revision
801+//
802+// You can specify all the values or you can default the Build and Revision Numbers
803+// by using the '*' as shown below:
804+// [assembly: AssemblyVersion("1.0.*")]
805+[assembly: AssemblyVersion("1.0.0.0")]
806+[assembly: AssemblyFileVersion("1.0.0.0")]
807+[assembly: ConcordionAssembly]
808\ No newline at end of file
809
810=== added directory 'Concordion_Config.Spec/Spec'
811=== added directory 'Concordion_Config.Spec/Spec/CustomCommand'
812=== added file 'Concordion_Config.Spec/Spec/CustomCommand/CustomCommands.html'
813--- Concordion_Config.Spec/Spec/CustomCommand/CustomCommands.html 1970-01-01 00:00:00 +0000
814+++ Concordion_Config.Spec/Spec/CustomCommand/CustomCommands.html 2010-10-16 22:42:45 +0000
815@@ -0,0 +1,22 @@
816+<html xmlns:concordion="http://www.concordion.org/2007/concordion"
817+xmlns:extension-commands="http://www.fictioushostname.abc/2007/extension-commands" >
818+ <head>
819+ <link href="../../concordion.css" rel="stylesheet" type="text/css" />
820+ <title>Custom Commands</title>
821+ </head>
822+ <body>
823+ <h1>Custom Commands Example</h1>
824+ <p />
825+
826+ (1) A simple command to check if the text contains any banned words.
827+ <p />
828+ A simple command to ensure the words nested inside the elements don't contain any agreed banned words (for the example below the banned words are "click" and "doubleClick" ).
829+ <p />
830+ <span extension-commands:bannedword="BannedWordCheckerMethod" >Don't mention the cli*k word, otherwise, this will fail!</span>
831+ <p />
832+
833+ (2) A command to take the screenshot of the desktop (this is the port of the Java Concordion screenshot command see http://github.com/talios/concordion-examples ).
834+ <p />
835+ <div extension-commands:screenshot="output.jpg"></div>
836+ </body>
837+</html>
838\ No newline at end of file
839
840=== added file 'Concordion_Config.Spec/Spec/CustomCommand/Run.html'
841--- Concordion_Config.Spec/Spec/CustomCommand/Run.html 1970-01-01 00:00:00 +0000
842+++ Concordion_Config.Spec/Spec/CustomCommand/Run.html 2010-10-16 22:42:45 +0000
843@@ -0,0 +1,10 @@
844+<html xmlns:concordion="http://www.concordion.org/2007/concordion"
845+xmlns:extension-commands="http://www.fictioushostname.abc/2007/extension-commands" >
846+ <head>
847+ <link href="../../concordion.css" rel="stylesheet" type="text/css" />
848+ <title>Custom Commands Via The Run Command</title>
849+ </head>
850+ <body>
851+ <a concordion:run="concordion" href="CustomCommands.html">Custom Commands</a>
852+ </body>
853+</html>
854\ No newline at end of file
855
856=== added file 'Concordion_Config.Spec/concordion.css'
857--- Concordion_Config.Spec/concordion.css 1970-01-01 00:00:00 +0000
858+++ Concordion_Config.Spec/concordion.css 2010-10-16 22:42:45 +0000
859@@ -0,0 +1,81 @@
860+* {
861+ font-family: Arial;
862+}
863+body {
864+ padding: 32px;
865+}
866+pre {
867+ padding: 6px 28px 6px 28px;
868+ background-color: #E8EEF7;
869+}
870+pre, pre *, code, kbd {
871+ font-family: Courier New, Courier;
872+ font-size: 10pt;
873+}
874+h1, h1 * {
875+ font-size: 24pt;
876+}
877+p, td, th, li, .breadcrumbs {
878+ font-size: 10pt;
879+}
880+p, li {
881+ line-height: 140%;
882+}
883+table {
884+ border-collapse: collapse;
885+ empty-cells: show;
886+ margin: 8px 0px 8px 0px;
887+}
888+th, td {
889+ border: 1px solid black;
890+ padding: 3px;
891+}
892+td {
893+ background-color: white;
894+ vertical-align: top;
895+}
896+th {
897+ background-color: #C3D9FF;
898+}
899+li {
900+ margin-top: 6px;
901+ margin-bottom: 6px;
902+}
903+
904+
905+.example {
906+ padding: 2px 12px 6px 12px;
907+ border: 1px solid #C3D9FF;
908+ margin: 6px 0px 28px 0px;
909+ background-color: #F5F9FD;
910+}
911+.example h3 {
912+ margin-top: 8px;
913+ margin-bottom: 8px;
914+ font-size: 12pt;
915+}
916+
917+.special {
918+ font-style: italic;
919+}
920+
921+.idea {
922+ font-size: 9pt;
923+ color: #888;
924+ font-style: italic;
925+}
926+.tight li {
927+ margin-top: 1px;
928+ margin-bottom: 1px;
929+}
930+.commentary {
931+ float: right;
932+ width: 200px;
933+ background-color: #ffffd0;
934+ padding:8px;
935+ border: 3px solid #eeeeb0;
936+ margin: 10px 0px 10px 10px;
937+}
938+.commentary, .commentary * {
939+ font-size: 8pt;
940+}
941\ No newline at end of file
942
943=== modified file 'Gallio.ConcordionAdapter/Model/ConcordionTest.cs'
944--- Gallio.ConcordionAdapter/Model/ConcordionTest.cs 2010-09-16 09:10:09 +0000
945+++ Gallio.ConcordionAdapter/Model/ConcordionTest.cs 2010-10-16 22:42:45 +0000
946@@ -104,23 +104,5 @@
947 */
948
949 #endregion
950-
951- //#region Override Methods
952-
953- /// <summary>
954- /// Gets the test controller factory.
955- /// </summary>
956- /// <value>The test controller factory.</value>
957- /*
958- public override Gallio.Common.Func<ITestController> TestControllerFactory
959- {
960- get
961- {
962- return CreateTestController;
963- }
964- }
965- */
966-
967- // #endregion
968 }
969 }
970
971=== modified file 'Gallio.ConcordionAdapter/Model/ConcordionTestController.cs'
972--- Gallio.ConcordionAdapter/Model/ConcordionTestController.cs 2010-09-16 09:10:09 +0000
973+++ Gallio.ConcordionAdapter/Model/ConcordionTestController.cs 2010-10-16 22:42:45 +0000
974@@ -25,6 +25,7 @@
975 /// </summary>
976 public class ConcordionTestController : TestController
977 {
978+
979 /// <inheritdoc />
980 protected override TestResult RunImpl(ITestCommand rootTestCommand, TestStep parentTestStep, TestExecutionOptions options, IProgressMonitor progressMonitor)
981 {
982@@ -67,9 +68,25 @@
983 private static TestResult RunTestFixture(ITestCommand testCommand, ConcordionTest concordionTest, TestStep parentTestStep)
984 {
985 ITestContext testContext = testCommand.StartPrimaryChildStep(parentTestStep);
986-
987 // The magic happens here!
988- var concordion = new ConcordionBuilder()
989+ Type builderType=null;
990+ try
991+ {
992+ ConcordionConfig concordionConfig = ConcordionConfig.Load(concordionTest.FixtureType.Assembly);
993+ builderType = concordionConfig.BuilderType;
994+ }
995+ catch (Exception e)
996+ {
997+ testContext.LogWriter.ConsoleError.WriteLine(e.Message);
998+ testContext.LogWriter.ConsoleError.WriteLine(e.StackTrace);
999+ return testContext.FinishStep(TestOutcome.Error, null);
1000+ }
1001+ ConcordionBuilder builder = CreateConcordionBuilder(builderType);
1002+ if (builder == null)
1003+ {
1004+ return testContext.FinishStep(TestOutcome.Error, null);
1005+ }
1006+ var concordion = builder
1007 .WithSource(concordionTest.Source)
1008 .WithTarget(concordionTest.Target)
1009 .WithSpecificationListener(new GallioResultRenderer())
1010@@ -83,6 +100,13 @@
1011 return testContext.FinishStep(passed ? TestOutcome.Passed : TestOutcome.Failed, null);
1012 }
1013
1014+ private static ConcordionBuilder CreateConcordionBuilder(Type builderType)
1015+ {
1016+ ConstructorInfo constructor = builderType.GetConstructor(Type.EmptyTypes);
1017+ var builder = constructor.Invoke(new object[] { }) as ConcordionBuilder;
1018+ return builder;
1019+ }
1020+
1021 private static TestResult RunChildTests(ITestCommand testCommand, TestStep parentTestStep, IProgressMonitor progressMonitor)
1022 {
1023 ITestContext testContext = testCommand.StartPrimaryChildStep(parentTestStep);
1024
1025=== modified file 'Gallio.ConcordionAdapter/Model/ConcordionTestExplorer.cs'
1026--- Gallio.ConcordionAdapter/Model/ConcordionTestExplorer.cs 2010-09-16 09:10:09 +0000
1027+++ Gallio.ConcordionAdapter/Model/ConcordionTestExplorer.cs 2010-10-16 22:42:45 +0000
1028@@ -39,16 +39,16 @@
1029 {
1030
1031 IAssemblyInfo assembly = ReflectionUtils.GetAssembly(codeElement);
1032+ var specConfig = GetSpecificationConfig(assembly);
1033 Version frameworkVersion = GetFrameworkVersion(assembly);
1034 if (frameworkVersion != null)
1035 {
1036 ITypeInfo type = ReflectionUtils.GetType(codeElement);
1037- Test assemblyTest = GetAssemblyTest(assembly, TestModel.RootTest, frameworkVersion, type == null);
1038+ Test assemblyTest = GetAssemblyTest(assembly, TestModel.RootTest, frameworkVersion, type == null, specConfig);
1039 if (type != null)
1040 {
1041- TryGetTypeTest(type, assemblyTest);
1042+ TryGetTypeTest(type, assemblyTest, specConfig);
1043 }
1044-
1045 }
1046 }
1047
1048@@ -78,7 +78,7 @@
1049 return false;
1050 }
1051
1052- private Test GetAssemblyTest(IAssemblyInfo assembly, Test parentTest, Version frameworkVersion, bool populateRecursively)
1053+ private Test GetAssemblyTest(IAssemblyInfo assembly, Test parentTest, Version frameworkVersion, bool populateRecursively, SpecificationConfig specConfig)
1054 {
1055 Test assemblyTest;
1056 if (!assemblyTests.TryGetValue(assembly, out assemblyTest))
1057@@ -94,21 +94,24 @@
1058 assemblyTests.Add(assembly, assemblyTest);
1059 }
1060
1061- GetInputOutputDirectories(assembly);
1062-
1063 if (populateRecursively)
1064 {
1065 foreach (var type in assembly.GetExportedTypes())
1066- TryGetTypeTest(type, assemblyTest);
1067+ TryGetTypeTest(type, assemblyTest,specConfig);
1068 }
1069
1070 return assemblyTest;
1071 }
1072
1073- private void GetInputOutputDirectories(IAssemblyInfo assembly)
1074+ private SpecificationConfig GetSpecificationConfig(IAssemblyInfo assembly)
1075 {
1076- var config = new SpecificationConfig().Load(assembly.Resolve(false));
1077-
1078+ var assemblyPath=assembly.Resolve(false);
1079+ var config = new SpecificationConfig().Load(assemblyPath);
1080+ if (!config.ConfigFileFound)
1081+ {
1082+ TestModel.AddAnnotation(new Annotation(AnnotationType.Info,assembly,"No specification config file found for assembly ["+assemblyPath+"], will use default settings"));
1083+ }
1084+ /*
1085 var baseInputDirectoryInfo = new DirectoryInfo(config.BaseInputDirectory);
1086 if (baseInputDirectoryInfo.Exists)
1087 {
1088@@ -117,7 +120,7 @@
1089 {
1090 TestModel.AddAnnotation(new Annotation(AnnotationType.Error, assembly, String.Format("The Base Input Directory {0} does not exist, reverting to default", config.BaseInputDirectory)));
1091 }
1092-
1093+ */
1094 var baseOutputDirectoryInfo = new DirectoryInfo(config.BaseOutputDirectory);
1095 this._baseOutputDirectory = baseOutputDirectoryInfo;
1096
1097@@ -125,6 +128,7 @@
1098 {
1099 Directory.CreateDirectory(_baseOutputDirectory.FullName);
1100 }
1101+ return config;
1102 }
1103
1104
1105@@ -136,7 +140,7 @@
1106 return assemblyTest;
1107 }
1108
1109- private Test TryGetTypeTest(ITypeInfo type, Test assemblyTest)
1110+ private Test TryGetTypeTest(ITypeInfo type, Test assemblyTest, SpecificationConfig specConfig)
1111 {
1112 Test typeTest;
1113 if (!typeTests.TryGetValue(type, out typeTest))
1114@@ -147,7 +151,7 @@
1115 {
1116 if (attribute is ConcordionTestAttribute)
1117 {
1118- typeTest = CreateTypeTest(new ConcordionTypeInfoAdapter(type));
1119+ typeTest = CreateTypeTest(new ConcordionTypeInfoAdapter(type),specConfig);
1120 break;
1121 }
1122 }
1123@@ -166,12 +170,12 @@
1124 return typeTest;
1125 }
1126
1127- private ConcordionTest CreateTypeTest(ConcordionTypeInfoAdapter typeInfo)
1128+ private ConcordionTest CreateTypeTest(ConcordionTypeInfoAdapter typeInfo, SpecificationConfig specConfig)
1129 {
1130 var fixtureType = CreateFixtureType(typeInfo.Target);
1131- var resource = CreateResource(ExtrapolateResourcePath(fixtureType));
1132+ var resource = CreateResource(ExtrapolateResourcePath(specConfig.BaseInputDirectory,fixtureType,typeInfo.Target));
1133
1134- var typeTest = new ConcordionTest(typeInfo.Target.Name, typeInfo.Target, typeInfo, resource, fixtureType);
1135+ var typeTest = new ConcordionTest(typeInfo.Target.FullName, typeInfo.Target, typeInfo, resource, fixtureType);
1136 typeTest.Source = new EmbeddedResourceSource(fixtureType.Assembly);
1137 typeTest.Target = new FileTarget(_baseOutputDirectory.FullName);
1138 typeTest.Kind = TestKinds.Fixture;
1139@@ -201,9 +205,22 @@
1140 throw new InvalidOperationException("Cannot create the fixture");
1141 }
1142
1143- private string ExtrapolateResourcePath(Type type)
1144+ private string ExtrapolateResourcePath(string specInputDirectory,Type type, ITypeInfo typeInfo)
1145 {
1146 var typeNamespace = type.Namespace;
1147+ var assemblyName=type.Assembly.GetName().Name;
1148+
1149+ if (specInputDirectory != Directory.GetCurrentDirectory())
1150+ {
1151+ if (!typeNamespace.Contains(assemblyName))
1152+ {
1153+ TestModel.AddAnnotation(new Annotation(AnnotationType.Warning, typeInfo, "The assembly name [" + assemblyName + "] does not appear in the namespace for type [" + type.FullName + "]"));
1154+ }
1155+ else
1156+ {
1157+ typeNamespace = typeNamespace.Replace(assemblyName, assemblyName + "\\" + specInputDirectory);
1158+ }
1159+ }
1160 typeNamespace = typeNamespace.Replace(".", "\\");
1161 var fileName = type.Name;
1162 if (fileName.EndsWith("Test"))

Subscribers

People subscribed via source and target branches