コード例 #1
0
        public void Put_at_directory_path_throws()
        {
            var data = AwsTestHelpers.CreateRandomDocument();

            try {
                _client.PutFile("foo/bar/", AwsTestHelpers.CreateFileHandle(data, null));
                Assert.Fail("didn't throw");
            } catch (InvalidOperationException) { }
        }
コード例 #2
0
        public void Can_put_file()
        {
            var data = AwsTestHelpers.CreateRandomDocument();

            MockPlug.Setup(AwsTestHelpers.AWS.S3Uri)
            .Verb("PUT")
            .At(_config.RootedPath("foo", "bar"))
            .WithBody(data)
            .Returns(DreamMessage.Ok())
            .ExpectAtLeastOneCall();
            _client.PutFile("foo/bar", AwsTestHelpers.CreateFileHandle(data, null));
            MockPlug.VerifyAll();
        }
コード例 #3
0
        public void Send_cache_control_header_when_writing_object()
        {
            var data = AwsTestHelpers.CreateRandomDocument();

            MockPlug.Setup(AwsTestHelpers.AWS.S3Uri)
            .Verb("PUT")
            .At(_config.RootedPath("foo", "bar"))
            .WithHeader("Cache-Control", "max-age=29030400, public")
            .WithBody(data)
            .Returns(DreamMessage.Ok())
            .ExpectAtLeastOneCall();
            var handle = AwsTestHelpers.CreateFileHandle(data, null);

            handle.CacheControl = "max-age=29030400, public";
            _client.PutFile("foo/bar", handle);
        }
コード例 #4
0
        public void Read_file_with_lazy_expiration_returns_null()
        {
            var data = AwsTestHelpers.CreateRandomDocument();

            MockPlug.Setup(AwsTestHelpers.AWS.S3Uri)
            .Verb("GET")
            .At(_config.RootedPath("foo", "bar"))
            .Returns(invocation => {
                var msg = DreamMessage.Ok(data);
                msg.Headers["x-amz-meta-expire"] = DateTime.UtcNow.Subtract(10.Minutes()).ToEpoch().ToInvariantString();
                msg.Headers["x-amz-meta-ttl"]    = "10";
                return(msg);
            })
            .ExpectAtLeastOneCall();
            Assert.IsNull(_client.GetDataInfo("foo/bar", false));
            MockPlug.VerifyAll();
        }
コード例 #5
0
        public void Can_put_file_with_expiration()
        {
            var data = AwsTestHelpers.CreateRandomDocument();

            MockPlug.Setup(AwsTestHelpers.AWS.S3Uri)
            .Verb("PUT")
            .At(_config.RootedPath("foo", "bar"))
            .WithHeader("x-amz-meta-ttl", 1.ToInvariantString())
            .WithBody(data)
            .Returns(DreamMessage.Ok())
            .ExpectAtLeastOneCall();
            MockPlug.Setup(AwsTestHelpers.AWS.S3Uri)
            .Verb("DELETE")
            .At(_config.RootedPath("foo", "bar"))
            .Returns(new DreamMessage(DreamStatus.NoContent, null))
            .ExpectAtLeastOneCall();
            _client.PutFile("foo/bar", AwsTestHelpers.CreateFileHandle(data, 1.Seconds()));
            MockPlug.VerifyAll(10.Seconds());
        }
コード例 #6
0
        public void Can_read_file()
        {
            var data = AwsTestHelpers.CreateRandomDocument();

            MockPlug.Setup(AwsTestHelpers.AWS.S3Uri)
            .Verb("GET")
            .At(_config.RootedPath("foo", "bar"))
            .Returns(DreamMessage.Ok(data))
            .ExpectAtLeastOneCall();
            var response = _client.GetDataInfo("foo/bar", false);

            MockPlug.VerifyAll();
            Assert.IsFalse(response.IsDirectory);
            var fileinfo = response.AsFileHandle();

            Assert.AreEqual(MimeType.XML.ToString(), fileinfo.MimeType.ToString());
            var data2 = XDocFactory.From(fileinfo.Stream, fileinfo.MimeType);

            Assert.AreEqual(data, data2);
        }