Пример #1
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            CustomPlugin cp = new CustomPlugin();

            cp.Initialize();

            GMailIntegration mail = new GMailIntegration(cp.GmailUsername, cp.GmailPassword);

            Console.WriteLine("New mails: {0}", mail.NewMessagesCount);

            for (int i = 0; i < mail.Entries.Count; ++i)
            {
                Console.WriteLine("{0} {1} {2}", mail.Entries[i].FromEmail, mail.Entries[i].Id, mail.Entries[i].Link);
            }

            try
            {
                ShowMessages showMessagesForm = new ShowMessages(mail.Entries);
                showMessagesForm.Show();
            }
            catch
            {
                ShowMessages showMessagesForm = new ShowMessages(false);
                showMessagesForm.Show();
            }

            Console.ReadLine();
        }
Пример #2
0
 private void LoadP()
 {
     foreach (var keyValuePair in PluginCompiler.Assemblys)
     {
         var temp = new CustomPlugin(keyValuePair.Key, keyValuePair.Value.GetName());
         PluginsList.Items.Add(temp);
         PluginsList.SetItemChecked(PluginsList.Items.Count - 1, LoadPluginSettings(temp.AssemblyName));
     }
 }
Пример #3
0
        public static void Run()
        {
            var userFeed = Feed.CreateRandom(
                "userFeed",
                FeedData.FromJson <User>("./JsonConfig/Configs/user-feed.json")
                );

            var httpFactory = ClientFactory.Create("http_factory",
                                                   initClient: (number, context) => Task.FromResult(new HttpClient {
                BaseAddress = new Uri(_customSettings.BaseUri)
            }));

            var getUser = Step.Create("get_user", httpFactory, userFeed, async context =>
            {
                var userId = context.FeedItem;
                var url    = $"users?id={userId}";

                var response = await context.Client.GetAsync(url, context.CancellationToken);
                var json     = await response.Content.ReadAsStringAsync();

                // parse JSON
                var users = JsonConvert.DeserializeObject <UserResponse[]>(json);

                return(users?.Length == 1
                    ? Response.Ok(users.First()) // we pass user object response to the next step
                    : Response.Fail("not found user"));
            });

            // this 'getPosts' will be executed only if 'getUser' finished OK.
            var getPosts = Step.Create("get_posts", httpFactory, async context =>
            {
                var user = context.GetPreviousStepResponse <UserResponse>();
                var url  = $"posts?userId={user.Id}";

                var response = await context.Client.GetAsync(url, context.CancellationToken);
                var json     = await response.Content.ReadAsStringAsync();

                // parse JSON
                var posts = JsonConvert.DeserializeObject <PostResponse[]>(json);

                return(posts?.Length > 0
                    ? Response.Ok()
                    : Response.Fail());
            });

            var scenario1 = ScenarioBuilder
                            .CreateScenario("rest_api", getUser, getPosts)
                            .WithInit(ScenarioInit);

            // the following scenario will be ignored since it is not included in target scenarios list of config.json
            var scenario2 = ScenarioBuilder
                            .CreateScenario("ignored", getUser, getPosts);

            // settings for worker plugins and reporting sinks are overriden in infra-config.json
            var pingPlugin = new PingPlugin();

            var customPlugin = new CustomPlugin(new CustomPluginSettings
            {
                Message = "Plugin is configured via constructor"
            });

            var influxDbReportingSink = new InfluxDBSink();

            var customReportingSink = new CustomReportingSink(new CustomReportingSinkSettings
            {
                Message = "Reporting sink is configured via constructor"
            });

            NBomberRunner
            .RegisterScenarios(scenario1, scenario2)
            .WithWorkerPlugins(pingPlugin, customPlugin)
            .WithReportingSinks(influxDbReportingSink, customReportingSink)
            .LoadConfig("./JsonConfig/Configs/config.json")
            .LoadInfraConfig("./JsonConfig/Configs/infra-config.json")
            .Run();
        }