public void ArraysAndBasicPolymorphism()
        {
            Mapper.CreateMap<SourceValue, DestinationValue>()
                .Include<SourceValueChild, DestinationValueChild>();

            Mapper.CreateMap<SourceValueChild, DestinationValueChild>();
            Mapper.Map<SourceValue, DestinationValue>(new SourceValueChild());

            var sources = new IHaveValue[]
            {
                new SourceValue { Value = 5 },
                new SourceValueChild { Value = 6 },
                new SourceValue { Value = 7 }
            };

            IEnumerable<DestinationValue> ienumerableDest = Mapper.Map<IHaveValue[], IEnumerable<DestinationValue>>(sources);
            ICollection<DestinationValue> icollectionDest = Mapper.Map<IHaveValue[], ICollection<DestinationValue>>(sources);
            IList<DestinationValue> ilistDest = Mapper.Map<IHaveValue[], IList<DestinationValue>>(sources);
            List<DestinationValue> listDest = Mapper.Map<IHaveValue[], List<DestinationValue>>(sources);
            DestinationValue[] dest = Mapper.Map<IHaveValue[], DestinationValue[]>(sources);

            CollectionAssert.AreEqual(sources, ienumerableDest, new ValueComparer());
            CollectionAssert.AreEqual(sources, icollectionDest, new ValueComparer());
            CollectionAssert.AreEqual(sources, ilistDest, new ValueComparer());
            CollectionAssert.AreEqual(sources, listDest, new ValueComparer());
            CollectionAssert.AreEqual(sources, dest, new ValueComparer());

            Assert.That(listDest[0], Is.InstanceOf<DestinationValue>());
            Assert.That(listDest[1], Is.InstanceOf<DestinationValueChild>());
            Assert.That(listDest[2], Is.InstanceOf<DestinationValue>());
        }
示例#2
0
        /// <summary>
        /// Checks the widget value matches the specified string.
        /// </summary>
        /// <param name="parent">The parent widget.</param>
        /// <param name="path">The widget path.</param>
        /// <param name="value">The value to check.</param>
        /// <param name="timeoutInSeconds">The number of seconds to wait for the widget (default is 5).</param>
        public static void CheckValueIs(this IWidget parent, string path, string value,
                                        int timeoutInSeconds = 5)
        {
            IHaveValue iHaveValue = parent.WidgetGet <IHaveValue>(path, timeoutInSeconds);

            CheckValueCore(iHaveValue, path, value);
        }
示例#3
0
        /// <summary>
        /// Sets the text of the widget with the given parent and path, and waits until it matches.
        /// </summary>
        /// <param name="parent">The parent widget.</param>
        /// <param name="path">The widget path.</param>
        /// <param name="text">The text to match.</param>
        /// <param name="widgetType">The widget type name.</param>
        /// <param name="timeoutInSeconds">The number of seconds to wait for the widget (default is 5).</param>
        public static void WidgetSetTextAssertSync(this IWidget parent, string path, string text, string widgetType,
                                                   long timeoutInSeconds = 5)
        {
            IHaveValue valueWidget = parent.WidgetRefresh(path, widgetType, timeoutInSeconds) as IHaveValue;

            if (valueWidget == null)
            {
                throw new ArgumentException("Widget does not support Value property", nameof(path));
            }

            valueWidget.Value = text;

            var driver = parent.Driver as WisejWebDriver;

            if (driver != null)
            {
                driver.Wait(() =>
                {
                    IWidget waitWidget = parent.WidgetRefresh(path, widgetType, timeoutInSeconds);
                    return(Equals(text, waitWidget.Text));
                }, false, timeoutInSeconds);
            }

            IWidget widget = parent.WidgetGet(path, widgetType, timeoutInSeconds);

            WidgetAssertTextIsCore(widget, text);
        }
示例#4
0
        /// <summary>
        /// Checks the widget value matches the specified string.
        /// </summary>
        /// <param name="driver">The <see cref="WisejWebDriver"/> to use.</param>
        /// <param name="path">The widget path.</param>
        /// <param name="value">The value to check.</param>
        /// <param name="timeoutInSeconds">The number of seconds to wait for the widget (default is 5).</param>
        public static void CheckValueIs(this WisejWebDriver driver, string path, string value,
                                        int timeoutInSeconds = 5)
        {
            IHaveValue iHaveValue = driver.WidgetGet <IHaveValue>(path, timeoutInSeconds);

            CheckValueCore(iHaveValue, path, value);
        }
示例#5
0
        /// <summary>
        /// Asserts the widget value matches the specified string.
        /// </summary>
        /// <param name="parent">The parent widget.</param>
        /// <param name="path">The widget path.</param>
        /// <param name="value">The value to check.</param>
        /// <param name="timeoutInSeconds">The number of seconds to wait for the widget (default is 5).</param>
        public static void AssertValueIs(this IWidget parent, string path, string value,
                                         long timeoutInSeconds = 5)
        {
            IHaveValue iHaveValue = parent.WidgetGet <IHaveValue>(path, timeoutInSeconds);

            AssertValueCore(iHaveValue, path, value);
        }
示例#6
0
        private static void CheckValueCore(this IHaveValue iHaveValue, string path, string value)
        {
            Assert.IsNotNull(iHaveValue, string.Format("Could not cast {0} to IHaveValue.", path));

            string iHaveValueValue = iHaveValue.Value;

            //Assert.AreEqual(value, iHaveValueValue, string.Format("Expected {0} and actual is {1}.", value, iHaveValueValue));
            Assert.AreEqual(value, iHaveValueValue);
        }
示例#7
0
        /// <summary>
        /// Sets the text of the widget with the given path, and waits until it matches.
        /// </summary>
        /// <param name="driver">The <see cref="WisejWebDriver"/> to use.</param>
        /// <param name="path">The widget path.</param>
        /// <param name="text">The text to match.</param>
        /// <param name="widgetType">The widget type name.</param>
        /// <param name="timeoutInSeconds">The number of seconds to wait for the widget (default is 5).</param>
        public static void SetTextCheckResult(this WisejWebDriver driver, string path, string text,
                                              string widgetType, int timeoutInSeconds = 5)
        {
            IHaveValue valueWidget = driver.WidgetGet(path, widgetType, timeoutInSeconds) as IHaveValue;

            if (valueWidget == null)
            {
                throw new ArgumentException("Widget does not support Value property", nameof(path));
            }

            valueWidget.Value = text;
            driver.Wait(() =>
            {
                IWidget waitWidget = driver.WidgetRefresh(path, widgetType, timeoutInSeconds);
                return(Equals(text, waitWidget.Text));
            }, false, timeoutInSeconds);

            IWidget widget = driver.WidgetGet(path, widgetType, timeoutInSeconds);

            CheckTextIsCore(widget, text);
        }
        public void ArraysAndBasicPolymorphism()
        {
            Mapper.CreateMap <SourceValue, DestinationValue>()
            .Include <SourceValueChild, DestinationValueChild>();

            Mapper.CreateMap <SourceValueChild, DestinationValueChild>();
            Mapper.Map <SourceValue, DestinationValue>(new SourceValueChild());

            var sources = new IHaveValue[]
            {
                new SourceValue {
                    Value = 5
                },
                new SourceValueChild {
                    Value = 6
                },
                new SourceValue {
                    Value = 7
                }
            };

            IEnumerable <DestinationValue> ienumerableDest = Mapper.Map <IHaveValue[], IEnumerable <DestinationValue> >(sources);
            ICollection <DestinationValue> icollectionDest = Mapper.Map <IHaveValue[], ICollection <DestinationValue> >(sources);
            IList <DestinationValue>       ilistDest       = Mapper.Map <IHaveValue[], IList <DestinationValue> >(sources);
            List <DestinationValue>        listDest        = Mapper.Map <IHaveValue[], List <DestinationValue> >(sources);

            DestinationValue[] dest = Mapper.Map <IHaveValue[], DestinationValue[]>(sources);

            CollectionAssert.AreEqual(sources, ienumerableDest, new ValueComparer());
            CollectionAssert.AreEqual(sources, icollectionDest, new ValueComparer());
            CollectionAssert.AreEqual(sources, ilistDest, new ValueComparer());
            CollectionAssert.AreEqual(sources, listDest, new ValueComparer());
            CollectionAssert.AreEqual(sources, dest, new ValueComparer());

            Assert.That(listDest[0], Is.InstanceOf <DestinationValue>());
            Assert.That(listDest[1], Is.InstanceOf <DestinationValueChild>());
            Assert.That(listDest[2], Is.InstanceOf <DestinationValue>());
        }
示例#9
0
 private static string GetValueCore(this IHaveValue iHaveValue, string path)
 {
     Assert.IsNotNull(iHaveValue, string.Format("Could not cast {0} to IHaveValue.", path));
     return(iHaveValue.Value);
 }
示例#10
0
        /// <summary>
        /// Gets the widget value.
        /// </summary>
        /// <param name="parent">The parent widget.</param>
        /// <param name="path">The widget path.</param>
        /// <param name="timeoutInSeconds">The number of seconds to wait for the widget (default is 5).</param>
        /// <returns>A <see cref="string"/> with the widget value.</returns>
        public static string GetValue(this IWidget parent, string path, int timeoutInSeconds = 5)
        {
            IHaveValue iHaveValue = parent.WidgetGet <IHaveValue>(path, timeoutInSeconds);

            return(GetValueCore(iHaveValue, path));
        }
示例#11
0
        /// <summary>
        /// Gets the widget value.
        /// </summary>
        /// <param name="driver">The <see cref="WisejWebDriver"/> to use.</param>
        /// <param name="path">The widget path.</param>
        /// <param name="timeoutInSeconds">The number of seconds to wait for the widget (default is 5).</param>
        /// <returns>A <see cref="string"/> with the widget value.</returns>
        public static string GetValue(this WisejWebDriver driver, string path, int timeoutInSeconds = 5)
        {
            IHaveValue iHaveValue = driver.WidgetGet <IHaveValue>(path, timeoutInSeconds);

            return(GetValueCore(iHaveValue, path));
        }
示例#12
0
 /// <summary>
 /// Checks the widget value matches the specified string.
 /// </summary>
 /// <param name="iHaveValue">The <see cref="IHaveValue"/> widget.</param>
 /// <param name="value">The value to check.</param>
 public static void CheckValueIs(this IHaveValue iHaveValue, string value)
 {
     CheckValueCore(iHaveValue, "", value);
 }
示例#13
0
        private static void CellSetTextCheckResultCore(this DataGridView dataGridView, int?colIdx, int?rowIdx,
                                                       string text, string result, string widgetType, int timeoutInSeconds)
        {
            IHaveValue cellEditor = null;

            var driver = ((IWidget)dataGridView).Driver as WisejWebDriver;

            if (driver != null)
            {
                if (colIdx.HasValue && rowIdx.HasValue)
                {
                    // wait for focus cell
                    driver.Wait(() =>
                    {
                        dataGridView.FocusCell(colIdx.Value, rowIdx.Value);
                        var focusedRow    = dataGridView.GetFocusedRow();
                        var focusedColumn = dataGridView.GetFocusedColumn();

                        return(focusedColumn != colIdx.Value || focusedRow != rowIdx.Value);
                    }, false, timeoutInSeconds);
                }

                // wait for cell editor, start editing
                driver.Wait(() =>
                {
                    // get cell editor, start editing
                    IWidget iWidget = dataGridView.CellEditorGet(widgetType);

                    if (iWidget != null)
                    {
                        cellEditor = iWidget as IHaveValue;
                        if (cellEditor == null)
                        {
                            throw new ArgumentException(string.Format(
                                                            "Widget at column {0}, row {1} ({2}) does not support Value property", colIdx, rowIdx,
                                                            widgetType));
                        }

                        return(true);
                    }

                    return(false);
                }, false, timeoutInSeconds);

                if (cellEditor != null)
                {
                    // set value and check value on the cell editor
                    driver.Wait(() =>
                    {
                        cellEditor.Value = text;
                        return(Equals(text, cellEditor.Text));
                    }, false, timeoutInSeconds);

                    // stop editing
                    dataGridView.StopEditing();
                }

                if (!string.IsNullOrEmpty(result))
                {
                    Assert.AreEqual(result, dataGridView.WaitForCellText(result, timeoutInSeconds));
                }
                else
                {
                    Assert.AreEqual(text, dataGridView.WaitForCellText(text, timeoutInSeconds));
                }
            }
        }
示例#14
0
 /// <summary>
 /// Asserts the widget value matches the specified string.
 /// </summary>
 /// <param name="iHaveValue">The <see cref="IHaveValue"/> widget.</param>
 /// <param name="value">The value to check.</param>
 public static void AssertValueIs(this IHaveValue iHaveValue, string value)
 {
     AssertValueCore(iHaveValue, "", value);
 }