public void Pass_Execute_EchoParametersCoverage() { // Setup var xmlDocument = new XmlDocument(); xmlDocument.LoadXml("<root><parent><child>123</child></parent></root>"); var projectParameters = new Dictionary <string, IParameter> { { "Parameter1", CreateParameter("Parameter1", Fakes.RandomString(), false, ParameterSource.Original) }, { "SensitiveOriginalParameterNoValue", CreateParameter("SensitiveOriginalParameterNoValue", null, true, ParameterSource.Original) }, { "Parameter2", CreateParameter("Parameter2", Fakes.RandomString(), false, ParameterSource.Configuration) }, { "SensitiveConfigParameterNoValue", CreateParameter("SensitiveConfigParameterNoValue", null, true, ParameterSource.Configuration) }, { "Parameter3", CreateParameter("Parameter3", Fakes.RandomString(), false, ParameterSource.Manual) } }; _projectMock.Setup(p => p.ProtectionLevel).Returns(ProtectionLevel.DontSaveSensitive); _projectMock.Setup(p => p.Parameters).Returns(projectParameters); _buildArgumentsMock.Setup(ba => ba.ProjectPath).Returns(Path.GetTempFileName()); _buildArgumentsMock.Setup(ba => ba.Parameters).Returns(new ReadOnlyDictionary <string, string>(new Dictionary <string, string>())); _buildArgumentsMock.Setup(ba => ba.Configuration).Returns(Fakes.RandomString()); var project = _projectMock.Object; var buildArguments = _buildArgumentsMock.Object; var logger = _loggerMock.Object; var builder = new Builder.Builder(logger, project); // Execute var exception = Record.Exception(() => builder.Build(buildArguments)); // Assert Assert.Null(exception); }
public void Pass_Execute_EncryptionLevels_Passwords(ProtectionLevel projectProtectionLevel, string buildArgumentsProtectionLevel, bool sendPassword, bool sendNewPassword) { // Setup var password = sendPassword ? Fakes.RandomString() : null; var newPassword = sendNewPassword ? Fakes.RandomString() : null; _projectMock.Setup(p => p.ProtectionLevel).Returns(projectProtectionLevel); _projectMock.Setup(p => p.Parameters).Returns(new Dictionary <string, IParameter>()); _buildArgumentsMock.Setup(ba => ba.ProtectionLevel).Returns(buildArgumentsProtectionLevel); _buildArgumentsMock.Setup(ba => ba.ProjectPath).Returns(Path.GetTempFileName()); _buildArgumentsMock.Setup(ba => ba.Password).Returns(password); _buildArgumentsMock.Setup(ba => ba.NewPassword).Returns(newPassword); _buildArgumentsMock.Setup(ba => ba.Parameters).Returns(new ReadOnlyDictionary <string, string>(new Dictionary <string, string>())); _buildArgumentsMock.Setup(ba => ba.Configuration).Returns(Fakes.RandomString()); var project = _projectMock.Object; var buildArguments = _buildArgumentsMock.Object; var logger = _loggerMock.Object; var builder = new Builder.Builder(logger, project); // Execute var exception = Record.Exception(() => builder.Build(buildArguments)); // Assert Assert.Null(exception); }
public void Fail_Execute_InvalidContentReleaseNotes(string releaseNotes) { // Setup var releaseNotesPath = Path.Combine(_workingFolder, Guid.NewGuid().ToString("N")); File.Create(releaseNotesPath).Close(); if (releaseNotes != null) { File.WriteAllText(releaseNotesPath, releaseNotes); } _projectMock.Setup(p => p.ProtectionLevel).Returns(ProtectionLevel.DontSaveSensitive); _projectMock.Setup(p => p.Parameters).Returns(new Dictionary <string, IParameter>()); _buildArgumentsMock.Setup(ba => ba.ProjectPath).Returns(Path.GetTempFileName()); _buildArgumentsMock.Setup(ba => ba.Parameters).Returns(new ReadOnlyDictionary <string, string>(new Dictionary <string, string>())); _buildArgumentsMock.Setup(ba => ba.Configuration).Returns(Fakes.RandomString()); _buildArgumentsMock.Setup(ba => ba.ReleaseNotes).Returns(releaseNotesPath); var project = _projectMock.Object; var buildArguments = _buildArgumentsMock.Object; var logger = _loggerMock.Object; var builder = new Builder.Builder(logger, project); // Execute var exception = Record.Exception(() => builder.Build(buildArguments)); // Assert Assert.NotNull(exception); Assert.IsType <InvalidReleaseNotesException>(exception); }
internal static void ProjectBuild(IProject project, string outputFolder) { var builder = new Builder.Builder(project, outputFolder); builder.OnProgress += Asd_OnProgress; builder.Build(); }
public void Pass_Execute_BuildArgumentsParametersUpdate() { // Setup var outputParameters = new List <TestBuildParameterUpdateResult>(); var inputParameers = new List <TestBuildParameterUpdateInput>(); var paramsCount = Fakes.RandomInt(20, 100); for (var i = 0; i < paramsCount; i++) { inputParameers.Add(new TestBuildParameterUpdateInput() { Value = Fakes.RandomString(), // to ensure it is unique Name = $"{Guid.NewGuid():N}-{Fakes.RandomString()}" }); } _projectMock.Setup(p => p.ProtectionLevel).Returns(ProtectionLevel.DontSaveSensitive); _projectMock.Setup(p => p.Parameters).Returns(new Dictionary <string, IParameter>()); _projectMock.Setup(p => p.UpdateParameter(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <ParameterSource>())).Callback( (string parameterName, string value, ParameterSource parameterSource) => { outputParameters.Add(new TestBuildParameterUpdateResult { Name = parameterName, Value = value, Source = parameterSource }); }); _buildArgumentsMock.Setup(ba => ba.ProjectPath).Returns(Path.GetTempFileName()); _buildArgumentsMock.Setup(ba => ba.Parameters).Returns(new ReadOnlyDictionary <string, string>(inputParameers.ToDictionary(i => i.Name, i => i.Value))); _buildArgumentsMock.Setup(ba => ba.Configuration).Returns(Fakes.RandomString()); var project = _projectMock.Object; var buildArguments = _buildArgumentsMock.Object; var logger = _loggerMock.Object; var builder = new Builder.Builder(logger, project); // Execute var exception = Record.Exception(() => builder.Build(buildArguments)); // Assert Assert.Null(exception); Assert.True(outputParameters.Count == paramsCount); for (var cnt = 0; cnt < paramsCount; cnt++) { Assert.True( outputParameters[cnt].Value == inputParameers[cnt].Value && outputParameters[cnt].Name == inputParameers[cnt].Name && outputParameters[cnt].Source == ParameterSource.Manual ); } }
public void Fail_Execute_ProjectFileNotFoundException() { // Setup var buildArguments = new BuildArguments(_workingFolder, null, null, null, null, null, Fakes.RandomString(), null, null); var logger = _loggerMock.Object; var project = _projectMock.Object; // Execute var builder = new Builder.Builder(logger, project); var exception = Record.Exception(() => builder.Build(buildArguments)); Assert.NotNull(exception); Assert.IsType <ProjectFileNotFoundException>(exception); }
public void Fail_Execute_NoArgs() { // Setup var project = _projectMock.Object; var logger = _loggerMock.Object; var builder = new Builder.Builder(logger, project); // Execute var exception = Record.Exception(() => builder.Build(null)); // Assert Assert.NotNull(exception); Assert.IsType <ArgumentNullException>(exception); }
public void Fail_Validate_ProtectionLevelPasswordCombination(string protectionLevelString) { // Setup var builder = new Builder.Builder(_loggerMock.Object, _projectMock.Object); _projectMock.Setup(p => p.Parameters).Returns(new Dictionary <string, IParameter>()); var testException = new PasswordRequiredException(protectionLevelString); // Execute var exception = Record.Exception(() => builder.Build(new BuildArguments(Fakes.RandomString(), Fakes.RandomString(), null, protectionLevelString, null, null, Fakes.RandomString(), null, null))); // Assert Assert.NotNull(exception); Assert.IsType <PasswordRequiredException>(exception); Assert.Equal(exception.Message, testException.Message, StringComparer.InvariantCultureIgnoreCase); }
public void Pass_Validate_ProtectionLevelPasswordCombination(string protectionLevelString, bool password, bool newPassword) { // Setup var builder = new Builder.Builder(_loggerMock.Object, _projectMock.Object); _projectMock.Setup(p => p.Parameters).Returns(new Dictionary <string, IParameter>()); // Execute var exception = Record.Exception( () => builder.Build(new BuildArguments(Fakes.RandomString(), Fakes.RandomString(), null, protectionLevelString, password ? Fakes.RandomString() : null, newPassword ? Fakes.RandomString() : null, Fakes.RandomString(), null, null))); // Assert Assert.Null(exception); }
public void Pass_Execute_NullProjectPath() { // Setup var projectPath = Path.Combine(_workingFolder, $"{Fakes.RandomString()}.dtproj"); File.Create(projectPath).Close(); _projectMock.Setup(p => p.Parameters).Returns(() => new Dictionary <string, IParameter>()); var buildArguments = new BuildArguments(_workingFolder, null, null, null, null, null, Fakes.RandomString(), null, null); var logger = _loggerMock.Object; var project = _projectMock.Object; // Execute var builder = new Builder.Builder(logger, project); builder.Build(buildArguments); }
public void Pass_Execute_CustomOutputFolder() { // Setup _projectMock.Setup(p => p.ProtectionLevel).Returns(ProtectionLevel.DontSaveSensitive); _projectMock.Setup(p => p.Parameters).Returns(new Dictionary <string, IParameter>()); _buildArgumentsMock.Setup(ba => ba.ProjectPath).Returns(Path.GetTempFileName()); _buildArgumentsMock.Setup(ba => ba.Parameters).Returns(new ReadOnlyDictionary <string, string>(new Dictionary <string, string>())); _buildArgumentsMock.Setup(ba => ba.Configuration).Returns(Fakes.RandomString()); _buildArgumentsMock.Setup(ba => ba.OutputFolder).Returns(Fakes.RandomString()); var project = _projectMock.Object; var buildArguments = _buildArgumentsMock.Object; var logger = _loggerMock.Object; var builder = new Builder.Builder(logger, project); // Execute var exception = Record.Exception(() => builder.Build(buildArguments)); // Assert Assert.Null(exception); }