Example #1
0
        public void ClearAssemblyResult_Always_ClearsResultOnControl()
        {
            // Setup
            var random = new Random(39);

            using (var resultControl = new AssessmentSectionAssemblyResultControl())
            {
                var result = new AssessmentSectionAssemblyResult(random.NextDouble(),
                                                                 random.NextEnumValue <AssessmentSectionAssemblyGroup>());
                resultControl.SetAssemblyResult(result);

                // Precondition
                BorderedLabel groupLabel = GetGroupLabel(resultControl);
                AssertGroupLabel(result.AssemblyGroup, groupLabel);

                BorderedLabel probabilityLabel = GetProbabilityLabel(resultControl);
                AssertProbabilityLabel(result.Probability, probabilityLabel);

                // Call
                resultControl.ClearAssemblyResult();

                // Assert
                Assert.AreEqual("-", groupLabel.Text);
                Assert.AreEqual(Color.White, groupLabel.BackColor);

                Assert.AreEqual("-", probabilityLabel.Text);
            }
        }
Example #2
0
        private static void AssertAssessmentSectionAssemblyResultControl(string expectedGroup, string expectedProbability)
        {
            AssessmentSectionAssemblyResultControl control = GetAssessmentSectionAssemblyResultControl();

            Assert.AreEqual(expectedGroup, GetGroupLabel(control).Text);
            Assert.AreEqual(expectedProbability, GetProbabilityLabel(control).Text);
        }
Example #3
0
        public void SetAssemblyResult_ResultNull_ThrowsArgumentNullException()
        {
            using (var resultControl = new AssessmentSectionAssemblyResultControl())
            {
                // Call
                void Call() => resultControl.SetAssemblyResult(null);

                // Assert
                var exception = Assert.Throws <ArgumentNullException>(Call);
                Assert.AreEqual("result", exception.ParamName);
            }
        }
Example #4
0
        public void SetError_ErrorMessageNull_ThrowsArgumentNullException()
        {
            // Setup
            using (var resultControl = new AssessmentSectionAssemblyResultControl())
            {
                // Call
                TestDelegate test = () => resultControl.SetError(null);

                // Assert
                var exception = Assert.Throws <ArgumentNullException>(test);
                Assert.AreEqual("errorMessage", exception.ParamName);
            }
        }
Example #5
0
        public void Constructor_ExpectedValues()
        {
            // Call
            using (var form = new Form())
                using (var resultControl = new AssessmentSectionAssemblyResultControl())
                {
                    form.Controls.Add(resultControl);
                    form.Show();

                    // Assert
                    Assert.IsInstanceOf <UserControl>(resultControl);
                    Assert.IsTrue(resultControl.AutoSize);

                    TableLayoutPanel panel = GetResultPanel(resultControl);
                    Assert.AreEqual(2, panel.ColumnCount);
                    Assert.AreEqual(2, panel.RowCount);

                    var assemblyGroupDisplayNameLabel = (Label)panel.GetControlFromPosition(0, 0);
                    Assert.AreEqual("Veiligheidsoordeel", assemblyGroupDisplayNameLabel.Text);
                    Assert.IsTrue(assemblyGroupDisplayNameLabel.AutoSize);
                    Assert.AreEqual(DockStyle.Left, assemblyGroupDisplayNameLabel.Dock);
                    Assert.AreEqual(new Padding(5, 0, 5, 0), assemblyGroupDisplayNameLabel.Padding);
                    Assert.AreEqual(new Padding(3), assemblyGroupDisplayNameLabel.Margin);

                    var failureProbabilityDisplayNameLabel = (Label)panel.GetControlFromPosition(0, 1);
                    Assert.AreEqual("Faalkans van het traject [1/jaar]", failureProbabilityDisplayNameLabel.Text);
                    Assert.IsTrue(failureProbabilityDisplayNameLabel.AutoSize);
                    Assert.AreEqual(DockStyle.Left, failureProbabilityDisplayNameLabel.Dock);
                    Assert.AreEqual(new Padding(5, 0, 5, 0), failureProbabilityDisplayNameLabel.Padding);
                    Assert.AreEqual(new Padding(3), failureProbabilityDisplayNameLabel.Margin);

                    var groupLabel = (BorderedLabel)panel.GetControlFromPosition(1, 0);
                    Assert.IsTrue(groupLabel.AutoSize);
                    Assert.AreEqual(DockStyle.Left, groupLabel.Dock);
                    Assert.AreEqual(new Padding(5, 0, 5, 0), groupLabel.Padding);
                    Assert.AreEqual(new Padding(3), groupLabel.Margin);

                    var probabilityLabel = (BorderedLabel)panel.GetControlFromPosition(1, 1);
                    Assert.IsTrue(probabilityLabel.AutoSize);
                    Assert.AreEqual(DockStyle.Left, probabilityLabel.Dock);
                    Assert.AreEqual(new Padding(5, 0, 5, 0), probabilityLabel.Padding);
                    Assert.AreEqual(new Padding(3), probabilityLabel.Margin);

                    ErrorProvider errorProvider = GetErrorProvider(resultControl);
                    TestHelper.AssertImagesAreEqual(RiskeerCommonFormsResources.ErrorIcon.ToBitmap(), errorProvider.Icon.ToBitmap());
                    Assert.AreEqual(ErrorBlinkStyle.NeverBlink, errorProvider.BlinkStyle);

                    Assert.IsEmpty(errorProvider.GetError(groupLabel));
                    Assert.IsEmpty(errorProvider.GetError(probabilityLabel));
                }
        }
Example #6
0
        public void SetError_WithErrorMessage_SetsErrorMessageOnControl(string errorMessage)
        {
            // Setup
            using (var resultControl = new AssessmentSectionAssemblyResultControl())
            {
                // Call
                resultControl.SetError(errorMessage);

                // Assert
                ErrorProvider errorProvider = GetErrorProvider(resultControl);

                BorderedLabel groupLabel = GetGroupLabel(resultControl);
                Assert.AreEqual(errorMessage, errorProvider.GetError(groupLabel));

                BorderedLabel probabilityLabel = GetProbabilityLabel(resultControl);
                Assert.AreEqual(errorMessage, errorProvider.GetError(probabilityLabel));
            }
        }
Example #7
0
        public void SetAssemblyResult_WithResult_SetsValues()
        {
            // Setup
            var random = new Random(39);
            var result = new AssessmentSectionAssemblyResult(random.NextDouble(),
                                                             random.NextEnumValue <AssessmentSectionAssemblyGroup>());

            using (var resultControl = new AssessmentSectionAssemblyResultControl())
            {
                // Call
                resultControl.SetAssemblyResult(result);

                // Assert
                BorderedLabel groupLabel = GetGroupLabel(resultControl);
                AssertGroupLabel(result.AssemblyGroup, groupLabel);

                BorderedLabel probabilityLabel = GetProbabilityLabel(resultControl);
                AssertProbabilityLabel(result.Probability, probabilityLabel);
            }
        }
Example #8
0
        public void GivenControlWithErrors_WhenErrorsCleared_ThenErrorsCleared()
        {
            // Given
            using (var resultControl = new AssessmentSectionAssemblyResultControl())
            {
                resultControl.SetError("Error");

                // Precondition
                ErrorProvider errorProvider = GetErrorProvider(resultControl);

                BorderedLabel groupLabel = GetGroupLabel(resultControl);
                Assert.IsNotEmpty(errorProvider.GetError(groupLabel));

                BorderedLabel probabilityLabel = GetProbabilityLabel(resultControl);
                Assert.IsNotEmpty(errorProvider.GetError(probabilityLabel));

                // When
                resultControl.ClearErrors();

                // Then
                Assert.IsEmpty(errorProvider.GetError(groupLabel));
                Assert.IsEmpty(errorProvider.GetError(probabilityLabel));
            }
        }
Example #9
0
 private static ErrorProvider GetErrorProvider(AssessmentSectionAssemblyResultControl resultControl)
 {
     return(TypeUtils.GetField <ErrorProvider>(resultControl, "errorProvider"));
 }
Example #10
0
 private static TableLayoutPanel GetResultPanel(AssessmentSectionAssemblyResultControl resultControl)
 {
     return((TableLayoutPanel)resultControl.Controls["resultLayoutPanel"]);
 }
Example #11
0
 private static BorderedLabel GetProbabilityLabel(AssessmentSectionAssemblyResultControl resultControl)
 {
     return((BorderedLabel)(GetResultPanel(resultControl)).GetControlFromPosition(1, 1));
 }
Example #12
0
        private static string GetGroupError(AssessmentSectionAssemblyResultControl resultControl)
        {
            ErrorProvider errorProvider = GetErrorProvider(resultControl);

            return(errorProvider.GetError(GetGroupLabel(resultControl)));
        }
Example #13
0
 private static BorderedLabel GetGroupLabel(AssessmentSectionAssemblyResultControl resultControl)
 {
     return((BorderedLabel)GetResultPanel(resultControl).GetControlFromPosition(1, 0));
 }