public void BuildTest_Symbol() { Mock <IProject> mockProject = new Mock <IProject>(MockBehavior.Strict); IProject project = mockProject.Object; int number = 0; StepType type = StepType.SymbolTable; string inputFile = @"C:\Users\Test\Project\input.asm"; string outputFile = @"C:\Users\Test\Project\output.bin"; mockProject.Setup(p => p.ProjectOutputs.Add(outputFile)).Verifiable(); mockProject.Setup(p => p.LabelOutputs.Add(Path.ChangeExtension(outputFile, ".lab"))).Verifiable(); Mock <IAssemblerService> mockAssemblerService = new Mock <IAssemblerService>(MockBehavior.Strict); mockAssemblerService.Setup(a => a.AssembleFile(new FilePath(inputFile), new FilePath(outputFile), null, AssemblyFlags.Assemble | AssemblyFlags.Label, null)) .Returns(true) .Verifiable(); mockProject.Setup(p => p.AssemblerService).Returns(mockAssemblerService.Object).Verifiable(); InternalBuildStep target = new InternalBuildStep(project, number, type, inputFile, outputFile); bool expected = true; bool actual; actual = target.Build(); Assert.AreEqual(expected, actual); mockProject.Verify(); mockAssemblerService.Verify(); }
private void outputBox_TextChanged(object sender, EventArgs e) { InternalBuildStep step = (InternalBuildStep)buildSeqList.SelectedItem; FilePath newPath = new FilePath(outputBox.Text); step.OutputFile = _project.ProjectDirectory.Combine(newPath).NormalizePath(); _needsSave = true; }
private void addDirButton_Click(object sender, EventArgs e) { int count = buildSeqList.Items.Count; FilePath fileName = new FilePath(_project.ProjectName + ".asm"); IBuildStep stepToAdd = new InternalBuildStep(count, BuildStepType.Assemble, fileName, fileName.ChangeExtension("8xk")); _currentConfig.AddStep(stepToAdd); buildSeqList.Items.Insert(count, stepToAdd); _needsSave = true; }
private void actionBox_SelectedIndexChanged(object sender, EventArgs e) { InternalBuildStep step = (InternalBuildStep)buildSeqList.SelectedItem; _currentConfig.RemoveStep(step); step.StepType = (BuildStepType)actionBox.SelectedIndex; buildSeqList.Items[buildSeqList.SelectedIndex] = step; _currentConfig.AddStep(step); UpdateStepOptions(); _needsSave = true; }
public void InternalBuildStepConstructorTest() { IProject project = null; int number = 0; StepType type = StepType.All; string inputFile = @"C:\Users\Test\Project\input.asm"; string outputFile = @"C:\Users\Test\Project\output.bin"; InternalBuildStep target = new InternalBuildStep(project, number, type, inputFile, outputFile); Assert.AreEqual(inputFile, target.InputFile); Assert.AreEqual(outputFile, target.OutputFile); Assert.AreEqual(type, target.StepType); Assert.AreEqual(number, target.StepNumber); }
public void InternalBuildStep_Equals_NotEqual2() { IProject project = null; int number = 0; StepType type = StepType.All; string inputFile = @"C:\Users\Test\Project\input.asm"; string outputFile = @"C:\Users\Test\Project\output.bin"; InternalBuildStep target = new InternalBuildStep(project, number, type, inputFile, outputFile); InternalBuildStep target2 = new InternalBuildStep(project, number + 1, type, inputFile, outputFile); bool expected = false; bool actual = target.Equals(target2); Assert.AreEqual(expected, actual); }
public void InternalBuildStep_GetHashCode_NullProject() { IProject project = null; int number = 0; StepType type = StepType.All; string inputFile = @"C:\Users\Test\Project\input.asm"; string outputFile = @"C:\Users\Test\Project\output.bin"; InternalBuildStep target = new InternalBuildStep(project, number, type, inputFile, outputFile); InternalBuildStep target2 = new InternalBuildStep(project, number, type, inputFile, outputFile); bool expected = true; bool actual = target.GetHashCode() == target2.GetHashCode(); Assert.AreEqual(expected, actual); }
public void DescriptionTest_SymbolTable() { IProject project = null; int number = 0; StepType type = StepType.SymbolTable; string inputFile = @"C:\Users\Test\Project\input.asm"; string outputFile = @"C:\Users\Test\Project\output.bin"; InternalBuildStep target = new InternalBuildStep(project, number, type, inputFile, outputFile); string expected = "Symbolize " + System.IO.Path.GetFileName(inputFile); string actual; actual = target.ToString(); Assert.AreEqual(expected, actual); }
public void ToStringTest() { IProject project = null; int number = 0; StepType type = StepType.All; string inputFile = @"C:\Users\Test\Project\input.asm"; string outputFile = @"C:\Users\Test\Project\output.bin"; InternalBuildStep target = new InternalBuildStep(project, number, type, inputFile, outputFile); string expected = "Assemble and list " + System.IO.Path.GetFileName(inputFile); string actual; actual = target.ToString(); Assert.AreEqual(expected, actual); }
public void CloneTest() { IProject project = null; int number = 0; StepType type = StepType.All; string inputFile = @"C:\Users\Test\Project\input.asm"; string outputFile = @"C:\Users\Test\Project\output.bin"; InternalBuildStep target = new InternalBuildStep(project, number, type, inputFile, outputFile); object expected = target; object actual; actual = target.Clone(); Assert.AreEqual(expected, actual); }
private void UpdateStepOptions() { if (buildSeqList.SelectedIndex == -1) { stepOptionsBox.Enabled = false; return; } stepOptionsBox.Enabled = true; if (buildSeqList.SelectedItem is InternalBuildStep) { stepTypeBox.SelectedIndex = 0; } else if (buildSeqList.SelectedItem is ExternalBuildStep) { stepTypeBox.SelectedIndex = 1; } IBuildStep step = (IBuildStep)buildSeqList.SelectedItem; switch (stepTypeBox.SelectedIndex) { case 0: InternalBuildStep intStep = (InternalBuildStep)step; inputLabel.Text = "Input File:"; outputLabel.Enabled = true; outputBox.Enabled = true; actionBox.Visible = true; actionLabel.Visible = true; inputBox.Text = intStep.InputFile; outputBox.Text = intStep.OutputFile; actionBox.SelectedIndex = (int)intStep.StepType; break; case 1: inputLabel.Text = "Command:"; outputLabel.Enabled = false; outputBox.Enabled = false; actionBox.Visible = false; actionLabel.Visible = false; inputBox.Text = step.InputFile; break; } }
public void InternalBuildStep_GetHashCode() { Mock <IProject> mockProject = new Mock <IProject>(MockBehavior.Strict); IProject project = mockProject.Object; int number = 0; StepType type = StepType.All; string inputFile = @"C:\Users\Test\Project\input.asm"; string outputFile = @"C:\Users\Test\Project\output.bin"; InternalBuildStep target = new InternalBuildStep(project, number, type, inputFile, outputFile); InternalBuildStep target2 = new InternalBuildStep(project, number, type, inputFile, outputFile); bool expected = true; bool actual = target.GetHashCode() == target2.GetHashCode(); Assert.AreEqual(expected, actual); mockProject.Verify(); }
public void OutputFileRelativeTest() { Mock <IProject> mockProject = new Mock <IProject>(MockBehavior.Strict); mockProject.Setup(p => p.ProjectDirectory).Returns(@"C:\Users\Test\"); IProject project = mockProject.Object; int number = 0; StepType type = StepType.All; string inputFile = @"C:\Users\Test\Project\input.asm"; string outputFile = @"C:\Users\Test\Project\New Folder\output.bin"; InternalBuildStep target = new InternalBuildStep(project, number, type, inputFile, outputFile); string expected = @"..\..\output.bin"; string actual = target.OutputFileRelative; Assert.AreEqual(expected, actual); mockProject.Verify(); }
private void stepTypeBox_SelectedIndexChanged(object sender, EventArgs e) { IBuildStep step = null; _currentConfig.RemoveStep((IBuildStep)buildSeqList.SelectedItem); int stepNum = ((IBuildStep)buildSeqList.SelectedItem).StepNumber; if (buildSeqList.SelectedItem is InternalBuildStep && stepTypeBox.SelectedIndex != 0) { step = new ExternalBuildStep(buildSeqList.SelectedIndex, new FilePath("cmd.exe"), string.Empty) { StepNumber = stepNum }; } else if (buildSeqList.SelectedItem is ExternalBuildStep && stepTypeBox.SelectedIndex != 1) { step = new InternalBuildStep( buildSeqList.SelectedIndex, BuildStepType.Assemble, _project.ProjectFile.ChangeExtension(".asm"), _project.ProjectFile.ChangeExtension(".8xk")) { StepNumber = stepNum }; } if (step == null) { return; } _currentConfig.AddStep(step); buildSeqList.Items[buildSeqList.SelectedIndex] = step; UpdateStepOptions(); _needsSave = true; }