Exemple #1
0
        public void Should_Throw_If_Source_Directory_Is_Null()
        {
            // Given
            var fixture = new UniversalPackagePackerFixture { Settings = { SourceDirectory = null } };

            // When
            var result = Record.Exception(() => fixture.Run());

            // Then
            ExtraAssert.IsCakeException(result, "Required setting SourceDirectory not specified.");
        }
Exemple #2
0
        public void Should_Throw_If_Metadata_FilePath_Is_Null()
        {
            // Given
            var fixture = new UniversalPackagePackerFixture { Settings = { MetadataFilePath = null } };

            // When
            var result = Record.Exception(() => fixture.Run());

            // Then
            ExtraAssert.IsCakeException(result, "Required setting MetadataFilePath not specified.");
        }
Exemple #3
0
        public void Should_Throw_If_Process_Has_A_Non_Zero_Exit_Code()
        {
            // Given
            var fixture = new UniversalPackagePackerFixture();
            fixture.GivenProcessExitsWithCode(1);

            // When
            var result = Record.Exception(() => fixture.Run());

            // Then
            ExtraAssert.IsCakeException(result, "UPack: Process returned an error (exit code 1).");
        }
Exemple #4
0
        public void Should_Throw_If_UPack_Executable_Was_Not_Found()
        {
            // Given
            var fixture = new UniversalPackagePackerFixture();
            fixture.GivenDefaultToolDoNotExist();

            // When
            var result = Record.Exception(() => fixture.Run());

            // Then
            ExtraAssert.IsCakeException(result, "UPack: Could not locate executable.");
        }
Exemple #5
0
        public void Should_Throw_If_Process_Was_Not_Started()
        {
            // Given
            var fixture = new UniversalPackagePackerFixture();
            fixture.GivenProcessCannotStart();

            // When
            var result = Record.Exception(() => fixture.Run());

            // Then
            ExtraAssert.IsCakeException(result, "UPack: Process was not started.");
        }
        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_Fail_Delete_If_Creds_Are_Invalid(string assetUri)
        {
            using (var server = FluentMockServer.Start())
            {
                server.Given(Request.Create().WithPath(assetUri).UsingDelete())
                .RespondWith(Response.Create().WithStatusCode(HttpStatusCode.Unauthorized));

                var asset  = new ProGetAssetPusher(_log, _config);
                var result = Record.Exception(() => asset.DeleteAsset($"http://localhost:{server.Ports[0]}{assetUri}"));
                ExtraAssert.IsCakeException(result, "Authorization to ProGet server failed; Credentials were incorrect, or not supplied.");
            }
        }
        public void Should_Throw_If_Credentials_Are_Not_Valid()
        {
            // Given
            var fixture = new UniversalPackagePusherFixture {
                Settings = { UserName = "******", Password = "" }
            };

            // When
            var result = Record.Exception(() => fixture.Run());

            // Then
            ExtraAssert.IsCakeException(result, "Both username and password must be specified for authentication");
        }
        public void Should_Throw_If_Target_Is_Null()
        {
            // Given
            var fixture = new UniversalPackagePusherFixture {
                Settings = { Target = null }
            };

            // When
            var result = Record.Exception(() => fixture.Run());

            // Then
            ExtraAssert.IsCakeException(result, "Required setting Target not specified.");
        }
        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.");
            }
        }
        public void Should_Throw_If_Source_Is_Null_Or_Empty(string source)
        {
            // Given
            var fixture = new UniversalPackageInstallerFixture {
                Settings = { Source = source }
            };

            // When
            var result = Record.Exception(() => fixture.Run());

            // Then
            ExtraAssert.IsCakeException(result, "Required setting Source not specified.");
        }
        public void Should_Throw_Exception_When_Asset_Push_Fails_As_Put(string assetUri)
        {
            using (var server = FluentMockServer.Start())
            {
                server.Given(Request.Create().WithPath(assetUri).UsingPut())
                .RespondWith(Response.Create().WithStatusCode(HttpStatusCode.BadRequest));

                var asset    = new ProGetAssetPusher(_log, _config);
                var tempFile = new FilePath($"{Path.GetTempPath()}Should_Throw_Exception_When_Asset_Push_Fails_As_Put.txt");

                if (File.Exists(tempFile.FullPath))
                {
                    File.Delete(tempFile.FullPath);
                }

                using (var fileStream = new FileStream(tempFile.FullPath, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None))
                {
                    fileStream.SetLength(4194304);
                }
                var result = Record.Exception(() => asset.Publish(tempFile, $"http://localhost:{server.Ports[0]}{assetUri}"));

                ExtraAssert.IsCakeException(result, "Upload failed. This request would have overwritten an existing package.");
            }
        }