Created
January 27, 2011 08:29
-
-
Save AlexZeitler/798238 to your computer and use it in GitHub Desktop.
BDD Learning Tests mit BehaviorConfigs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ich habe ein COM Interop Szenario. Um das Verhalten des API kennen zu lernen, habe ich Learning Tests / Specs geschrieben, die aber eine OLE-Verbindung zur laufenden App benötigen. | |
Es müssen z.B. Dokumente in der App geladen werden. Da häufig gleiche Dokumente benötigt werden, sollen diese in BehaviorConfigs ausgelagert werden. Da die BehaviorConfigs teilweise voneinander abhängen (schlecht, aber derzeit nicht anders lösbar), muß EstablishContext der jeweiligen BehaviorConfig vor dem Instanzieren der nächsten BehaviorConfig erledigt sein. | |
public class EmptyAssemblyAsActiveDocument : IBehaviorConfig { | |
public void EstablishContext(IDependencyAccessor accessor) { | |
string applicationDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); | |
string tempFolder = Path.Combine(applicationDataFolder, "Temp"); | |
DirectoryInfo directoryInfo = new DirectoryInfo(tempFolder); | |
if (!directoryInfo.Exists) { | |
Directory.CreateDirectory(tempFolder); | |
} | |
string assemblyPath = string.Format("{0}\\test.sldasm", tempFolder); | |
ISldWorks solidWorks = new SolidWorksOleConnector().Connect(new SolidWorksVersion2009()); | |
AssemblyCreator assemblyCreator = | |
new AssemblyCreator(solidWorks); | |
assemblyCreator.CreateEmptyAssembly(assemblyPath); | |
} | |
public void PrepareSut(object sut) { | |
} | |
public void Cleanup(object sut) { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment