public ConfiguredSettings releaseConfiguredSettings()
        {
            ConfiguredSettings temp = configuredSettings;

            configuredSettings = null;
            return(temp);
        }
예제 #2
0
        public MainWindow()
        {
            this.InitializeComponent();

            this.Settings.DataContext = ConfiguredSettings.GetDefaultSettings();
            this.Settings.DisableButtonsForEmulator();

            this.ProfileConfig.DataContext = ConfiguredSettings.GetDefaultSettings().Profiles.First();
            this.ProfileConfig.DisableButtonsForEmulator();
        }
예제 #3
0
        public MainWindow()
        {
            this.InitializeComponent();

            this.Settings.DataContext = ConfiguredSettings.GetDefaultSettings();
            this.Settings.DisableButtonsForEmulator();

            // Pick a random profile to show in tab - makes repeated testing more interesting
            this.ProfileConfig.SetDataContextAndHost(ConfiguredSettings.GetDefaultSettings().Profiles.OrderBy(p => Guid.NewGuid()).First(), null);
            this.ProfileConfig.DisableButtonsForEmulator();
        }
예제 #4
0
        /// <summary>
        /// Deploys the underlying threads to begin crawling the web
        /// </summary>
        /// <param name="query"></param>
        public void searchAndDeployAetherlings(string query)
        {
            ConfigurationContext inputContext = new ConfigurationContext(m_mainDisplayQueue, m_secondaryDisplayQueue, query);

            m_settings = inputContext.releaseConfiguredSettings();
            m_mainDisplayQueue.Enqueue(" ");
            m_mainDisplayQueue.Enqueue(ApplicationConstants.STARTED_THREADLING_DEPLOYMENT);
            m_mainDisplayQueue.Enqueue(" ");
            constructAndDeployAetherlings(m_settings);
            m_mainDisplayQueue.Enqueue(" ");
            m_mainDisplayQueue.Enqueue(ApplicationConstants.FINISHED_THREADLING_DEPLOYMENT);
        }
예제 #5
0
 public WebProcessor(ConfiguredSettings settings)
 {
     searchPhrase = settings.get(ConfiguredConstants.SEARCH_PHRASE_LBL).ToLower();
     usingFilter  = StringExtensionMethods.ToBoolean(settings.get(ConfiguredConstants.USE_FILTER_LBL));
     string[] terms = searchPhrase.Split(' ');
     searchTokens = new List <string>();
     for (int i = 0; i < terms.Length; i++)
     {
         searchTokens.Add(terms[i].ToLower());
     }
     searchTokens.Add(searchPhrase);
 }
        /// <summary>
        /// Constructs the output file
        /// </summary>
        /// <param name="configs"></param>
        public void constructOutputFile(ConfiguredSettings configs)
        {
            StringBuilder sb = new StringBuilder(ApplicationConstants.LESSER_DIVIDER + "\n");

            sb.Append(configs.ToString());
            sb.Append(ApplicationConstants.LESSER_DIVIDER + "\n");

            /*foreach (WebPage site in m_webpadeUrls.Values)
             * {
             *  sb.Append(site.ToString() + "\n");
             * }*/
            sb.Append(ApplicationConstants.LESSER_DIVIDER + "\n");
            //File.WriteAllText("AetherReport.txt", sb.ToString());
        }
예제 #7
0
        public void EnsureNoNullsInDefaultConfig()
        {
            var defSet = ConfiguredSettings.GetDefaultSettings();

            Assert.IsNotNull(defSet.ExtendedOutputEnabled, nameof(Settings.ExtendedOutputEnabled));

            // This is the only things that may be null (although empty is preferred)
            Assert.IsTrue(string.IsNullOrEmpty(defSet.ActiveProfileName), nameof(Settings.ActiveProfileName));

            Assert.IsNotNull(defSet.Profiles, nameof(Settings.Profiles));

            foreach (var profile in defSet.Profiles)
            {
                Assert.IsNotNull(profile.Name, "There's a profile without a name");
                Assert.IsNotNull(profile.ClassGrouping, $"{nameof(Profile.ClassGrouping)} in profile {profile.Name}");
                Assert.IsNotNull(profile.FallbackOutput, $"{nameof(Profile.FallbackOutput)} in profile {profile.Name}");
                Assert.IsNotNull(profile.SubPropertyOutput, $"{nameof(Profile.SubPropertyOutput)} in profile {profile.Name}");
                Assert.IsNotNull(profile.EnumMemberOutput, $"{nameof(Profile.EnumMemberOutput)} in profile {profile.Name}");

                Assert.IsNotNull(profile.Mappings, $"{nameof(Profile.Mappings)} in profile {profile.Name}");

                foreach (var mapping in profile.Mappings)
                {
                    Assert.IsNotNull(mapping.IfReadOnly, nameof(Mapping.IfReadOnly));
                    Assert.IsNotNull(mapping.NameContains, nameof(Mapping.NameContains));
                    Assert.IsNotNull(mapping.Output, nameof(Mapping.Output));
                    Assert.IsNotNull(mapping.Type, nameof(Mapping.Type));
                }

                Assert.IsNotNull(profile.ViewGeneration, $"{nameof(Profile.ViewGeneration)} in profile {profile.Name}");
                Assert.IsNotNull(profile.ViewGeneration.AllInSameProject, nameof(ViewGenerationSettings.AllInSameProject));
                Assert.IsNotNull(profile.ViewGeneration.CodePlaceholder, nameof(ViewGenerationSettings.CodePlaceholder));
                Assert.IsNotNull(profile.ViewGeneration.ViewModelDirectoryName, nameof(ViewGenerationSettings.ViewModelDirectoryName));
                Assert.IsNotNull(profile.ViewGeneration.ViewModelFileSuffix, nameof(ViewGenerationSettings.ViewModelFileSuffix));
                Assert.IsNotNull(profile.ViewGeneration.ViewModelProjectSuffix, nameof(ViewGenerationSettings.ViewModelProjectSuffix));
                Assert.IsNotNull(profile.ViewGeneration.XamlFileDirectoryName, nameof(ViewGenerationSettings.XamlFileDirectoryName));
                Assert.IsNotNull(profile.ViewGeneration.XamlFileSuffix, nameof(ViewGenerationSettings.XamlFileSuffix));
                Assert.IsNotNull(profile.ViewGeneration.XamlPlaceholder, nameof(ViewGenerationSettings.XamlPlaceholder));
                Assert.IsNotNull(profile.ViewGeneration.XamlProjectSuffix, nameof(ViewGenerationSettings.XamlProjectSuffix));

                Assert.IsNotNull(profile.Datacontext, $"{nameof(Profile.Datacontext)} in profile {profile.Name}");
                Assert.IsNotNull(profile.Datacontext.CodeBehindConstructorContent, nameof(DatacontextSettings.CodeBehindConstructorContent));
                Assert.IsNotNull(profile.Datacontext.CodeBehindPageContent, nameof(DatacontextSettings.CodeBehindPageContent));
                Assert.IsNotNull(profile.Datacontext.DefaultCodeBehindConstructor, nameof(DatacontextSettings.DefaultCodeBehindConstructor));
                Assert.IsNotNull(profile.Datacontext.XamlPageAttribute, nameof(DatacontextSettings.XamlPageAttribute));

                Assert.IsNotNull(profile.General, $"{nameof(Profile.General)} in profile {profile.Name}");
                Assert.IsNotNull(profile.General.AttemptAutomaticDocumentFormatting, $"{nameof(Profile.General.AttemptAutomaticDocumentFormatting)} in profile {profile.Name}");
            }
        }
예제 #8
0
        /// <summary>
        /// Constructs multiple search context instance
        /// </summary>
        /// <param name="contexts"></param>
        private void constructAndDeployAetherlings(ConfiguredSettings configs)
        {
            int deploys = Int32.Parse(configs.get(ConfiguredConstants.THREADLING_COUNT_LBL));

            m_threadlings = new Threadling[deploys];
            string[] faces = m_repository.getRandomFaces(deploys);
            for (int i = 0; i < m_threadlings.Length; i++)
            {
                string contextId = StringExtensionMethods.generateUsername(6);
                m_threadlings[i] = new Threadling(configs, m_mainDisplayQueue, m_secondaryDisplayQueue, faces[i]);
                m_threadlings[i].start();
                // threads must be space out to prevent intersecting traversals
                Thread.Sleep(ApplicationConstants.TEN_SECONDS_AS_MS);
            }
        }
예제 #9
0
        public async Task EnsureDefaultProfilesCanBeExportedAndImported()
        {
            var defSet = ConfiguredSettings.GetDefaultSettings();

            foreach (var profile in defSet.Profiles)
            {
                var json = profile.AsJson();

                var parser = new ApiAnalysis.SimpleJsonAnalyzer();

                var parserResults = await parser.AnalyzeJsonAsync(json, typeof(Profile));

                Assert.AreEqual(1, parserResults.Count);
                Assert.AreEqual(parser.MessageBuilder.AllGoodMessage, parserResults.First());
            }
        }
예제 #10
0
        public void EnsureValidXamlInDefaultConfig()
        {
            var defSet = ConfiguredSettings.GetDefaultSettings();

            foreach (var profile in defSet.Profiles)
            {
                Assert.IsTrue(profile.FallbackOutput.IsValidXamlOutput(), $"{nameof(Profile.FallbackOutput)} in profile {profile.Name}");
                Assert.IsTrue(profile.SubPropertyOutput.IsValidXamlOutput(), $"{nameof(Profile.SubPropertyOutput)} in profile {profile.Name}");
                Assert.IsTrue(profile.EnumMemberOutput.IsValidXamlOutput(), $"{nameof(Profile.EnumMemberOutput)} in profile {profile.Name}");

                foreach (var mapping in profile.Mappings)
                {
                    Assert.IsTrue(mapping.Output.IsValidXamlOutput(), $"Invalid output: {mapping.Output}");
                }
            }
        }
        public ConfigurationContext(ConcurrentQueue <string> mainDisplayQueue, ConcurrentQueue <string> secondaryDisplayQueue, string query) : base(mainDisplayQueue, secondaryDisplayQueue)
        {
            defaultEntrySearchEngines.Add("google", "https://www.google.com/search?q=");
            defaultEntrySearchEngines.Add("bing", "https://www.bing.com/search?q=");
            defaultEntrySearchEngines.Add("reddit", "https://www.reddit.com/search?q=");
            defaultEntrySearchEngines.Add("yahoo", "https://search.yahoo.com/search?p=");
            defaultEntrySearchEngines.Add("youtube", "https://www.youtube.com/results?search_query=");
            defaultEntrySearchEngines.Add("britannica", "https://www.britannica.com/search?query=");
            defaultEntrySearchEngines.Add("wikipedia", "https://en.wikipedia.org/w/index.php?search=");
            defaultEntrySearchEngines.Add("yahooAnswers", "https://answers.search.yahoo.com/search?p=");

            // this must be called after adding all elements to the map
            configuredSettings = constructConfiguredSettings(query);
            mainDisplayQueue.Enqueue(ApplicationConstants.GREATER_DIVIDER + "\r\n");
            mainDisplayQueue.Enqueue(configuredSettings.ToString() + "\r\n");
        }
예제 #12
0
        public SearchContext(ConfiguredSettings configs, ConcurrentQueue <string> mainQueue, ConcurrentQueue <string> secondaryQueue, string id) : base(mainQueue, secondaryQueue)
        {
            contextualId       = id;
            configuredSettings = configs;

            bool isUsingQueue = configs.get(ConfiguredConstants.USE_QUEUE_LBL).ToBoolean();

            if (sharedSearchContext == null)
            {
                sharedSearchContext = new SharedSearchContextState(isUsingQueue);
                sharedSearchContext.getContextInfo().addThreadId(contextualId);
            }
            else
            {
                sharedSearchContext.getContextInfo().addThreadId(contextualId);
            }
            maxPageSearchLimit = StringExtensionMethods.ToInteger(configs.get(ConfiguredConstants.SEARCH_LIMIT_LBL));
            traversalStyle     = TraversalStyle.getTraversalType(configs.get(ConfiguredConstants.TRAVERSAL_STYLE_LBL));
            currentUrl         = StringExtensionMethods.URLifyParseAddition(configs.get(ConfiguredConstants.ENTRY_POINT_LBL), configs.get(ConfiguredConstants.SEARCH_PHRASE_LBL));
        }
예제 #13
0
        public void SetUp()
        {
            InMemoryQueueManager.ClearAll();
            FubuTransport.Reset();

            theSettings = new ConfiguredSettings
            {
                Upstream = "memory://foo".ToUri(),
                Outbound = "memory://bar".ToUri()
            };

            theContainer = new Container(x => {
                x.For <ConfiguredSettings>().Use(theSettings);
            });

            theRuntime = FubuTransport.For <ConfiguredFubuRegistry>().StructureMap(theContainer)
                         .Bootstrap();

            theGraph = theContainer.GetInstance <ChannelGraph>();
        }
예제 #14
0
        public void EnsureValidXamlInDefaultConfig()
        {
            var defSet = ConfiguredSettings.GetDefaultSettings();

            foreach (var profile in defSet.Profiles)
            {
                Assert.IsTrue(profile.ViewGeneration.XamlPlaceholder.IsValidXamlOutput(), $"{nameof(Profile.ViewGeneration.XamlPlaceholder)} in profile '{profile.Name}' is not valid XAML.");

                Assert.IsTrue(profile.FallbackOutput.IsValidXamlOutput(), $"{nameof(Profile.FallbackOutput)} in profile '{profile.Name}' is not valid XAML.");
                Assert.IsTrue(profile.SubPropertyOutput.IsValidXamlOutput(), $"{nameof(Profile.SubPropertyOutput)} in profile '{profile.Name}' is not valid XAML.");
                Assert.IsTrue(profile.EnumMemberOutput.IsValidXamlOutput(), $"{nameof(Profile.EnumMemberOutput)} in profile '{profile.Name}' is not valid XAML.");

                foreach (var mapping in profile.Mappings)
                {
                    if (mapping.Output != Placeholder.NoOutput)
                    {
                        Assert.IsTrue(mapping.Output.IsValidXamlOutput(), $"Invalid output: {mapping.Output}");
                    }
                }
            }
        }
예제 #15
0
        public MainWindow()
        {
            this.InitializeComponent();

            this.Settings.DataContext = ConfiguredSettings.GetDefaultSettings();
            this.Settings.DisableButtonsForEmulator();
            this.Settings.SelectFirstProfileInList();

            if (System.Diagnostics.Debugger.IsAttached)
            {
                // Pick a random profile to show in tab - makes repeated manual testing more interesting
                this.ProfileConfig.SetDataContextAndHost(ConfiguredSettings.GetDefaultSettings().Profiles.OrderBy(p => Guid.NewGuid()).First(), null);
            }
            else
            {
                // Always use the same in automated testing so can compare visuals
                this.ProfileConfig.SetDataContextAndHost(ConfiguredSettings.GetDefaultSettings().Profiles.First(), null);
            }

            this.ProfileConfig.DisableButtonsForEmulator();
        }
        public void EnsureOnlyValidPlaceholdersInDefaultConfig()
        {
            var defSet = ConfiguredSettings.GetDefaultSettings();
            var apv    = new AllowedPlaceholderValidator();

            foreach (var profile in defSet.Profiles)
            {
                var checkResult = apv.ContainsOnlyValidPlaceholders(typeof(Profile), nameof(Profile.FallbackOutput), profile.FallbackOutput);

                if (!checkResult.isValid)
                {
                    Assert.Fail($"{nameof(Profile.FallbackOutput)} in profile '{profile.Name}' contained invalid placeholder(s): {string.Join(", ", checkResult.invalidPlaceholders)}");
                }

                checkResult = apv.ContainsOnlyValidPlaceholders(typeof(Profile), nameof(Profile.SubPropertyOutput), profile.SubPropertyOutput);

                if (!checkResult.isValid)
                {
                    Assert.Fail($"{nameof(Profile.SubPropertyOutput)} in profile '{profile.Name}' contained invalid placeholder(s): {string.Join(", ", checkResult.invalidPlaceholders)}");
                }

                checkResult = apv.ContainsOnlyValidPlaceholders(typeof(Profile), nameof(Profile.EnumMemberOutput), profile.EnumMemberOutput);

                if (!checkResult.isValid)
                {
                    Assert.Fail($"{nameof(Profile.EnumMemberOutput)} in profile '{profile.Name}' contained invalid placeholder(s): {string.Join(", ", checkResult.invalidPlaceholders)}");
                }

                foreach (var mapping in profile.Mappings)
                {
                    checkResult = apv.ContainsOnlyValidPlaceholders(typeof(Mapping), nameof(Mapping.Output), mapping.Output);

                    if (!checkResult.isValid)
                    {
                        Assert.Fail($"Mapping output in profile '{profile.Name}' contained invalid placeholder(s): {string.Join(", ", checkResult.invalidPlaceholders)}");
                    }
                }
            }
        }
        public void EnsureNoNullsInDefaultConfig()
        {
            var defSet = ConfiguredSettings.GetDefaultSettings();

            Assert.IsNotNull(defSet.ExtendedOutputEnabled, nameof(Settings.ExtendedOutputEnabled));

            Assert.IsFalse(string.IsNullOrEmpty(defSet.FallBackProfileName), nameof(Settings.FallBackProfileName));

            Assert.AreEqual(3, defSet.ActiveProfileNames.Count, "Incorrect number of active profiles configured by default.");

            Assert.IsFalse(string.IsNullOrEmpty(defSet.ActiveProfileNames[ProjectType.Uwp.GetDescription()]), "Active UWP profile is not set.");
            Assert.IsFalse(string.IsNullOrEmpty(defSet.ActiveProfileNames[ProjectType.Wpf.GetDescription()]), "Active WPF profile is not set.");
            Assert.IsFalse(string.IsNullOrEmpty(defSet.ActiveProfileNames[ProjectType.XamarinForms.GetDescription()]), "Active Xamarin.Forms profile is not set.");

            Assert.IsNotNull(defSet.Profiles, nameof(Settings.Profiles));

            foreach (var profile in defSet.Profiles)
            {
                Assert.IsNotNull(profile.Name, "There's a profile without a name");
                Assert.IsNotNull(profile.ClassGrouping, $"{nameof(Profile.ClassGrouping)} in profile {profile.Name}");
                Assert.IsNotNull(profile.FallbackOutput, $"{nameof(Profile.FallbackOutput)} in profile {profile.Name}");
                Assert.IsNotNull(profile.SubPropertyOutput, $"{nameof(Profile.SubPropertyOutput)} in profile {profile.Name}");
                Assert.IsNotNull(profile.EnumMemberOutput, $"{nameof(Profile.EnumMemberOutput)} in profile {profile.Name}");

                Assert.IsNotNull(profile.Mappings, $"{nameof(Profile.Mappings)} in profile {profile.Name}");

                foreach (var mapping in profile.Mappings)
                {
                    Assert.IsNotNull(mapping.IfReadOnly, nameof(Mapping.IfReadOnly));
                    Assert.IsNotNull(mapping.NameContains, nameof(Mapping.NameContains));
                    Assert.IsNotNull(mapping.Output, nameof(Mapping.Output));
                    Assert.IsNotNull(mapping.Type, nameof(Mapping.Type));
                }

                Assert.IsNotNull(profile.AttemptAutomaticDocumentFormatting, $"{nameof(Profile.AttemptAutomaticDocumentFormatting)} in profile {profile.Name}");
            }
        }
예제 #18
0
        public static Settings GetSettings()
        {
            var configuredSettings = new ConfiguredSettings(ServiceProvider);

            return(configuredSettings.ActualSettings);
        }
예제 #19
0
        public void EnsureOnlyValidPlaceholdersInDefaultConfig()
        {
            var defSet = ConfiguredSettings.GetDefaultSettings();
            var apv    = new AllowedPlaceholderValidator();

            foreach (var profile in defSet.Profiles)
            {
                var checkResult = apv.ContainsOnlyValidPlaceholders(typeof(Profile), nameof(Profile.FallbackOutput), profile.FallbackOutput);

                if (!checkResult.isValid)
                {
                    Assert.Fail($"{nameof(Profile.FallbackOutput)} in profile '{profile.Name}' contained invalid placeholder(s): {string.Join(", ", checkResult.invalidPlaceholders)}");
                }

                checkResult = apv.ContainsOnlyValidPlaceholders(typeof(Profile), nameof(Profile.SubPropertyOutput), profile.SubPropertyOutput);

                if (!checkResult.isValid)
                {
                    Assert.Fail($"{nameof(Profile.SubPropertyOutput)} in profile '{profile.Name}' contained invalid placeholder(s): {string.Join(", ", checkResult.invalidPlaceholders)}");
                }

                checkResult = apv.ContainsOnlyValidPlaceholders(typeof(Profile), nameof(Profile.EnumMemberOutput), profile.EnumMemberOutput);

                if (!checkResult.isValid)
                {
                    Assert.Fail($"{nameof(Profile.EnumMemberOutput)} in profile '{profile.Name}' contained invalid placeholder(s): {string.Join(", ", checkResult.invalidPlaceholders)}");
                }

                checkResult = apv.ContainsOnlyValidPlaceholders(typeof(ViewGenerationSettings), nameof(ViewGenerationSettings.CodePlaceholder), profile.ViewGeneration.CodePlaceholder);

                if (!checkResult.isValid)
                {
                    Assert.Fail($"{nameof(ViewGenerationSettings)}.{nameof(ViewGenerationSettings.CodePlaceholder)} in profile '{profile.Name}' contained invalid placeholder(s): {string.Join(", ", checkResult.invalidPlaceholders)}");
                }

                checkResult = apv.ContainsOnlyValidPlaceholders(typeof(ViewGenerationSettings), nameof(ViewGenerationSettings.XamlPlaceholder), profile.ViewGeneration.XamlPlaceholder);

                if (!checkResult.isValid)
                {
                    Assert.Fail($"{nameof(ViewGenerationSettings)}.{nameof(ViewGenerationSettings.XamlPlaceholder)} in profile '{profile.Name}' contained invalid placeholder(s): {string.Join(", ", checkResult.invalidPlaceholders)}");
                }

                checkResult = apv.ContainsOnlyValidPlaceholders(typeof(DatacontextSettings), nameof(DatacontextSettings.XamlPageAttribute), profile.Datacontext.XamlPageAttribute);

                if (!checkResult.isValid)
                {
                    Assert.Fail($"{nameof(DatacontextSettings)}.{nameof(DatacontextSettings.XamlPageAttribute)} in profile '{profile.Name}' contained invalid placeholder(s): {string.Join(", ", checkResult.invalidPlaceholders)}");
                }

                checkResult = apv.ContainsOnlyValidPlaceholders(typeof(DatacontextSettings), nameof(DatacontextSettings.CodeBehindPageContent), profile.Datacontext.CodeBehindPageContent);

                if (!checkResult.isValid)
                {
                    Assert.Fail($"{nameof(DatacontextSettings)}.{nameof(DatacontextSettings.CodeBehindPageContent)} in profile '{profile.Name}' contained invalid placeholder(s): {string.Join(", ", checkResult.invalidPlaceholders)}");
                }

                checkResult = apv.ContainsOnlyValidPlaceholders(typeof(DatacontextSettings), nameof(DatacontextSettings.CodeBehindConstructorContent), profile.Datacontext.CodeBehindConstructorContent);

                if (!checkResult.isValid)
                {
                    Assert.Fail($"{nameof(DatacontextSettings)}.{nameof(DatacontextSettings.CodeBehindConstructorContent)} in profile '{profile.Name}' contained invalid placeholder(s): {string.Join(", ", checkResult.invalidPlaceholders)}");
                }

                checkResult = apv.ContainsOnlyValidPlaceholders(typeof(DatacontextSettings), nameof(DatacontextSettings.DefaultCodeBehindConstructor), profile.Datacontext.DefaultCodeBehindConstructor);

                if (!checkResult.isValid)
                {
                    Assert.Fail($"{nameof(DatacontextSettings)}.{nameof(DatacontextSettings.DefaultCodeBehindConstructor)} in profile '{profile.Name}' contained invalid placeholder(s): {string.Join(", ", checkResult.invalidPlaceholders)}");
                }

                foreach (var mapping in profile.Mappings)
                {
                    checkResult = apv.ContainsOnlyValidPlaceholders(typeof(Mapping), nameof(Mapping.Output), mapping.Output);

                    if (!checkResult.isValid)
                    {
                        Assert.Fail($"Mapping output in profile '{profile.Name}' contained invalid placeholder(s): {string.Join(", ", checkResult.invalidPlaceholders)}");
                    }
                }
            }
        }