public void Test_CreateEventPage_CreateEvent_ValidData() { // Arrange: open the "Create Event" page var createEventPage = new CreateEventPage(driver); createEventPage.Open(baseUrl); // act: create a new event var eventName = "Party" + DateTime.Now.Ticks; var eventPlace = "Beach"; createEventPage.CreateEvent(eventName, eventPlace, "100", "10.00"); // Assert user is redirected to the "All Events" page var allEventsPage = new AllEventsPage(driver); Assert.IsTrue(allEventsPage.IsOpen(baseUrl)); // Assert the new event appears var eventRowText = allEventsPage.GetEventRow(eventName); Assert.That(eventRowText.Contains(eventName)); Assert.That(eventRowText.Contains(eventPlace)); Assert.That(eventRowText.Contains(username)); Assert.That(eventRowText.Contains("Delete")); Assert.That(eventRowText.Contains("Edit")); }
private void LogAllEventsPage(AllEventsPage allEventsPage) { _testOutputHelper.WriteLine($"FromCheckpoint = {allEventsPage.FromCheckpoint}"); _testOutputHelper.WriteLine($"NextCheckpoint = {allEventsPage.NextCheckpoint}"); _testOutputHelper.WriteLine($"IsEnd = {allEventsPage.IsEnd}"); _testOutputHelper.WriteLine($"StreamEvents.Count = {allEventsPage.StreamEvents.Count}"); _testOutputHelper.WriteLine(""); }
public static AllEventsPage LoadAllEvents( this IEventStore eventStore, GlobalPosition globalPosition, int pageSize, CancellationToken cancellationToken) { AllEventsPage allEventsPage = null; using (var a = AsyncHelper.Wait) { a.Run(eventStore.LoadAllEventsAsync(globalPosition, pageSize, cancellationToken), p => allEventsPage = p); } return(allEventsPage); }
public void Test_AllEventsPage_Anonymous() { // Arrange // Act: go to the "All Events" page var allEventsPage = new AllEventsPage(driver); allEventsPage.Open(baseUrl); // Assert the user is redirected to the "Log in" page var loginPage = new LoginPage(driver); Assert.IsTrue(loginPage.IsOpenWhenUnauthorized(baseUrl)); Assert.AreEqual("Log in - Eventures App", loginPage.GetPageTitle()); Assert.AreEqual("Log in", loginPage.GetPageHeadingText()); Assert.IsTrue(loginPage.Contains("Use a local account to log in")); }
public void Test_HomePage_AllEventsLink() { // Arrange: go to the "Home" page var homePage = new HomePage(driver); homePage.Open(baseUrl); // Act: click on the "All Events" page link homePage.AllEventsPageLink.Click(); // Assert the user is redirected to the "All Events" page var allEventsPage = new AllEventsPage(driver); Assert.IsTrue(allEventsPage.IsOpen(baseUrl)); Assert.AreEqual("All Events - Eventures App", allEventsPage.GetPageTitle()); Assert.AreEqual("All Events", allEventsPage.GetPageHeadingText()); Assert.That(allEventsPage.Contains("Create New")); }
public void Test_EditEvent_ValidData() { // Create an event for editing string eventName = "Best Show" + DateTime.Now.Ticks; this.CreateEvent(eventName); // Assert user is redirected to the "All Events" page var allEventsPage = new AllEventsPage(driver); Assert.IsTrue(allEventsPage.IsOpen(baseUrl)); // Get the row with the new event var eventRowText = allEventsPage.GetEventRow(eventName); Assert.That(eventRowText.Contains(eventName)); // Click on the "Edit" button of the new event allEventsPage.PressEventEditButton(eventName); // Assert the user is redirected to the "Edit Event" page var editPage = new EditPage(driver); Assert.IsTrue(editPage.IsOpen(baseUrl)); Assert.AreEqual("Edit Event - Eventures App", editPage.GetPageTitle()); Assert.AreEqual("Edit Event", editPage.GetPageHeadingText()); Assert.IsTrue(editPage.Contains(eventName)); // Change the name of the event var changedName = "Best Best Show" + DateTime.Now.Ticks; editPage.EditEventName(changedName); // Assert the user is redirected to the "All Events" page Assert.IsTrue(allEventsPage.IsOpen(baseUrl)); // Assert that the page contains the new event name and not the old one Assert.IsTrue(allEventsPage.Contains(changedName)); Assert.IsFalse(allEventsPage.Contains(eventName)); }
public void Test_EditEvent_InvalidData() { // Create an event for editing string eventName = "Best Show" + DateTime.Now.Ticks; this.CreateEvent(eventName); // Assert user is redirected to the "All Events" page var allEventsPage = new AllEventsPage(driver); Assert.IsTrue(allEventsPage.IsOpen(baseUrl)); // Get the row with the new event var eventRowText = allEventsPage.GetEventRow(eventName); Assert.That(eventRowText.Contains("Edit")); // Click on the "Edit" button of the new event allEventsPage.PressEventEditButton(eventName); // Assert the user is redirected to the "Edit Event" page var editPage = new EditPage(driver); Assert.IsTrue(editPage.IsOpen(baseUrl)); Assert.AreEqual("Edit Event - Eventures App", editPage.GetPageTitle()); Assert.AreEqual("Edit Event", editPage.GetPageHeadingText()); Assert.IsTrue(editPage.Contains(eventName)); // Change the name of the event with an invalid one var invalidName = string.Empty; editPage.EditEventName(invalidName); // Assert the user is on the same page Assert.IsTrue(editPage.IsOpen(baseUrl)); // Assert an error message appears on the page Assert.AreEqual("The Name field is required.", editPage.GetNameError()); }
public void Test_DeleteEvent() { // Arrange: create an event for deleting string eventName = "Best Show" + DateTime.Now.Ticks; this.CreateEvent(eventName); // Assert the user is redirected to the "All Events" page var allEventsPage = new AllEventsPage(driver); Assert.IsTrue(allEventsPage.IsOpen(baseUrl)); // Get the row with the new event var eventRowText = allEventsPage.GetEventRow(eventName); Assert.That(eventRowText.Contains(eventName)); // Click on the "Edit" button of the new event allEventsPage.PressEventDeleteButton(eventName); // Assert the user is redirected to the "Delete Event" page var deletePage = new DeletePage(driver); Assert.IsTrue(deletePage.IsOpen(baseUrl)); Assert.AreEqual("Delete Event - Eventures App", deletePage.GetPageTitle()); Assert.AreEqual("Delete Existing Event", deletePage.GetPageHeadingText()); Assert.IsTrue(deletePage.Contains(eventName)); // Act: click on the "Delete" button to confirm deletion deletePage.PressConfirmDeleteButton(); // Assert the user is redirected to the "All Events" page Assert.IsTrue(allEventsPage.IsOpen(baseUrl)); // Assert that the event doesn't appear on the page Assert.IsFalse(allEventsPage.Contains(eventName)); }
protected override Task <AllEventsPage> ReadAllBackwardsInternal( long fromCheckpointExclusive, int maxCount, CancellationToken cancellationToken = default(CancellationToken)) { if (_isDisposed) { throw new ObjectDisposedException(nameof(InMemoryEventStore)); } _lock.EnterReadLock(); try { if (fromCheckpointExclusive == Checkpoint.End) { fromCheckpointExclusive = _allStream.Last.Value.Checkpoint; } // Find the node to start from (it may not be equal to the exact checkpoint) var current = _allStream.First; if (current.Next == null) //Empty store { return(Task.FromResult( new AllEventsPage(Checkpoint.Start, Checkpoint.Start, true, ReadDirection.Backward))); } var previous = current.Previous; while (current.Value.Checkpoint < fromCheckpointExclusive) { if (current.Next == null) // fromCheckpoint is past end of store { return(Task.FromResult( new AllEventsPage(fromCheckpointExclusive, fromCheckpointExclusive, true, ReadDirection.Backward))); } previous = current; current = current.Next; } var streamEvents = new List <StreamEvent>(); while (maxCount > 0 && current != _allStream.First) { var streamEvent = new StreamEvent( current.Value.StreamId, current.Value.EventId, current.Value.StreamVersion, current.Value.Checkpoint, current.Value.Created, current.Value.Type, current.Value.JsonData, current.Value.JsonMetadata); streamEvents.Add(streamEvent); maxCount--; previous = current; current = current.Previous; } bool isEnd; if (previous == null || previous.Value.Checkpoint == 0) { isEnd = true; } else { isEnd = false; } var nextCheckPoint = isEnd ? 0 : current.Value.Checkpoint; fromCheckpointExclusive = streamEvents.Any() ? streamEvents[0].Checkpoint : 0; var page = new AllEventsPage( fromCheckpointExclusive, nextCheckPoint, isEnd, ReadDirection.Backward, streamEvents.ToArray()); return(Task.FromResult(page)); } finally { _lock.ExitReadLock(); } }