Skip to content

Instantly share code, notes, and snippets.


Alexander Zeitler AlexZeitler

View GitHub Profile
AlexZeitler / ideas for grouping BDD items using VsCommands
Created Jun 29, 2010
my thoughts on grouping #bdd items using #vscommands - any other ideas?
View ideas for grouping BDD items using VsCommands
+- FooSpecs.cs
BarSpecs.cs (with common Bar related IBehaviorConfigs)
+- when_bar_has_this.cs
View xUnit.BDDExtensions
C:\Users\AZeitler\Desktop\xunitbddextensions>powershell -Command "& {Import-Modu
le .\psake.psm1; Invoke-psake .\default.ps1}"
Executing task: Clean
Executing task: Init
fatal: Not a git repository (or any of the parent directories): .git
default.ps1:You cannot call a method on a null-valued expression.
Press any key to continue . . .
View gist:477556
// Concern
protected override void Because() {
_actualDependencyModel = Sut.Resolve(); // "root" of AssemblyHasTwoPartDependencies / EstablishContext should be passed to Resolve
// Dependency
public class AssemblyHasTwoPartDependencies : IBehaviorConfig {
public void EstablishContext(IDependencyAccessor accessor) {
IConfiguration activeRootConfiguration = accessor.An<IConfiguration>();
View bdd ext + RhinoMocks.Do()
public class LightSwitchedOff : IBehaviorConfig {
public void EstablishContext(IDependencyAccessor accessor) {
accessor.The<ILight>().WhenToldTo(l => l.LightState).Return(LightState.Off).Repeat.Once();
(l => l.SwitchLight(LightState.On)).Do(
new Func<object, LightSwitchedHandlerArgs, int>((sender1, args1) =>
AlexZeitler / gist:798238
Created Jan 27, 2011
BDD Learning Tests mit BehaviorConfigs
View gist:798238
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) {
AlexZeitler / Failing Spec
Created Feb 21, 2011
Why does this always fail?
View Failing Spec
using System;
using SolidWorks.Interop.sldworks;
using Xunit;
namespace SolidTp.SolidWorks.Domain.Tests {
[Concern(typeof (IEquationManagerWriter))]
public class Wenn_eine_variablendefinition_im_modell_aktualisiert_werden_soll_ : InstanceContextSpecification<IEquationManagerWriter> {
private string _variableDefinitionAsEquation;
protected override void EstablishContext() {
AlexZeitler / gist:917497
Created Apr 13, 2011
Configuring the The<>() directly
View gist:917497
Running the tests results in "System.InvalidOperationException:
The result for IContactRepository.Get(1); has already been setup."
When creating An<IContactRepository> and assigning it by fakeAccessor.Use(), it does work.
public class When_requesting_alex_from_contact_service : WithSubject<ContactService> {
static Contact _contact;
static IContact _actualContact;
Establish context = () => {
AlexZeitler / gist:923466
Created Apr 16, 2011
mfakes, StructureMap and COM...
View gist:923466
Establish context = () => {
_solidWorks = The<ISolidWorks>();
public class SolidWorks2010OleConnected {
OnEstablish context =
fakeAccessor =>
ISldWorks solidWorks =
AlexZeitler / gist:925015
Created Apr 18, 2011
SolidWorks and StructureMap RhinoAutoMocker
View gist:925015
public class When_putting_a_real_solidworks_instance_into_a_mock {
static ISldWorks _solidWorks;
static IModelDoc2 _model;
static Exception _exception;
static RhinoAutoMocker<ModelReader> _mocks;
Establish context
= () =>
AlexZeitler / gist:926928
Created Apr 19, 2011
Passing params into BehaviorConfigs by With<T> in Machine.Fakes
View gist:926928
How about having
Establish context = () => With<CurrentTime>().UsingParams(new DateTime(2011,2,14));
instead of
Establish context = () => With(new CurrentTime(new DateTime(2011, 2, 14)));
I think it would enable a more consistent manner of reading when using more than one behavior config.
Might be nitpicking, though ;-)
You can’t perform that action at this time.