Skip to content

Instantly share code, notes, and snippets.

@jamesmcroft
Created June 28, 2020 16:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamesmcroft/a601126014ea9946054306d47a323ed8 to your computer and use it in GitHub Desktop.
Save jamesmcroft/a601126014ea9946054306d47a323ed8 to your computer and use it in GitHub Desktop.
An example test showing how to reference Legerity elements in a test
namespace MyAppTests
{
using System.Threading;
using Legerity;
using Legerity.Windows;
using Legerity.Windows.Elements.Core;
using Legerity.Windows.Extensions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenQA.Selenium;
[TestClass]
public class HomepageTests : BaseTest
{
[TestMethod]
public void CanSetCalendarDate()
{
// Arrange
var expectedDate = new DateTime(2020, 4, 14);
CalendarView myCalendarView = AppManager.WindowsApp.FindElement(ByExtensions.AutomationId("myCalendarView"));
// Act
myCalendarView.SetDate(expectedDate);
// Assert
string day = expectedDate.ToString("%d");
string month = expectedDate.ToString("MMMM");
string year = expectedDate.ToString("yyyy");
string actualDate = myCalendarView.Value;
Assert.IsTrue(
actualDate.Contains(day, StringComparison.CurrentCultureIgnoreCase)
&& actualDate.Contains(month, StringComparison.CurrentCultureIgnoreCase)
&& actualDate.Contains(year, StringComparison.CurrentCultureIgnoreCase));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment