public void FileProcessor_InvalidContent_ReturnsBadRequest() { fileProcMock.Setup(s => s.StartProcess("testfile")).Returns(new ProcessSummary()); var expected = new BadRequestObjectResult(new object()); var objectUnderTest = new FileProcessorController(loggerMock.Object, fileProcMock.Object, fileManagerMock.Object); var result = objectUnderTest.Post("temp"); Assert.Equal(((BadRequestObjectResult)result).StatusCode, expected.StatusCode); }
public void FileProcessor_AcceptEncodedFileContent_ReturnsOK() { fileProcMock.Setup(s => s.StartProcess(It.IsAny <string>())).Returns(new ProcessSummary()); var expected = new OkObjectResult(new object()); string fileEncContent = System.IO.File.ReadAllText("./Resources/EncryptedSample.json"); var objectUnderTest = new FileProcessorController(loggerMock.Object, fileProcMock.Object, fileManagerMock.Object); var result = objectUnderTest.Post(fileEncContent); Assert.Equal(((OkObjectResult)result).StatusCode, expected.StatusCode); fileProcMock.Verify(s => s.StartProcess(It.IsAny <string>()), Times.Once()); }
public void FileProcessorAPI_MissingFileName_DoesnotPerform_StartProcess() { string fileName = "./Resources/NonExistantFile.json"; fileManagerMock.Setup(s => s.ReadFile(It.IsAny <string>())); fileProcMock.Setup(s => s.StartProcess(It.IsAny <string>())).Returns(new ProcessSummary()); var underTestController = new FileProcessorController(loggerMock.Object, fileProcMock.Object, fileManagerMock.Object); var expected = new BadRequestResult(); var actual = underTestController.Post(fileName); fileProcMock.Verify(s => s.StartProcess(It.IsAny <string>()), Times.Never); }