public async Task Document_Get_Returns_Result() { var repo = Substitute.For <IDocumentRepository>(); Guid expectedGuid = Guid.NewGuid(); byte[] expectedContent = new byte[] { 0x1 }; string expectedLocation = "location"; string expectedName = "name"; int expectedOrder = 1; repo.GetAsync(Arg.Any <Guid>()).Returns(new Document() { Id = expectedGuid, Content = expectedContent, Location = expectedLocation, Name = expectedName, Order = expectedOrder }); DocumentOrchestrator orchestrator = new DocumentOrchestrator(repo); IActionResult result = await orchestrator.GetAsync(expectedGuid.ToString()); var typedResult = result as OkObjectResult; var value = typedResult.Value as Document; Assert.IsNotNull(typedResult); Assert.AreEqual(200, typedResult.StatusCode); Assert.AreEqual(value.Id, expectedGuid); Assert.AreEqual(value.Content, expectedContent); Assert.AreEqual(value.Location, expectedLocation); Assert.AreEqual(value.Name, expectedName); Assert.AreEqual(value.Order, expectedOrder); }
public async Task Document_Get_Returns_Bad_Request() { DocumentOrchestrator orchestrator = new DocumentOrchestrator(Substitute.For <IDocumentRepository>()); IActionResult result = await orchestrator.GetAsync("invalid-guid"); var typedResult = result as BadRequestResult; Assert.IsNotNull(typedResult); Assert.AreEqual(400, typedResult.StatusCode); }
public async Task Document_Get_Returns_Not_Found() { var repo = Substitute.For <IDocumentRepository>(); repo.GetAsync(Arg.Any <Guid>()).Returns((Document)null); DocumentOrchestrator orchestrator = new DocumentOrchestrator(repo); IActionResult result = await orchestrator.GetAsync(Guid.NewGuid().ToString()); var typedResult = result as NotFoundResult; Assert.IsNotNull(typedResult); Assert.AreEqual(404, typedResult.StatusCode); }