public static TOwner BeReadOnly <TData, TControl, TOwner>(this IFieldVerificationProvider <TData, TControl, TOwner> should)
            where TControl : EditableField <TData, TOwner>
            where TOwner : PageObject <TOwner>
        {
            should.CheckNotNull(nameof(should));

            return(should.Component.IsReadOnly.Should.WithSettings(should).BeTrue());
        }
        /// <summary>
        /// Verifies that the checkbox list has the specified value(s) checked.
        /// </summary>
        /// <typeparam name="TData">The type of the control's data.</typeparam>
        /// <typeparam name="TOwner">The type of the owner.</typeparam>
        /// <param name="should">The verification provider.</param>
        /// <param name="value">The expected value or combination of enumeration flag values.</param>
        /// <returns>The owner instance.</returns>
        public static TOwner HaveChecked <TData, TOwner>(this IFieldVerificationProvider <TData, CheckBoxList <TData, TOwner>, TOwner> should, TData value)
            where TOwner : PageObject <TOwner>
        {
            should.CheckNotNull(nameof(should));

            IEnumerable <TData> expectedIndividualValues = should.Component.GetIndividualValues(value);
            string expectedIndividualValuesAsString      = should.Component.ConvertIndividualValuesToString(expectedIndividualValues, true);

            string expectedMessage = new StringBuilder().
                                     Append("have checked").
                                     AppendIf(expectedIndividualValues.Count() > 1, ":").
                                     Append($" {expectedIndividualValuesAsString}").ToString();

            should.Component.Context.Log.ExecuteSection(
                new VerificationLogSection(should.VerificationKind, should.Component, $"{should.GetShouldText()} {expectedMessage}"),
                () =>
            {
                IEnumerable <TData> actualIndividualValues = null;
                Exception exception = null;

                bool doesSatisfy = should.Component.Context.Driver.Try().Until(
                    _ =>
                {
                    try
                    {
                        actualIndividualValues = should.Component.GetIndividualValues(should.Component.Get());
                        int intersectionsCount = expectedIndividualValues.Intersect(actualIndividualValues).Count();
                        bool result            = should.IsNegation ? intersectionsCount == 0 : intersectionsCount == expectedIndividualValues.Count();
                        exception = null;
                        return(result);
                    }
                    catch (Exception e)
                    {
                        exception = e;
                        return(false);
                    }
                },
                    should.GetRetryOptions());

                if (!doesSatisfy)
                {
                    string actualMessage = exception == null ? should.Component.ConvertIndividualValuesToString(actualIndividualValues, true) : null;

                    string failureMessage = VerificationUtils.BuildFailureMessage(should, expectedMessage, actualMessage);

                    should.ReportFailure(failureMessage, exception);
                }
            });

            return(should.Owner);
        }
        public static TOwner HaveChecked <TData, TOwner>(this IFieldVerificationProvider <TData, CheckBoxList <TData, TOwner>, TOwner> should, TData value)
            where TOwner : PageObject <TOwner>
        {
            should.CheckNotNull(nameof(should));

            IEnumerable <TData> expectedIndividualValues = should.Component.GetIndividualValues(value);
            string expectedIndividualValuesAsString      = should.Component.ConvertIndividualValuesToString(expectedIndividualValues, true);

            string expectedMessage = new StringBuilder().
                                     Append("have checked").
                                     AppendIf(expectedIndividualValues.Count() > 1, ":").
                                     Append($" {expectedIndividualValuesAsString}").ToString();

            AtataContext.Current.Log.Start(new VerificationLogSection(should.Component, $"{should.GetShouldText()} {expectedMessage}"));

            IEnumerable <TData> actualIndividualValues = null;

            bool doesSatisfy = AtataContext.Current.Driver.Try().Until(
                _ =>
            {
                actualIndividualValues = should.Component.GetIndividualValues(should.Component.Get());
                int intersectionsCount = expectedIndividualValues.Intersect(actualIndividualValues).Count();
                return(should.IsNegation ? intersectionsCount == 0 : intersectionsCount == expectedIndividualValues.Count());
            },
                should.Timeout,
                should.RetryInterval);

            if (!doesSatisfy)
            {
                throw should.CreateAssertionException(
                          expectedMessage,
                          should.Component.ConvertIndividualValuesToString(actualIndividualValues, true));
            }

            AtataContext.Current.Log.EndSection();

            return(should.Owner);
        }
 public static TOwner BeRequired <TOwner>(this IFieldVerificationProvider <string, ValidationMessage <TOwner>, TOwner> should)
     where TOwner : PageObject <TOwner>
 {
     return(should.Equal("This field is required."));
 }
 public static TOwner MustFill <TOwner>(this IFieldVerificationProvider <string, ValidationMessage <TOwner>, TOwner> should)
     where TOwner : PageObject <TOwner>
 {
     return(should.Equal("You must fill this field"));
 }
 public static TOwner HaveMaxLength <TOwner>(this IFieldVerificationProvider <string, ValidationMessage <TOwner>, TOwner> should, int length)
     where TOwner : PageObject <TOwner>
 {
     return(should.Equal($"Please enter no more than {length} characters."));
 }
 public static TOwner HaveIncorrectFormat <TOwner>(this IFieldVerificationProvider <string, ValidationMessage <TOwner>, TOwner> should)
     where TOwner : PageObject <TOwner>
 {
     return(should.Equal("has incorrect format"));
 }
 public static TOwner HaveMaxLength <TOwner>(this IFieldVerificationProvider <string, ValidationMessage <TOwner>, TOwner> should, int length)
     where TOwner : PageObject <TOwner>
 {
     return(should.Equal($"maximum length is {length}"));
 }
예제 #9
0
 /// <summary>
 ///   Haves the minimum length.
 /// </summary>
 /// <typeparam name="TOwner">
 ///   The type of the owner.
 /// </typeparam>
 /// <param name="should">
 ///   The should.
 /// </param>
 /// <param name="length">
 ///   The length.
 /// </param>
 /// <returns></returns>
 public static TOwner HaveMinLength <TOwner>(this IFieldVerificationProvider <string, ValidationMessage <TOwner>, TOwner> should, int length)
     where TOwner : PageObject <TOwner>
 {
     return(should.EndWithIgnoringCase($"field must be at least {length} characters."));
 }
예제 #10
0
 /// <summary>
 ///   Haves the incorrect format.
 /// </summary>
 /// <typeparam name="TOwner">
 ///   The type of the owner.
 /// </typeparam>
 /// <param name="should">
 ///   The should.
 /// </param>
 /// <returns></returns>
 public static TOwner HaveIncorrectFormat <TOwner>(this IFieldVerificationProvider <string, ValidationMessage <TOwner>, TOwner> should)
     where TOwner : PageObject <TOwner>
 {
     return(should.Equal("The email field must be a valid email."));
 }