Created
June 4, 2010 19:31
-
-
Save jmarnold/425844 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
[TestFixture] | |
public class When_Rendering_Entity_Details : InteractionContext<RenderEntityDetailsAction<Vendor, VendorRequestModel, VendorDetailsModel>> | |
{ | |
private VendorRequestModel _requestModel; | |
protected override void BeforeEach() | |
{ | |
_requestModel = new VendorRequestModel {VendorId = 1}; | |
} | |
[Test] | |
public void An_Entity_Not_Found_Exception_Is_Thrown_If_The_Entity_Cannot_Be_Found() | |
{ | |
MockFor<IEntityService>() | |
.Expect(s => s.Get<Vendor>(_requestModel)) | |
.Return(null); | |
Exception<EntityNotFoundException<Vendor>> | |
.ShouldBeThrownBy(() => ClassUnderTest.Get(_requestModel)); | |
} | |
[Test] | |
public void Entity_Is_Mapped_To_Details_Model_When_Found() | |
{ | |
var vendor = Vendor | |
.CreateNew() | |
.WithVendorName("Test Vendor") | |
.WithAccountNumber("1234") | |
.WithVendorCode("TV") | |
.Build(); | |
MockFor<IEntityService>() | |
.Expect(s => s.Get<Vendor>(_requestModel)) | |
.Return(vendor); | |
var detailsModel = new VendorDetailsModel(); | |
MockFor<IMappingRegistry>() | |
.Expect(r => r.Map<Vendor, VendorDetailsModel>(vendor)) | |
.Return(detailsModel); | |
ClassUnderTest.Get(_requestModel).ShouldBeTheSameAs(detailsModel); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment