Skip to content

Instantly share code, notes, and snippets.

@AlexZeitler
Created April 18, 2011 08:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexZeitler/925015 to your computer and use it in GitHub Desktop.
Save AlexZeitler/925015 to your computer and use it in GitHub Desktop.
SolidWorks and StructureMap RhinoAutoMocker
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
= () =>
{
_mocks = new RhinoAutoMocker<ModelReader>();
_mocks.Inject(new SolidWorksOleConnector().Connect(new SolidWorksVersion2010()));
};
Because of
= () => {
_exception = Catch.Exception(()
=> new ModelReader((ISldWorks) _mocks.Container.GetInstance(typeof(ISldWorks))));
};
It should_not_throw_an_exception
= () => { _exception.ShouldBeNull(); };
It should_return_the_active_modeldoc
= () => { _model.ShouldNotBeNull(); };
}
public class ModelReader {
readonly ISldWorks _solidWorks;
public ModelReader(ISldWorks solidWorks) {
_solidWorks = solidWorks;
}
}
@AlexZeitler
Copy link
Author

sorry, missed that due to hurried work ;-)
works like a charme now - thanks again.

@BjRo
Copy link

BjRo commented Apr 18, 2011 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment