public void Should_return_step_matching_parent_and_id() { var unitOfWork = A.Fake <IUnitOfWork>(); A.CallTo(() => unitOfWork.FlowTemplateSteps.Get()).Returns( new List <FlowTemplateStep> { new FlowTemplateStep { Id = 1, Name = "Correct Step 1", FlowTemplateId = 1, StepTypeId = 1 }, new FlowTemplateStep { Id = 2, Name = "Incorrect Step", FlowTemplateId = 2, StepTypeId = 1 }, new FlowTemplateStep { Id = 3, Name = "Correct Step 3", FlowTemplateId = 1, StepTypeId = 2 } }); var sut = new FlowTemplateStepsController(unitOfWork); SetupController(sut, "http://example.com/api/FlowTemplates/1/Steps/2", HttpMethod.Get); var response = sut.Get(1, 3); var task = response.Content.ReadAsAsync <FlowTemplateDto>(); task.Wait(); var result = task.Result; Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal(3, result.Id); }
public void Should_return_404_if_step_does_not_exist() { var unitOfWork = A.Fake <IUnitOfWork>(); A.CallTo(() => unitOfWork.FlowTemplateSteps.Get(A <int> ._)).Returns(null); var sut = new FlowTemplateStepsController(unitOfWork); SetupController(sut, "http://example.com/api/FlowTemplates/1/Steps", HttpMethod.Get); var response = sut.Get(2); Assert.Equal(HttpStatusCode.NotFound, response.StatusCode); Assert.Equal(null, response.Content); }
public void Should_return_404_if_step_does_not_exist_on_parent() { var unitOfWork = A.Fake <IUnitOfWork>(); A.CallTo(() => unitOfWork.FlowTemplateSteps.Get()).Returns( new List <FlowTemplateStep> { new FlowTemplateStep { Id = 1, Name = "Correct Step 1", FlowTemplateId = 1, StepTypeId = 1 }, new FlowTemplateStep { Id = 2, Name = "Incorrect Step", FlowTemplateId = 2, StepTypeId = 1 }, new FlowTemplateStep { Id = 3, Name = "Correct Step 3", FlowTemplateId = 1, StepTypeId = 2 } }); var sut = new FlowTemplateStepsController(unitOfWork); SetupController(sut, "http://example.com/api/FlowTemplates/1/Steps", HttpMethod.Get); var response = sut.Get(3, 3); Assert.Equal(HttpStatusCode.NotFound, response.StatusCode); Assert.Equal(null, response.Content); }