public async Task Document_Upload_Stores_Document() { var repo = Substitute.For <IDocumentRepository>(); DocumentOrchestrator orchestrator = new DocumentOrchestrator(repo); Document document = new Document(); document.Content = TestDocument.Get(TestDocumentType.Pdf); document.Name = "my_document.pdf"; await orchestrator.UploadAsync(document); await repo.Received(1).CreateAsync(document); }
public async Task Document_Upload_200_Response() { Document document = new Document(); document.Content = TestDocument.Get(TestDocumentType.Pdf); document.Name = "my_document.pdf"; DocumentOrchestrator orchestrator = new DocumentOrchestrator(Substitute.For <IDocumentRepository>()); IActionResult result = await orchestrator.UploadAsync(document); var typedResult = result as OkObjectResult; Assert.IsNotNull(typedResult); Assert.AreEqual(200, typedResult.StatusCode); }
public async Task Document_Upload_Rejects_Large_Payload() { var repo = Substitute.For <IDocumentRepository>(); DocumentOrchestrator orchestrator = new DocumentOrchestrator(repo); Document document = new Document(); document.Content = TestDocument.Get(TestDocumentType.LargePdf); document.Name = "my_document.pdf"; IActionResult result = await orchestrator.UploadAsync(document); var typedResult = result as StatusCodeResult; Assert.IsNotNull(typedResult); Assert.AreEqual(413, typedResult.StatusCode); }
public async Task Document_Upload_Rejects_NonPdf() { var repo = Substitute.For <IDocumentRepository>(); DocumentOrchestrator orchestrator = new DocumentOrchestrator(repo); Document document = new Document(); document.Content = TestDocument.Get(TestDocumentType.Word); document.Name = "my_document.docx"; IActionResult result = await orchestrator.UploadAsync(document); var typedResult = result as UnsupportedMediaTypeResult; Assert.IsNotNull(typedResult); Assert.AreEqual(415, typedResult.StatusCode); }