/// <summary> /// Creates a new instance of the web test properties inheriting the <see cref="WebTestProperties"/> class. /// </summary> /// <param name="testLocations"><see cref="TestLocations"/> value.</param> /// <param name="testStatus"><see cref="TestStatus"/> value.</param> /// <param name="testFrequency"><see cref="TestFrequency"/> value.</param> /// <param name="testTimeout"><see cref="TestTimeout"/> value.</param> /// <param name="parseDependentRequests">Value indicating whether to parse dependent requests or not.</param> /// <param name="retriesForWebTestFailure"><see cref="RetriesForWebTestFailure"/> value.</param> /// <param name="expectedHttpStatusCode">HTTP status code expected. Default value is <c>200</c>.</param> /// <param name="authType"><see cref="AuthType"/> value.</param> /// <param name="accessToken">Access token value.</param> /// <param name="text">Text to find in the validation rule.</param> public void CreateWebTestProperties(TestLocations testLocations, TestStatus testStatus, TestFrequency testFrequency, TestTimeout testTimeout, bool parseDependentRequests, RetriesForWebTestFailure retriesForWebTestFailure, int expectedHttpStatusCode = 200, AuthType authType = AuthType.None, string accessToken = null, string text = null) { WebTestProperties properties; switch (this._testType) { case TestType.UrlPingTest: properties = this.CreatePingWebTestProperties(testLocations, testStatus, testFrequency, testTimeout, parseDependentRequests, retriesForWebTestFailure, expectedHttpStatusCode, authType, accessToken, text); break; case TestType.MultiStepTest: properties = new MultiStepWebTestProperties(); break; default: properties = null; break; } this.Properties = properties; }
public async void Given_Parameters_CreateOrUpdateWebTestAsync_ShouldReturn_Result(string name, string url, TestStatus testStatus, TestFrequency testFrequency, TestTimeout testTimeout, bool parseDependentRequests, RetriesForWebTestFailure retriesForWebTestFailure, AuthType authType, string accessToken, TestLocations testLocations, string resourceGroup, string location) { var successCriteria = new Mock <SucessCriteriaElement>(); successCriteria.SetupGet(p => p.Timeout).Returns(testTimeout); this._webTest.SetupGet(p => p.TestType).Returns(TestType.UrlPingTest); this._webTest.SetupGet(p => p.Status).Returns(testStatus); this._webTest.SetupGet(p => p.Frequency).Returns(testFrequency); this._webTest.SetupGet(p => p.ParseDependentRequests).Returns(parseDependentRequests); this._webTest.SetupGet(p => p.SuccessCriteria).Returns(successCriteria.Object); this._webTest.SetupGet(p => p.RetriesForWebTestFailure).Returns(retriesForWebTestFailure); this._webTest.SetupGet(p => p.TestLocations).Returns(testLocations); this._appInsights.SetupGet(p => p.ResourceGroup).Returns(resourceGroup); this._settings.SetupGet(p => p.ApplicationInsight).Returns(this._appInsights.Object); var resource = new GenericResourceExtended(location); var resourceResult = new ResourceCreateOrUpdateResult() { StatusCode = HttpStatusCode.OK, Resource = resource }; this._resourceOperations.Setup(p => p.CreateOrUpdateAsync(It.IsAny <string>(), It.IsAny <ResourceIdentity>(), It.IsAny <GenericResource>(), It.IsAny <CancellationToken>())).ReturnsAsync(resourceResult); this._resourceClient.Setup(p => p.Resources).Returns(this._resourceOperations.Object); var id = Guid.NewGuid(); var insightsResource = new ResourceBaseExtended(location) { Id = id.ToString(), Name = name }; var result = await this._service.CreateOrUpdateWebTestAsync(name, url, authType, accessToken, this._webTest.Object, this._resourceClient.Object, insightsResource).ConfigureAwait(false); result.Location.Should().BeEquivalentTo(location); }
private PingWebTestProperties CreatePingWebTestProperties(TestLocations testLocations, TestStatus testStatus, TestFrequency testFrequency, TestTimeout testTimeout, bool parseDependentRequests, RetriesForWebTestFailure retriesForWebTestFailure, int expectedHttpStatusCode = 200, AuthType authType = AuthType.None, string accessToken = null, string text = null) { var properties = new PingWebTestProperties() { Name = this._name, Description = string.Empty, TestStatus = testStatus, TestFrequency = testFrequency, TestTimeout = testTimeout, EnableRetriesForWebTestFailure = retriesForWebTestFailure, Locations = WebTestLocations.GetWebTestLocations(testLocations), Configuration = new PingWebTestConfiguration(this._name, this._url, (int)testTimeout, parseDependentRequests, expectedHttpStatusCode, authType, accessToken, text), SyntheticMonitorId = this._syntheticMonitorId, }; return(properties); }