public void ActivatedFeaturesAreGroupedCorrectly()
        {
            // Arrange

            // get 3 locations with each 4 same activated features
            Guid[] lIds = { TestLocations.Ids.Id001,
                            TestLocations.Ids.Id002,
                            TestLocations.Ids.Id003 };

            Guid[] fIds = { TestFeatureDefinitions.Ids.Id004,
                            TestFeatureDefinitions.Ids.Id001,
                            TestFeatureDefinitions.Ids.Id002,
                            TestFeatureDefinitions.Ids.Id003 };

            var locations = TestLocations.GetLocations(lIds, fIds);

            // Act

            var msg = new Core.Messages.Tasks.LocationsLoaded(Guid.NewGuid(), null, locations);

            // Assert
            // 4 different feature definitions
            var differentFeatureDefinitions = 4;

            Assert.Equal(differentFeatureDefinitions, msg.LoadedFeatures.Count());

            foreach (var featureDefinitionGroup in msg.LoadedFeatures)
            {
                var activeFeaturesPerDefinition = 3;
                Assert.Equal(activeFeaturesPerDefinition, featureDefinitionGroup.Count());
            }
        }
Example #2
0
        public FeatureDefinitionFactoryTests()
        {
            // get 3 locations with each 4 same activated features
            Guid[] lIds = { TestLocations.Ids.Id001,
                            TestLocations.Ids.Id002,
                            TestLocations.Ids.Id003 };

            Guid[] fIds = { TestFeatureDefinitions.Ids.Id004,
                            TestFeatureDefinitions.Ids.Id001,
                            TestFeatureDefinitions.Ids.Id002,
                            TestFeatureDefinitions.Ids.Id003 };

            var locations = TestLocations.GetLocations(lIds, fIds);

            Loaded3LocationsWithFirst4ActivatedFeaturesEach = new LocationsLoaded(Guid.NewGuid(), null, locations);
        }
        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);
        }
        /// <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);
        }
        /// <summary>
        /// Gets the list of <see cref="WebTestLocation"/> objects.
        /// </summary>
        /// <param name="locations"><see cref="TestLocations"/> value.</param>
        /// <returns>Returns the list of the <see cref="WebTestLocation"/> objects.</returns>
        public static IList <WebTestLocation> GetWebTestLocations(TestLocations locations)
        {
            if (locations == TestLocations.None)
            {
                throw new ArgumentException("Invalid test locations");
            }

            var results = new LazyList <WebTestLocation>();

            if (locations.HasFlag(TestLocations.UsIlChicago))
            {
                results.Add(UsIlChicago);
            }

            if (locations.HasFlag(TestLocations.UsCaSanJose))
            {
                results.Add(UsCaSanJose);
            }

            if (locations.HasFlag(TestLocations.UsTxSanAntonio))
            {
                results.Add(UsTxSanAntonio);
            }

            if (locations.HasFlag(TestLocations.UsVaAshburn))
            {
                results.Add(UsVaAshburn);
            }

            if (locations.HasFlag(TestLocations.UsFlMiami))
            {
                results.Add(UsFlMiami);
            }

            if (locations.HasFlag(TestLocations.SgSingapore))
            {
                results.Add(SgSingapore);
            }

            if (locations.HasFlag(TestLocations.SeStockholm))
            {
                results.Add(SeStockholm);
            }

            if (locations.HasFlag(TestLocations.RuMoscow))
            {
                results.Add(RuMoscow);
            }

            if (locations.HasFlag(TestLocations.NlAmsterdam))
            {
                results.Add(NlAmsterdam);
            }

            if (locations.HasFlag(TestLocations.JpKawaguchi))
            {
                results.Add(JpKawaguchi);
            }

            if (locations.HasFlag(TestLocations.IeDublin))
            {
                results.Add(IeDublin);
            }

            if (locations.HasFlag(TestLocations.HkHongKong))
            {
                results.Add(HkHongKong);
            }

            if (locations.HasFlag(TestLocations.FrParis))
            {
                results.Add(FrParis);
            }

            if (locations.HasFlag(TestLocations.ChZurich))
            {
                results.Add(ChZurich);
            }

            if (locations.HasFlag(TestLocations.BrSaoPaulo))
            {
                results.Add(BrSaoPaulo);
            }

            if (locations.HasFlag(TestLocations.AuSydney))
            {
                results.Add(AuSydney);
            }

            return(results);
        }
Example #7
0
        public void Given_Locations_GetWebTestLocations_ShouldReturn_Results(TestLocations locations)
        {
            var results = WebTestLocations.GetWebTestLocations(locations);

            results.Count.Should().Be(2);
        }