Esempio n. 1
0
        public void Create(string fileName)
        {
            ProfileFilePath = Path.Combine(ProfileDiscovery.GetProfilesDir(), fileName);
            string jsonContent = JsonConvert.SerializeObject(ProfileMapping, Formatting.Indented);

            File.WriteAllText(ProfileFilePath, jsonContent);
            profileWasCreated = true;
        }
        public Profile[] GetRemoteWebdriverProfiles()
        {
            ProfileDiscovery profileDiscovery = new ProfileDiscovery();

            Profile[] allProfiles = profileDiscovery.Discover();

            Profile[] result = allProfiles.Where(p => p.ProfileConfig.profile.canUseWithRemoteWebdriver).ToArray();
            return(result);
        }
Esempio n. 3
0
        public void ProfileDiscovery_Discover__Finds_new_and_user_defined_profiles()
        {
            var profileDiscovery = new ProfileDiscovery();

            using (var newProfile = new TemporaryTestProfile())
            {
                newProfile.ProfileMapping.profile.displayName = "New Profile";
                newProfile.Create("NewProfile.json");

                Profile[] listWithExpectedProfile = profileDiscovery.Discover();

                var discoveredProfile = listWithExpectedProfile.FirstOrDefault(p => p.FileName == "NewProfile.json");
                discoveredProfile.Should().NotBeNull("Discover must find new profile");
                discoveredProfile.HasErrors.Should().BeFalse("must not have errors");
            }
        }
Esempio n. 4
0
        public void ProfileDiscovery_Discover__Should_report_errors_inside_profile()
        {
            var profileDiscovery = new ProfileDiscovery();

            using (var newProfile = new TemporaryTestProfile())
            {
                newProfile.ProfileMapping.profile.displayName = "New Profile with Errors";
                newProfile.Create("NewErrorsProfile.json");
                // Corrupt JSON by appending text lines

                File.AppendAllText(newProfile.ProfileFilePath, "CORRUPTED }}}{{{");

                Profile[] listWithExpectedProfile = profileDiscovery.Discover();

                var discoveredProfile = listWithExpectedProfile.FirstOrDefault(p => p.FileName == "NewErrorsProfile.json");
                discoveredProfile.Should().NotBeNull("Discover must find new profile");
                discoveredProfile.HasErrors.Should().BeTrue("profile must have errors");
            }
        }