Skip to content

Instantly share code, notes, and snippets.

@kolesnick
Created March 6, 2012 18:54
Show Gist options
  • Save kolesnick/1988168 to your computer and use it in GitHub Desktop.
Save kolesnick/1988168 to your computer and use it in GitHub Desktop.
ReSharper template for MSpec+Moq test of proxy method with no args which returns data got from different entity
/*
Please remove this comment only after placing this template to ReSharper template editor.
Existance of this comment during paste will automatically align macroses in shown order.
Macroses:
$Proxy$ - ProxyName (this one is under test)
$ProxyMethod$ - ProxyMethod
$proxy$ - proxyName
$Result$ - ResultType
$ISubject$ - SubjectName (this one produces data returned by proxy)
$subject$ - subjectName
$subj$ - subjectLambdaVarName
$SubjectMethod$ - SubjectMethod
$subject_in_should_part$ - subject_readable_name
$subjectArgument$ - name of subject argument supplied as dependency to factory method
$ResultInitialization$ - constructor call or mock
*/
[Subject(typeof($Proxy$))]
internal class $ProxyMethod$_when_called : $Proxy$TestsContext
{
Establish context = () =>
{
$subject$Result = $ResultInitialization$;
var $subject$ = Mock.Of<$ISubject$>($subj$
=> $subj$.$SubjectMethod$() == $subject$Result);
$proxy$ = Create$Proxy$($subjectArgument$: $subject$);
};
Because of = () =>
result = $proxy$.$ProxyMethod$();
It should_return_result_provided_by_$subject_in_should_part$ = () =>
result.ShouldEqual($subject$Result);
private static $Result$ result;
private static $Result$ $subject$Result;
private static $Proxy$ $proxy$;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment