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); } }
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)); } }
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)); } }