public void Equals_FailedInequalToSuccess() { var x = EValidation.Failure(new ArgumentException()); var y = EValidation.Success; Assert.That(x.Equals(y), Is.False); }
public Hotel() { InitializeComponent(); validateionState = EValidation.INVALID; TBLand.ItemsSource = Infrastructure.Land.Lesen_Alle(); TBLand.DisplayMemberPath = "Name"; TBLand.SelectedValuePath = "LandID"; }
public void ConvertToEOption_Failure() { var exception = new ArgumentNullException(); var validation = EValidation.Failure(exception); var option = validation.ToEOption(); Assert.That(option.IsFailure, Is.True); Assert.That(option.FailureOrThrow(), Is.EqualTo(exception)); }
public void Equals_FailureEqual() { var e = new ArgumentException(); var x = EValidation.Failure(e); var y = EValidation.Failure(e); Assert.That(x.Equals(y), Is.True); }
/// <summary>Return a string description of this validation result</summary> public static string ToErrorDescription(this EValidation val) { var sb = new StringBuilder(); if (val.HasFlag(EValidation.AmountInOutOfRange)) { sb.AppendLine("The amount of currency being sold is not within the valid range."); val ^= EValidation.AmountInOutOfRange; } if (val.HasFlag(EValidation.AmountOutOutOfRange)) { sb.AppendLine("The amount of currency being bought is not within the valid range."); val ^= EValidation.AmountOutOutOfRange; } if (val.HasFlag(EValidation.PriceOutOfRange)) { sb.AppendLine("The price level to trade at is not within the valid range."); val ^= EValidation.PriceOutOfRange; } if (val.HasFlag(EValidation.InsufficientBalance)) { sb.AppendLine("There is insufficient balance."); val ^= EValidation.InsufficientBalance; } if (val.HasFlag(EValidation.PriceIsInvalid)) { sb.AppendLine("The price level to trade at is invalid."); val ^= EValidation.PriceIsInvalid; } if (val.HasFlag(EValidation.AmountInIsInvalid)) { sb.AppendLine("The amount of currency being sold is invalid."); val ^= EValidation.AmountInIsInvalid; } if (val.HasFlag(EValidation.AmountOutIsInvalid)) { sb.AppendLine("The amount of currency being bought is invalid."); val ^= EValidation.AmountOutIsInvalid; } if (val.HasFlag(EValidation.InvalidOrderType)) { sb.AppendLine("The order type is not valid for the given price relative to the spot price."); val ^= EValidation.InvalidOrderType; } if (val.HasFlag(EValidation.Inconsistent)) { sb.AppendLine("The trade amounts are inconsistent with the price."); val ^= EValidation.Inconsistent; } if (val != 0) { throw new Exception("Unknown validation flags"); } return(sb.ToString()); }
public void Equals_FailureInequal() { var e1 = new ArgumentException(); var e2 = new ArgumentException(); var x = EValidation.Failure(e1); var y = EValidation.Failure(e2); Assert.That(x.Equals(y), Is.False); }
/// <summary> /// Add a list of components depending on their validation type. /// </summary> /// <param name="eValidation">Validation for the device</param> protected override void AddComponent(EValidation eValidation) { if (eValidation == EValidation.Finger) { base.Components = CoreSystem.ComponentsPnlFinger; } else { base.Components = CoreSystem.ComponentsPnlRFID; } }
public void Equals_Validation_DifferentType() { var aEValid = EValidation.Success; var aValid = Validation <string> .Success; var exception = new ArgumentException(); var bEValid = EValidation.Failure(exception); var bValid = Validation <string> .Failure("whatever"); Assert.That(aEValid, Is.Not.EqualTo(aValid)); Assert.That(bValid, Is.Not.EqualTo(bEValid)); Assert.That(aValid, Is.Not.EqualTo(aEValid)); Assert.That(bValid, Is.Not.EqualTo(bEValid)); Assert.That(aEValid, Is.Not.EqualTo(bValid)); //sanity-check }
private void areFieldsValid() { if (RegexLib.RegexMatcher(RegexLib.IsNameValid, TBName.Text, TBName) && RegexLib.RegexMatcher(RegexLib.IsLocationValid, TBOrt.Text, TBOrt) && RegexLib.RegexMatcher(RegexLib.AreStarsValid, TBSterne.Text, TBSterne) && RegexLib.RegexMatcher(RegexLib.IsManageValid, TBManager.Text, TBManager) && RegexLib.RegexMatcher(RegexLib.IsCountOfRoomsValid, TBAnzahlZimmer.Text, TBAnzahlZimmer) && RegexLib.RegexMatcher(RegexLib.IsDailyPriceValid, TBTagespreis.Text, TBTagespreis) && RegexLib.RegexMatcher(RegexLib.IsTelephonenumberValid, TBTelefon.Text, TBTelefon) && RegexLib.RegexMatcher(RegexLib.IsURLValid, TBWeb.Text, TBWeb)) { validateionState = EValidation.VALID; } else { validateionState = EValidation.INVALID; } }
public void Equals_Validation() { var aEValid = EValidation.Success; var aValid = Validation <Exception> .Success; var exception = new ArgumentException(); var bEValid = EValidation.Failure(exception); var bValid = Validation <Exception> .Failure(exception); Assert.That(aEValid.GetHashCode(), Is.EqualTo(aValid.GetHashCode()), "HashCode not correct (Success-Case)"); Assert.That(bEValid.GetHashCode(), Is.EqualTo(bValid.GetHashCode()), "HashCode not correct (Failure-Case)"); Assert.That(aEValid, Is.EqualTo(aValid), "EValidation-Equals is buggy! (Success-Case)"); Assert.That(bValid, Is.EqualTo(bEValid), "EValidation-Equals is buggy! (Failure-Case)"); Assert.That(aValid, Is.EqualTo(aEValid), "Implementation of Validation is not accepting EValidation! (Success-Case)"); Assert.That(bValid, Is.EqualTo(bEValid), "Implementation of Validation is not accepting EValidation! (Failure-Case)"); Assert.That(aEValid, Is.Not.EqualTo(bValid)); //sanity-check }
/// <summary> /// AccessPanel builder. /// </summary> /// <param name="serialNumber">Serial Number</param> /// <param name="codeInternal">Code internal for the device</param> /// <param name="typeDevice">Type for the device</param> /// <param name="eValidation">Validation for the device</param> public AccessPanel(double serialNumber, ECode codeInternal, EType typeDevice, EValidation eValidation) : base(serialNumber, codeInternal, typeDevice, eValidation) { AddComponent(eValidation); }
/// <summary> /// AccessPanel builder. /// </summary> /// <param name="codeInternal">Code internal for the device</param> /// <param name="typeDevice">Type for the device</param> /// <param name="eValidation">Validation for the device</param> public AccessPanel(ECode codeInternal, EType typeDevice, EValidation eValidation) : base(codeInternal, typeDevice, eValidation) { AddComponent(eValidation); }
/// <summary> /// AccessPanel builder. /// </summary> /// <param name="codeInternal">Code internal for the device</param> /// <param name="typeDevice">Type for the device</param> /// <param name="numberAccess">Number the access for device</param> /// <param name="eValidation">Validation for the device</param> public AccessPanel(ECode codeInternal, EType typeDevice, int numberAccess, EValidation eValidation) : base(codeInternal, typeDevice, eValidation) { NumberAccess = numberAccess; AddComponent(eValidation); }
/// <summary> /// Attendance builder. /// </summary> /// <param name="codeInternal">Code internal for the device</param> /// <param name="typeDevice">Type for the device</param> /// <param name="eValidation">Validation for the device</param> public Attendance(ECode codeInternal, EType typeDevice, EValidation eValidation) : base(codeInternal, typeDevice, eValidation) { AddComponent(eValidation); }
public void Error_ReturnsFailure() { var exception = new ArgumentNullException(); Assert.That(EValidation.Failure(exception).FailureOrThrow(), Is.EqualTo(exception)); }
public void ConstructFailure_ErrorNull() { Assert.That(() => EValidation.Failure(null), Throws.TypeOf <ValidationFailureConstructionException>()); }
public void ConstructFailure_WrappingErrorGiven() { var testValue = EValidation.Wrapping <Exception>(() => new ArgumentException()); Assert.That(testValue.IsSuccess, Is.True); }
public void ConstructFailure_ErrorNotNull() { var testValue = EValidation.Failure(new ArgumentException()); Assert.That(testValue.IsSuccess, Is.False); }