public void TestMethod3()
        {
            // Arrange
            string         rootPath                = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..\\..\\"));
            string         taffFileName            = "PT1 - Test4.taff";
            string         taffFile                = $"{rootPath}TestFiles{Path.DirectorySeparatorChar}{taffFileName}";
            TaskAllocation taskAllocation          = new TaskAllocation();
            Validations    validations             = new Validations();
            int            expectedErrorCode       = 10;
            string         expectedErrorMessage    = "LOCATIONS is invalid";
            string         expectedErrorLinenumber = "15";

            // Act
            taskAllocation.ValidateFile(taffFile, validations);
            ErrorManager errorManager = validations.ErrorValidationManager;
            List <Error> errors       = errorManager.Errors;
            Error        actualError  = new Error();

            foreach (Error error in errors)
            {
                if (error.ErrorCode == expectedErrorCode &&
                    error.Message == expectedErrorMessage &&
                    error.LineNumber == expectedErrorLinenumber)
                {
                    actualError = error;
                    break;
                }
            }

            // Assert
            Assert.AreEqual(expectedErrorCode, actualError.ErrorCode, "The error code is incorrect");
            Assert.AreEqual(expectedErrorMessage, actualError.Message, "The error message is incorrect");
            Assert.AreEqual(expectedErrorLinenumber, actualError.LineNumber, "The error's line number is incorrect");
        }
Пример #2
0
        private void OpenToolStripMenuItemClick(object sender, EventArgs e)
        {
            int errorCount;

            // Reset
            ValdationsController     = new Validations();
            TaskAllocationController = new TaskAllocation();
            ConfigurationController  = new Configuration();

            errorsToolStripMenuItem.Enabled     = false;
            allocationToolStripMenuItem.Enabled = false;
            validateButton.Enabled  = false;
            RenderedMainDisplayText = "";

            DialogResult dialogResult = openFileDialog.ShowDialog();

            if (dialogResult == DialogResult.OK)
            {
                TaffFilename    = openFileDialog.FileName;
                urlTextBox.Text = TaffFilename;

                // Validate task allocation file and configuration file
                ValidTaskAllocation = TaskAllocationController.ValidateFile(TaffFilename, ValdationsController);
                CffFilename         = TaskAllocationController.CffFilename;
                ValidConfiguration  = ConfigurationController.ValidateFile(CffFilename, ValdationsController);
                TaskAllocationController.CalculateAllocationValues(ConfigurationController);
                errorCount = ValdationsController.ErrorValidationManager.Errors.Count;

                if (ValidTaskAllocation && ValidConfiguration)
                {
                    allocationToolStripMenuItem.Enabled = true;
                    validateButton.Enabled = true;
                }
                else
                {
                    TaskAllocationController.AllocationDisplays = AllocationsDisplay.DisplayInvalidAllocations(TaskAllocationController.AllocationDisplays, TaskAllocationController.AllocationInFileCount);
                }

                if (errorCount != 0)
                {
                    RenderedErrorText = ErrorDisplay.DisplayText(ValdationsController.ErrorValidationManager);
                    errorsToolStripMenuItem.Enabled = true;
                }

                // Display a summary of validations and a set of allocations
                RenderedMainDisplayText += ValidationSummaryDisplay.ValidAllocationFile(TaffFilename, ValidTaskAllocation);
                RenderedMainDisplayText += ValidationSummaryDisplay.ValidConfigurationFile(CffFilename, ValidConfiguration);
                RenderedMainDisplayText += AllocationsDisplay.Display(TaskAllocationController.AllocationDisplays, ConfigurationController);

                mainWebBrowser.DocumentText = RenderedMainDisplayText;
            }
        }
Пример #3
0
        public void TestMethod3()
        {
            // Arrange
            string         rootPath              = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..\\..\\"));
            string         taffFileName          = "PT1 - Test4.taff";
            string         taffFile              = $"{rootPath}TestFiles{Path.DirectorySeparatorChar}{taffFileName}";
            TaskAllocation taskAllocation        = new TaskAllocation();
            Validations    validations           = new Validations();
            bool           expectedValidTaffFile = false;
            string         errorMessage          = "the contents of a TAFF file conform to the TAFF format";

            // Act
            bool actualValidTaffFile = taskAllocation.ValidateFile(taffFile, validations);

            // Assert
            Assert.AreEqual(expectedValidTaffFile, actualValidTaffFile, errorMessage);
        }
        // File - Open Event Handler
        private void OpenToolStripMenuItem_Click(object sender, System.EventArgs e)
        {
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                // Reset Data
                ClearData();
                // Validate TAFF & CFF Files. If VALID then ENABLE VALIDATE - ALLOCATIONS
                TaskAllocation taskAllocation = new TaskAllocation(openFileDialog.FileName);
                if (taskAllocation.Validate())
                {
                    allocationsToolStripMenuItem.Enabled = true;
                }
                else
                {
                    allocations.Clear();
                }

                // Print Validation Messages.
                foreach (string message in validationMessages)
                {
                    outputTextBox.Text += message + Environment.NewLine;
                }

                // Print Error Messages.
                outputTextBox.Text += Environment.NewLine;
                foreach (string message in errorMessages)
                {
                    outputTextBox.Text += message + Environment.NewLine;
                }

                // Print Allocations.
                foreach (string allocation in allocations)
                {
                    outputTextBox.Text += allocation + Environment.NewLine;
                }
            }
        }