Created
June 28, 2020 16:06
-
-
Save jamesmcroft/a601126014ea9946054306d47a323ed8 to your computer and use it in GitHub Desktop.
An example test showing how to reference Legerity elements in a test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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