public static void GetSessionsAsync_Throws_If_BuildId_Is_Null() { // Arrange BrowserStackAutomateClient target = CreateClient(); string buildId = null; // Act and Assert target .Awaiting((p) => p.GetSessionsAsync(buildId)) .Should() .Throw <ArgumentException>() .And .ParamName.Should().Be("buildId"); }
public static void GetSessionAsync_Throws_If_SessionId_Is_Not_Found() { // Arrange BrowserStackAutomateClient target = CreateAuthenticatedClient(); string sessionId = Guid.NewGuid().ToString(); // Act and Assert target .Awaiting((p) => p.GetSessionAsync(sessionId)) .Should() .Throw <BrowserStackAutomateException>() .And .ErrorDetail.Should().NotBeNull(); }
public static void DeleteSessionsAsync_Throws_If_SessionIds_Is_Empty() { // Arrange BrowserStackAutomateClient target = CreateClient(); var sessionIds = Array.Empty <string>(); // Act and Assert target .Awaiting((p) => p.DeleteSessionsAsync(sessionIds)) .Should() .Throw <ArgumentException>() .And .ParamName.Should().Be("sessionIds"); }
public static void DeleteSessionsAsync_Throws_If_SessionIds_Is_Null() { // Arrange BrowserStackAutomateClient target = CreateClient(); ICollection <string> sessionIds = null; // Act and Assert target .Awaiting((p) => p.DeleteSessionsAsync(sessionIds)) .Should() .Throw <ArgumentNullException>() .And .ParamName.Should().Be("sessionIds"); }
public static void DeleteProjectAsync_Throws_If_ProjectId_Is_Not_Found() { // Arrange BrowserStackAutomateClient target = CreateAuthenticatedClient(); int projectId = 0; // Act and Assert target .Awaiting((p) => p.DeleteProjectAsync(projectId)) .Should() .Throw <BrowserStackAutomateException>() .And .ErrorDetail.Should().NotBeNull(); }
public static void SetSessionStatusAsync_Throws_If_Status_Is_Null() { // Arrange BrowserStackAutomateClient target = CreateClient(); string sessionId = "x"; string status = null; string reason = null; // Act and Assert target .Awaiting((p) => p.SetSessionStatusAsync(sessionId, status, reason)) .ShouldThrow <ArgumentException>() .And .ParamName.Should().Be("status"); }
public static void SetSessionNameAsync_Throws_If_Name_Is_Null() { // Arrange BrowserStackAutomateClient target = CreateClient(); string sessionId = "x"; string name = null; // Act and Assert target .Awaiting((p) => p.SetSessionNameAsync(sessionId, name)) .Should() .Throw <ArgumentException>() .And .ParamName.Should().Be("name"); }
public static void SetSessionErrorAsync_Throws_If_Client_Is_Null() { // Arrange BrowserStackAutomateClient client = null; string sessionId = "MySessionId"; string reason = "My reason"; // Act and Assert client .Awaiting((p) => p.SetSessionErrorAsync(sessionId, reason)) .ShouldThrow <ArgumentNullException>() .And .ParamName .Should() .Be("client"); }
public static async Task Can_Delete_Session() { // Arrange BrowserStackAutomateClient target = CreateAuthenticatedClient(); string sessionId = "CHANGE_ME"; // Act await target.DeleteSessionAsync(sessionId); // Assert target .Awaiting((p) => p.DeleteSessionAsync(sessionId)) .ShouldThrow <BrowserStackAutomateException>() .And .ErrorDetail.Should().NotBeNull(); }
public static async Task Can_Delete_Project() { // Arrange BrowserStackAutomateClient target = CreateAuthenticatedClient(); int projectId = 0; // Act await target.DeleteProjectAsync(projectId); // Assert target .Awaiting((p) => p.DeleteProjectAsync(projectId)) .ShouldThrow <BrowserStackAutomateException>() .And .ErrorDetail.Should().NotBeNull(); }
public static void GetBuildsAsync_Throws_If_Limit_Is_Less_Than_One() { // Arrange BrowserStackAutomateClient target = CreateClient(); int? limit = 0; string status = null; // Act and Assert target .Awaiting((p) => p.GetBuildsAsync(limit, status)) .ShouldThrow <ArgumentOutOfRangeException>() .Where((p) => p.ParamName == "limit") .Where((p) => p.Message.StartsWith("The limit value cannot be less than one.")) .And .ActualValue.Should().Be(0); }
public static void GetBuildsAsync_Throws_If_Offset_Is_Less_Than_Zero() { // Arrange BrowserStackAutomateClient target = CreateClient(); int? limit = 1; int? offset = -1; string status = null; // Act and Assert target .Awaiting((p) => p.GetBuildsAsync(limit, offset, status)) .Should() .Throw <ArgumentOutOfRangeException>() .Where((p) => p.ParamName == "offset") .Where((p) => p.Message.StartsWith("The offset value cannot be less than zero.", StringComparison.Ordinal)) .And .ActualValue.Should().Be(-1); }
public static async Task Can_Query_BrowserStack_Automate_Api() { // Arrange BrowserStackAutomateClient target = CreateAuthenticatedClient(); int? limit; string status; // Act ICollection <Browser> browsers = await target.GetBrowsersAsync(); // Assert browsers.Should().NotBeNullOrEmpty(); browsers.Should().NotContainNulls(); browsers.All((p) => !string.IsNullOrEmpty(p.BrowserVersion)); browsers.All((p) => !string.IsNullOrEmpty(p.Device)); foreach (var browser in browsers) { browser.Should().NotBeNull(); browser.BrowserName.Should().NotBeNullOrEmpty(); browser.BrowserName.Should().NotBeNullOrEmpty(); browser.OSName.Should().NotBeNullOrEmpty(); browser.OSVersion.Should().NotBeNullOrEmpty(); } // Act ICollection <Build> builds = await target.GetBuildsAsync(); // Assert builds.Should().NotBeNull(); builds.Should().NotContainNulls(); foreach (var build in builds) { build.Should().NotBeNull(); build.Duration.Should().BeGreaterOrEqualTo(1); build.HashedId.Should().NotBeNullOrEmpty(); build.Name.Should().NotBeNullOrEmpty(); build.Status.Should().NotBeNullOrEmpty(); } // Arrange foreach (var build in builds) { // Act ICollection <Session> sessions = await target.GetSessionsAsync(build.HashedId); // Assert sessions.Should().NotBeNull(); sessions.Should().NotContainNulls(); sessions.All((p) => !string.IsNullOrEmpty(p.BrowserName)); sessions.All((p) => !string.IsNullOrEmpty(p.BrowserVersion)); // Limit the sessions for performance foreach (var session in sessions.Take(1)) { AssertSession(session, build.Name); // Act var sessionDetail = await target.GetSessionAsync(session.HashedId); // Assert sessionDetail.Should().NotBeNull(); sessionDetail.BrowserUri.Should().NotBeNull(); sessionDetail.PublicUri.Should().NotBeNull(); sessionDetail.VideoUri.Should().NotBeNull(); sessionDetail.BrowserName.Should().Be(session.BrowserName); sessionDetail.BrowserVersion.Should().Be(session.BrowserVersion); sessionDetail.BuildName.Should().Be(session.BuildName); sessionDetail.Duration.Should().Be(session.Duration); sessionDetail.HashedId.Should().Be(session.HashedId); sessionDetail.LogsUri.Should().Be(session.LogsUri); sessionDetail.Name.Should().Be(session.Name); sessionDetail.OSName.Should().Be(session.OSName); sessionDetail.OSVersion.Should().Be(session.OSVersion); sessionDetail.ProjectName.Should().Be(session.ProjectName); sessionDetail.Reason.Should().Be(session.Reason); sessionDetail.Status.Should().Be(session.Status); // Act Session updatedSession = await target.SetSessionCompletedAsync(session.HashedId, string.Empty); // Assert updatedSession.Should().NotBeNull(); updatedSession.HashedId.Should().Be(session.HashedId); } // Arrange limit = 5; status = null; // Act sessions = await target.GetSessionsAsync(build.HashedId, limit, status); // Assert sessions.Should().NotBeNull(); sessions.Should().NotContainNulls(); sessions.Count.Should().BeLessOrEqualTo(limit.Value); foreach (var session in sessions) { AssertSession(session, build.Name); } // Arrange limit = null; status = SessionStatuses.Done; // Act sessions = await target.GetSessionsAsync(build.HashedId, limit, status); // Assert sessions.Should().NotBeNull(); sessions.Should().NotContainNulls(); foreach (var session in sessions) { AssertSession(session, build.Name); } // Arrange limit = 5; status = SessionStatuses.Done; // Act sessions = await target.GetSessionsAsync(build.HashedId, limit, status); // Assert sessions.Should().NotBeNull(); sessions.Should().NotContainNulls(); sessions.Count.Should().BeLessOrEqualTo(limit.Value); foreach (var session in sessions) { AssertSession(session, build.Name); // Act (no Assert) await target.GetSessionLogsAsync(build.HashedId, session.HashedId); } } // Arrange limit = 5; status = null; // Act builds = await target.GetBuildsAsync(limit, status); // Assert builds.Should().NotBeNull(); builds.Should().NotContainNulls(); builds.Count.Should().BeLessOrEqualTo(limit.Value); foreach (var build in builds) { AssertBuild(build); } // Arrange limit = null; status = BuildStatuses.Done; // Act builds = await target.GetBuildsAsync(limit, status); // Assert builds.Should().NotBeNull(); builds.Should().NotContainNulls(); foreach (var build in builds) { AssertBuild(build, status); } // Act ICollection <Project> projects = await target.GetProjectsAsync(); // Assert projects.Should().NotBeNullOrEmpty(); projects.Should().NotContainNulls(); DateTime minimumDate = new DateTime(2011, 1, 1, 0, 0, 0); foreach (var project in projects) { project.Should().NotBeNull(); project.GroupId.Should().BeGreaterThan(0); project.Id.Should().BeGreaterThan(0); project.CreatedAt.Should().BeAfter(minimumDate); project.UpdatedAt.Should().BeAfter(minimumDate); project.Name.Should().NotBeNullOrEmpty(); if (project.UserId.HasValue) { project.UserId.Should().BeGreaterThan(0); } } // Arrange foreach (int projectId in projects.Select((p) => p.Id)) { // Act ProjectDetailItem projectItem = await target.GetProjectAsync(projectId); // Assert projectItem.Should().NotBeNull(); projectItem.Project.Should().NotBeNull(); var project = projectItem.Project; project.GroupId.Should().BeGreaterThan(0); project.Id.Should().BeGreaterThan(0); project.CreatedAt.Should().BeAfter(minimumDate); project.UpdatedAt.Should().BeAfter(minimumDate); project.Name.Should().NotBeNullOrEmpty(); project.Builds.Should().NotBeNull(); project.Builds.Should().NotContainNulls(); foreach (var build in project.Builds) { build.Should().NotBeNull(); build.Should().NotBeNull(); build.CreatedAt.Should().BeOnOrAfter(project.CreatedAt); build.Duration.Should().BeGreaterOrEqualTo(1); build.Id.Should().BeGreaterThan(0); build.HashedId.Should().NotBeNullOrEmpty(); build.Name.Should().NotBeNullOrEmpty(); build.Status.Should().NotBeNullOrEmpty(); build.UpdatedAt.Should().BeAfter(project.CreatedAt); build.UpdatedAt.Should().BeAfter(build.CreatedAt); build.GroupId.Should().Be(project.GroupId); build.ProjectId.Should().Be(project.Id); build.UserId.Should().BeGreaterThan(0); } } // Act AutomatePlanStatus plan = await target.GetStatusAsync(); // Assert plan.Should().NotBeNull(); plan.AutomatePlan.Should().NotBeNullOrEmpty(); plan.MaximumAllowedParallelSessions.Should().BeGreaterOrEqualTo(1); plan.MaximumQueuedParallelSessions.Should().BeGreaterOrEqualTo(1); plan.ParallelSessionsRunning.Should().BeGreaterOrEqualTo(0); plan.QueuedParallelSessions.Should().BeGreaterOrEqualTo(0); plan.TeamMaximumAllowedParallelSessions.Should().BeGreaterOrEqualTo(0); }