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>()); }
/// <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); }
/// <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); }
/// <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); }
/// <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); }
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); }
/// <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>()); }
private static string GetValueCore(this IHaveValue iHaveValue, string path) { Assert.IsNotNull(iHaveValue, string.Format("Could not cast {0} to IHaveValue.", path)); return(iHaveValue.Value); }
/// <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)); }
/// <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)); }
/// <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); }
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)); } } }
/// <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); }