👷♂️
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
Bar.cs | |
+-BarSpecs.cs | |
Foo.cs | |
+- FooSpecs.cs | |
vs. | |
Bar.cs | |
BarSpecs.cs (with common Bar related IBehaviorConfigs) | |
+- when_bar_has_this.cs |
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
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. | |
C:\Users\AZeitler\Desktop\xunitbddextensions>Pause | |
Press any key to continue . . . |
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
// 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>(); |
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
public class LightSwitchedOff : IBehaviorConfig { | |
public void EstablishContext(IDependencyAccessor accessor) { | |
accessor.The<ILight>().WhenToldTo(l => l.LightState).Return(LightState.Off).Repeat.Once(); | |
accessor.The<ILight>().WhenToldTo | |
(l => l.SwitchLight(LightState.On)).Do( | |
new Func<object, LightSwitchedHandlerArgs, int>((sender1, args1) => | |
{ | |
accessor.The<ILight>() |
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) { |
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
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() { |
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
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 = () => { |
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
Establish context = () => { | |
With<SolidWorks2010OleConnected>(); | |
_solidWorks = The<ISolidWorks>(); | |
} | |
public class SolidWorks2010OleConnected { | |
OnEstablish context = | |
fakeAccessor => | |
{ | |
ISldWorks solidWorks = |
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
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 | |
= () => | |
{ | |
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
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 ;-) |
OlderNewer