Ejemplo n.º 1
0
        public void Should_Throw_If_Asset_Not_Found(string assetUri)
        {
            _server.Stub(x => x.Get(assetUri))
            .NotFound();

            var asset  = new ProGetAssetDownloader(_config);
            var result = Record.Exception(() => asset.GetSingleAsset($"{Host}{assetUri}", new FilePath(Path.GetTempPath())));

            Assert.IsCakeException(result, "The asset was not found.");
        }
Ejemplo n.º 2
0
        public void Should_Throw_If_Unauthorized(string assetUri)
        {
            _server.Stub(x => x.Get(assetUri))
            .WithStatus(HttpStatusCode.Unauthorized);

            var asset  = new ProGetAssetDownloader(_config);
            var result = Record.Exception(() =>
                                          asset.GetSingleAsset($"{Host}{assetUri}", new FilePath(Path.GetTempPath())));

            Assert.IsCakeException(result, "Authorization to ProGet server failed; Credentials were incorrect, or not supplied.");
        }
        public void Should_Throw_If_Asset_Not_Found(string assetUri)
        {
            using (var server = FluentMockServer.Start())
            {
                server.Given(Request.Create().WithPath(assetUri).UsingGet())
                .RespondWith(Response.Create().WithStatusCode(HttpStatusCode.NotFound));

                var asset  = new ProGetAssetDownloader(_config);
                var result = Record.Exception(() => asset.GetSingleAsset($"http://localhost:{server.Ports[0]}{assetUri}", new FilePath(Path.GetTempPath())));
                ExtraAssert.IsCakeException(result, "The asset was not found.");
            }
        }
        public void Should_Throw_If_Unauthorized(string assetUri)
        {
            using (var server = FluentMockServer.Start())
            {
                server.Given(Request.Create().WithPath(assetUri).UsingGet())
                .RespondWith(Response.Create().WithStatusCode(HttpStatusCode.Unauthorized));

                var asset  = new ProGetAssetDownloader(_config);
                var result = Record.Exception(() =>
                                              asset.GetSingleAsset($"http://localhost:{server.Ports[0]}{assetUri}", new FilePath(Path.GetTempPath())));
                ExtraAssert.IsCakeException(result, "Authorization to ProGet server failed; Credentials were incorrect, or not supplied.");
            }
        }
Ejemplo n.º 5
0
        public void Should_Download_Asset(string assetUri)
        {
            var tempFile = Path.GetTempFileName();

            _server.Stub(x => x.Get(assetUri))
            .ReturnFile(tempFile)
            .OK();

            var asset      = new ProGetAssetDownloader(_config);
            var outputPath = Path.GetRandomFileName();

            asset.GetSingleAsset($"{Host}{assetUri}", outputPath);
            Assert.True(File.Exists(outputPath));
            File.Delete(outputPath);
        }
        public void Should_Download_Asset(string assetUri)
        {
            using (var server = FluentMockServer.Start())
            {
                var tempFile = Path.GetTempFileName();

                server.Given(Request.Create().WithPath(assetUri).UsingGet())
                .RespondWith(Response.Create().WithStatusCode(HttpStatusCode.OK).WithBodyFromFile(tempFile));

                var asset      = new ProGetAssetDownloader(_config);
                var outputPath = Path.GetRandomFileName();
                asset.GetSingleAsset($"http://localhost:{server.Ports[0]}{assetUri}", outputPath);
                Assert.True(File.Exists(outputPath));
                File.Delete(outputPath);
            }
        }