public void GetFile_ShouldReturnNotFound() { var controller = new GoatsController(); controller.Request = new HttpRequestMessage(); controller.Configuration = new HttpConfiguration(); var response = controller.GetFile("no_file.json"); Assert.IsNotNull(response); Assert.AreEqual(response.StatusCode, HttpStatusCode.NotFound); }
public void GetCommand_ShouldReturnDirectoryListing() { var controller = new GoatsController(); controller.Request = new HttpRequestMessage(); controller.Configuration = new HttpConfiguration(); var response = controller.GetCommand("dir"); Assert.IsNotNull(response); Assert.AreEqual(response.StatusCode, HttpStatusCode.OK); string commandOutput; Assert.IsTrue(response.TryGetContentValue <String>(out commandOutput)); Assert.IsTrue(commandOutput.Contains("Directory of ")); }
public void GetFile_ShouldReturnFileContent() { var controller = new GoatsController(); controller.Request = new HttpRequestMessage(); controller.Configuration = new HttpConfiguration(); var response = controller.GetFile("dotnet-api-goat.Tests.dll.config"); Assert.IsNotNull(response); Assert.AreEqual(response.StatusCode, HttpStatusCode.OK); string fileContent; Assert.IsTrue(response.TryGetContentValue <String>(out fileContent)); Assert.IsTrue(fileContent.Contains("configuration")); }
public void GetEcho_ShouldReturnHtml() { var controller = new GoatsController(); controller.Request = new HttpRequestMessage(); controller.Configuration = new HttpConfiguration(); var response = controller.GetEcho("hello"); Assert.IsNotNull(response); Assert.AreEqual(response.StatusCode, HttpStatusCode.OK); string htmlOutput; Assert.IsTrue(response.TryGetContentValue <String>(out htmlOutput)); Assert.IsTrue(htmlOutput.Equals("hello")); }