예제 #1
0
        public void ItCanPatch()
        {
            Environment.SetEnvironmentVariable("directory", Constants.ValidDirectoryPath);
            const string filePath = Constants.ValidDirectoryPath + Constants.FileName;
            var hash = EncryptionTools.GetSha1(filePath);

            var request = new MockRequest()
            {
                Resource = Constants.FileName,
                Headers = new Dictionary<string, string>
                {
                    {Headers.IfMatch, hash}
                },
                Body = "PATCHED TEXT"
            };
            var response = new PatchResponse().Construct(request);
            response.StatusCode.ShouldEqual(204);
            response.Headers.Keys.ShouldContain("Content-Location");
            response.Headers.Keys.ShouldContain("ETag");
            File.ReadAllText(filePath).ShouldEqual("PATCHED TEXT");
            hash = EncryptionTools.GetSha1(filePath);
            response.Headers["ETag"].ShouldEqual(hash);
            response.Headers["Content-Location"].ShouldEqual(Constants.FileName);
            File.WriteAllText(filePath, "TEST FILE");
        }
예제 #2
0
 public void ItAppendsAllOptionsToAllowHeader()
 {
     var request = new MockRequest();
     var response = new OptionsResponse().Construct(request);
     response.StatusCode.ShouldEqual(200);
     response.Headers.Keys.ShouldContain(Headers.Allow);
     response.Headers[Headers.Allow].ShouldEqual("GET,HEAD,POST,OPTIONS,PUT");
 }
예제 #3
0
 public void CanEditEditableFiles()
 {
     Environment.SetEnvironmentVariable("directory", Constants.ValidDirectoryPath);
     var request = new MockRequest
     {
         Resource = "/form",
         Body = "EDITED STUFF"
     };
     var response =new WriterResponse().Construct(request);
     response.StatusCode.ShouldEqual(200);
     File.ReadAllText(Constants.ValidDirectoryPath + request.Resource).ShouldEqual("EDITED STUFF");
     File.Delete(Constants.ValidDirectoryPath + request.Resource);
 }
예제 #4
0
        public void ItCanReturnPartialContent()
        {
            var partialRequest = new MockRequest()
            {
                Resource = Constants.FileName,
                Headers = new Dictionary<string, string>
                {
                    {Headers.Range,"bytes=4-"}
                }
            };

            Environment.SetEnvironmentVariable("directory", Constants.ValidDirectoryPath);
            var response = new FileResponse().Construct(partialRequest);
            response.ToString().ShouldContain(" FIL");
            response.ToString().ShouldNotContain("TEST FIL");
        }