Exemplo n.º 1
0
        public static void AddKeys()
        {
            ArgsBuilder builder = null;
            string      result  = null;

            Arrange(() =>
            {
                builder = ArgsBuilder.By("-", "=");
            });

            When("added two keys", () =>
            {
                var condition = true;
                string[] keys = null;

                Act(() =>
                {
                    result = builder.AddKeys(keys, condition);
                });

                And("a condition is true", () =>
                {
                    condition = true;

                    And("keys are provided", () =>
                    {
                        keys = new[] { "key1", "key2" };

                        Should("provide the provided keys", () =>
                        {
                            Assert.That(result, Is.EqualTo("-key1 -key2"));
                        });
                    });

                    And("keys is null", () =>
                    {
                        keys = null;

                        Should("provide an empty string", () =>
                        {
                            Assert.That(result, Is.Empty);
                        });
                    });
                });

                And("a condition is false", () =>
                {
                    condition = false;

                    Should("provide an empty string", () =>
                    {
                        Assert.That(result, Is.Empty);
                    });
                });
            });
        }
Exemplo n.º 2
0
        public async Task <RegistratedUser> GetById(int Id)
        {
            var args = new ArgsBuilder()
                       .Add(nameof(Id), Id.ToString())
                       .Build();

            var result = await _webApi.Query <RegistratedUser>(Defines.UserServices.GetUserByIdUrl, args);

            return(result.Responce);
        }
Exemplo n.º 3
0
        public async Task <Bet> GetById(int id)
        {
            var args = new ArgsBuilder()
                       .Add(nameof(id), id.ToString())
                       .Build();

            var result = await _webApi.Query <Bet>(Defines.BetService.GetBetById, args);

            return(result.Responce);
        }
Exemplo n.º 4
0
        public async Task <JustResult> Delete(int id)
        {
            var args = new ArgsBuilder()
                       .Add(nameof(id), id.ToString())
                       .Build();

            var result = await _webApi.Query <JustResult>(Defines.EventServices.CreateEvent, args);

            return(result.Responce);
        }
Exemplo n.º 5
0
        public async Task <RegistratedUser> SignIn(string login, string password)
        {
            var args = new ArgsBuilder()
                       .Add(nameof(login), login)
                       .Add(nameof(password), password)
                       .Build();

            var result = await _webApi.Query <RegistratedUser>(Defines.UserServices.SignInUserUrl, args);

            return(result.Responce);
        }
Exemplo n.º 6
0
        public async Task <EventInfo> Create(CreatingEventInfo ev)
        {
            var args = new ArgsBuilder()
                       .Add(nameof(ev.Name), ev.Name)
                       .Add(nameof(ev.DataTime), ev.DataTime.ToString())
                       .Add(nameof(ev.Teams), _serializer.Serialize(ev.Teams))
                       .Build();

            var result = await _webApi.Query <EventInfo>(Defines.EventServices.CreateEvent, args);

            return(result.Responce);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Implements Class#allocate feature.
        /// </summary>
        public void BuildObjectAllocation(MetaObjectBuilder /*!*/ metaBuilder, CallArguments /*!*/ args, string /*!*/ methodName)
        {
            // check for empty arguments (handles splat correctly):
            var argsBuilder = new ArgsBuilder(0, 0, 0, false);

            argsBuilder.AddCallArguments(metaBuilder, args);

            if (!metaBuilder.Error)
            {
                metaBuilder.Result = MakeAllocatorCall(args, () => Ast.Constant(Name));
            }
        }
Exemplo n.º 8
0
        public async Task <MakeBetResult> MakeBet(int userId, int betResultId, int summa)
        {
            var args = new ArgsBuilder()
                       .Add(nameof(userId), userId.ToString())
                       .Add(nameof(betResultId), betResultId.ToString())
                       .Add(nameof(summa), summa.ToString())
                       .Build();

            var result = await _webApi.Query <MakeBetResult>(Defines.BetService.MakeBet, args);

            return(result.Responce);
        }
Exemplo n.º 9
0
        public static void AddPaths1()
        {
            ArgsBuilder builder = null;
            string      result  = null;

            Arrange(() =>
            {
                builder = ArgsBuilder.By("-", "=");
            });

            When("added paths", () =>
            {
                var condition = true;
                var paths     = new[] { "path1", "path2" };

                Act(() =>
                {
                    result = builder.AddPaths(paths, condition);
                });

                And("a condition is true", () =>
                {
                    condition = true;

                    Should("provide the paths", () =>
                    {
                        Assert.That(result, Is.EqualTo("\"path1\" \"path2\""));
                    });

                    And("the paths is null", () =>
                    {
                        paths = null;

                        Should("provide an empty string", () =>
                        {
                            Assert.That(result, Is.Empty);
                        });
                    });
                });

                And("a condition is false", () =>
                {
                    condition = false;

                    Should("provide an empty string", () =>
                    {
                        Assert.That(result, Is.Empty);
                    });
                });
            });
        }
Exemplo n.º 10
0
        public async Task <RegistratedUser> SignUp(RegisterInfoUser user)
        {
            var args = new ArgsBuilder()
                       .Add(nameof(user.Login), user.Login)
                       .Add(nameof(user.Password), user.Login)
                       .Add(nameof(user.Name), user.Login)
                       .Add(nameof(user.Age), user.Age.ToString())
                       .Add(nameof(user.Score), user.Age.ToString())
                       .Build();

            var result = await _webApi.Query <RegistratedUser>(Defines.UserServices.SignUpUserUrl, args);

            return(result.Responce);
        }
Exemplo n.º 11
0
        private void UpdateComplete(bool update)
        {
            if (!update)
            {
                return;
            }
            ServicePointManager.ServerCertificateValidationCallback =
                (sender, cert, chain, sslPolicyErrors) => true;//ignore ssl Certificate

            //Current process file address
            string cur_process = Process.GetCurrentProcess().MainModule.FileName;

            //Get uri bind Download information Server address
            Uri uri = new Uri(Server);

            //Parameter for passing to DownloadForm
            ArgsBuilder args = new ArgsBuilder();

            //For start process application information
            ProcessStartInfo pInfo = new ProcessStartInfo(DownLoadFormPath);

            //Parameter[0] = DownLoadInfoPath
            args.Add(DownLoadInfoPath);

            //Parameter[1] = current process name
            args.Add(Path.GetFileName(cur_process));
            pInfo.Arguments = args.ToString();
            if (!Directory.Exists(Path.GetDirectoryName(DownLoadInfoPath)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(DownLoadInfoPath));
            }
            try
            {
                XmlDocument doc = new XmlDocument();
                doc.Load(uri.AbsoluteUri);
                doc.Save(DownLoadInfoPath);

                using (Process p = new Process())
                {
                    p.StartInfo = pInfo;
                    p.Start();
                }
                Application.Exit();
            }
            catch
            {
                MessageBox.Show("網路異常");
            }
        }
Exemplo n.º 12
0
        public static RuleGenerator /*!*/ GetException()
        {
            return(new RuleGenerator((metaBuilder, args, name) => {
                Debug.Assert(args.Target is Exception);

                // 1 optional parameter (exceptionArg):
                var argsBuilder = new ArgsBuilder(0, 0, 1, false);
                argsBuilder.AddCallArguments(metaBuilder, args);

                if (!metaBuilder.Error)
                {
                    if (argsBuilder.ExplicitArgumentCount == 0)
                    {
                        metaBuilder.Result = args.TargetExpression;
                    }
                    else
                    {
                        RubyClass cls = args.RubyContext.GetClassOf(args.Target);
                        var classExpression = AstUtils.Constant(cls);
                        args.SetTarget(classExpression, cls);

                        ParameterExpression messageVariable = null;

                        // RubyOps.MarkException(new <exception-type>(GetClrMessage(<class>, #message = <message>)))
                        if (cls.BuildAllocatorCall(metaBuilder, args, () =>
                                                   Ast.Call(null, new Func <RubyClass, object, string>(GetClrMessage).Method,
                                                            classExpression,
                                                            Ast.Assign(messageVariable = metaBuilder.GetTemporary(typeof(object), "#message"), AstUtils.Box(argsBuilder[0]))
                                                            )
                                                   ))
                        {
                            // ReinitializeException(<result>, #message)
                            metaBuilder.Result = Ast.Call(null, new Func <RubyContext, Exception, object, Exception>(ReinitializeException).Method,
                                                          AstUtils.Convert(args.MetaContext.Expression, typeof(RubyContext)),
                                                          metaBuilder.Result,
                                                          messageVariable ?? AstUtils.Box(argsBuilder[0])
                                                          );
                        }
                        else
                        {
                            metaBuilder.SetError(Methods.MakeAllocatorUndefinedError.OpCall(Ast.Convert(args.TargetExpression, typeof(RubyClass))));
                        }
                    }
                }
            }));
        }
Exemplo n.º 13
0
        public void TestPlanExecution()
        {
            const string path = @"%jmeter%\bin\jmeter.bat";

            var argsBuilder = new ArgsBuilder()
                .NonGui()
                .LogTo(@"LoopTestPlan.jtl")
                .WithTestPlan(@"LoopTestPlan.jmx")
                .WithFailedAssersionReport();
            
            var jmeterRunner = new JmeterRunner(path,argsBuilder);
            jmeterRunner.Start();
            var logPath = @"LoopTestPlan.jtl";
            jmeterRunner.CreateSummaryReport(PluginTypeCsv.AggregateReport, @"LoopTestPlan.csv", logPath);
            var errorsRate = jmeterRunner.GetErrorsRate(logPath);
            Assert.AreEqual(errorsRate, 83.33d);
            var totalDuration = jmeterRunner.GetTotalDuration(logPath);
            Assert.AreNotEqual(totalDuration,0);
        }
Exemplo n.º 14
0
        public static void By()
        {
            ArgsBuilder builder = null;
            string      result  = null;

            Arrange(() =>
            {
                builder = ArgsBuilder.By("-", "=", ";", "\"", " ");
            });

            When("added two paths and a key with a value", () =>
            {
                var condition = true;

                Act(() =>
                {
                    result = builder
                             .AddPaths("key1", new[] { "path1", "path2" }, false, condition)
                             .AddArgument("key2", "value2", condition)
                             .ToString();
                });

                And("a condition is true", () =>
                {
                    condition = true;

                    Should("provide arguments with provided paths and the key with the value", () =>
                    {
                        Assert.That(result, Is.EqualTo("-key1=\"path1\";\"path2\" -key2=value2"));
                    });
                });

                And("a condition is false", () =>
                {
                    condition = false;

                    Should("provide an empty string", () =>
                    {
                        Assert.That(result, Is.Empty);
                    });
                });
            });
        }
Exemplo n.º 15
0
        public static void ToString1()
        {
            ArgsBuilder builder = null;
            string      result  = null;

            Arrange(() =>
            {
                builder = ArgsBuilder.By("-", "=");
            });

            When("the builder is empty", () =>
            {
                Act(() =>
                {
                    builder.ToString();
                    builder.ToString();
                    result = builder.ToString();
                });

                Should("provide an empty string", () =>
                {
                    Assert.That(result, Is.Empty);
                });

                And("a value is added", () =>
                {
                    Act(() =>
                    {
                        builder.AddValue("value1");

                        builder.ToString();
                        builder.ToString();
                        result = builder.ToString();
                    });

                    Should("provide the added value", () =>
                    {
                        Assert.That(result, Is.EqualTo("value1"));
                    });
                });
            });
        }
Exemplo n.º 16
0
        public static void OperatorString()
        {
            ArgsBuilder builder = null;
            string      result  = null;

            When("the builder is null", () =>
            {
                Act(() =>
                {
                    builder = null;

                    result = builder;
                });

                Should("provide null", () =>
                {
                    Assert.That(result, Is.Null);
                });

                And("the builder is not null and a value is added", () =>
                {
                    Act(() =>
                    {
                        builder = ArgsBuilder.By("-", "=");
                        builder.AddValue("value1");

                        result = builder;
                    });

                    Should("provide the added value", () =>
                    {
                        Assert.That(result, Is.EqualTo("value1"));
                    });
                });
            });
        }
Exemplo n.º 17
0
        public static void AddValue()
        {
            ArgsBuilder builder = null;
            string      result  = null;

            Arrange(() =>
            {
                builder = ArgsBuilder.By("-", "=");
            });

            When("added a value", () =>
            {
                var condition = true;
                string value  = null;

                Act(() =>
                {
                    result = builder.AddValue(value, condition);
                });

                And("a condition is true", () =>
                {
                    condition = true;

                    And("the value is provided", () =>
                    {
                        value = "value1";

                        Should("provide the provided value", () =>
                        {
                            Assert.That(result, Is.EqualTo(value));
                        });
                    });

                    And("the value is an empty string", () =>
                    {
                        value = string.Empty;

                        Should("provide an empty string", () =>
                        {
                            Assert.That(result, Is.Empty);
                        });
                    });

                    And("the value is null", () =>
                    {
                        value = null;

                        Should("provide an empty string", () =>
                        {
                            Assert.That(result, Is.Empty);
                        });
                    });
                });

                And("a condition is false", () =>
                {
                    condition = false;

                    Should("provide an empty string", () =>
                    {
                        Assert.That(result, Is.Empty);
                    });
                });
            });
        }
Exemplo n.º 18
0
        static void Main(string[] args)
        {
            Options options = ArgsBuilder.Build <Options>(args);

            Console.ReadLine();
        }
Exemplo n.º 19
0
        public static void AddValues()
        {
            ArgsBuilder builder = null;
            string      result  = null;

            Arrange(() =>
            {
                builder = ArgsBuilder.By("-", "=");
            });

            When("added two values", () =>
            {
                var condition   = true;
                string[] values = null;

                Act(() =>
                {
                    result = builder.AddValues(values, condition);
                });

                And("a condition is true", () =>
                {
                    condition = true;

                    And("the values has null value", () =>
                    {
                        values = new[] { "value1", null };

                        Should("provide only non-null values", () =>
                        {
                            Assert.That(result, Is.EqualTo("value1"));
                        });
                    });

                    And("values are provided", () =>
                    {
                        values = new[] { "value1", "value2" };

                        Should("provide arguments with the provided values", () =>
                        {
                            Assert.That(result, Is.EqualTo("value1 value2"));
                        });
                    });

                    And("values is null", () =>
                    {
                        values = null;

                        Should("provide an empty string", () =>
                        {
                            Assert.That(result, Is.Empty);
                        });
                    });
                });

                And("a condition is false", () =>
                {
                    condition = false;

                    Should("provide an empty string", () =>
                    {
                        Assert.That(result, Is.Empty);
                    });
                });
            });
        }
Exemplo n.º 20
0
        public static void AddArguments()
        {
            ArgsBuilder builder = null;
            string      result  = null;

            Arrange(() =>
            {
                builder = ArgsBuilder.By("-", "=");
            });

            When("added arguments", () =>
            {
                var condition     = true;
                string key        = null;
                string[] values   = null;
                var multipleTimes = false;

                Act(() =>
                {
                    result = builder.AddArguments(key, values, multipleTimes, condition);
                });

                And("a condition is true", () =>
                {
                    condition = true;

                    And("the key is provided", () =>
                    {
                        key = "key1";

                        And("the values has null value", () =>
                        {
                            values = new[] { "value1", null };

                            Should("provide only non-null values", () =>
                            {
                                Assert.That(result, Is.EqualTo("-key1=value1"));
                            });
                        });

                        And("the values are provided", () =>
                        {
                            values = new[] { "value1", "value2" };

                            Should("provide the argument with the provided key and values", () =>
                            {
                                Assert.That(result, Is.EqualTo("-key1=value1;value2"));
                            });

                            And("the key with values should be added multiple times", () =>
                            {
                                multipleTimes = true;

                                Should("provide the argument with the provided values with teir own keys", () =>
                                {
                                    Assert.That(result, Is.EqualTo("-key1=value1 -key1=value2"));
                                });
                            });
                        });

                        And("the values is null", () =>
                        {
                            values = null;

                            Should("provide an empty string", () =>
                            {
                                Assert.That(result, Is.Empty);
                            });
                        });
                    });

                    And("the key is an empty string", () =>
                    {
                        key = string.Empty;

                        Should("provide an empty string", () =>
                        {
                            Assert.That(result, Is.Empty);
                        });
                    });

                    And("the key is null", () =>
                    {
                        key = null;

                        Should("provide an empty string", () =>
                        {
                            Assert.That(result, Is.Empty);
                        });
                    });
                });

                And("a condition is false", () =>
                {
                    condition = false;

                    Should("provide an empty string", () =>
                    {
                        Assert.That(result, Is.Empty);
                    });
                });
            });
        }
Exemplo n.º 21
0
 public void ArgumentParsing()
 {
     var argsBuilder = new ArgsBuilder();
     var build = argsBuilder.NonGui().LogTo(@"c:\tom\a a").SetPropertiesFile(@"c:\a.txt").WithTestPlan(@"a.txt").Build();
     Assert.AreEqual(build, "-n -l \"c:\\tom\\a a\" -p \"c:\\a.txt\" -t \"a.txt\"");
 }
Exemplo n.º 22
0
        public static void AddKey()
        {
            ArgsBuilder builder = null;
            string      result  = null;

            Arrange(() =>
            {
                builder = ArgsBuilder.By("-", "=");
            });

            When("added a key", () =>
            {
                var condition = true;
                string key    = null;

                Act(() =>
                {
                    result = builder.AddKey(key, condition);
                });

                And("a condition is true", () =>
                {
                    condition = true;

                    And("the key is provided", () =>
                    {
                        key = "key1";

                        Should("provide the provided key", () =>
                        {
                            Assert.That(result, Is.EqualTo("-key1"));
                        });
                    });

                    And("the key is an empty string", () =>
                    {
                        key = string.Empty;

                        Should("provide an empty string", () =>
                        {
                            Assert.That(result, Is.Empty);
                        });
                    });

                    And("the key is null", () =>
                    {
                        key = null;

                        Should("provide an empty string", () =>
                        {
                            Assert.That(result, Is.Empty);
                        });
                    });
                });

                And("a condition is false", () =>
                {
                    condition = false;

                    Should("provide an empty string", () =>
                    {
                        Assert.That(result, Is.Empty);
                    });
                });
            });
        }
Exemplo n.º 23
0
        public static void AddPaths2()
        {
            ArgsBuilder builder = null;
            string      result  = null;

            Arrange(() =>
            {
                builder = ArgsBuilder.By("-", "=");
            });

            When("added paths", () =>
            {
                var condition     = true;
                string key        = null;
                string[] paths    = null;
                var multipleTimes = false;

                Act(() =>
                {
                    result = builder.AddPaths(key, paths, multipleTimes, condition);
                });

                And("a condition is true", () =>
                {
                    condition = true;

                    And("the key is provided", () =>
                    {
                        key = "key1";

                        And("the paths are provided", () =>
                        {
                            paths = new[] { "path1", "path2" };

                            Should("provide the key with the provided paths", () =>
                            {
                                Assert.That(result, Is.EqualTo("-key1=\"path1\";\"path2\""));
                            });
                        });

                        And("the key with paths should be added multiple times", () =>
                        {
                            multipleTimes = true;

                            Should("provide the key with the provided paths with teir own keys", () =>
                            {
                                Assert.That(result, Is.EqualTo("-key1=\"path1\" -key1=\"path2\""));
                            });
                        });

                        And("the paths is null", () =>
                        {
                            paths = null;

                            Should("provide an empty string", () =>
                            {
                                Assert.That(result, Is.Empty);
                            });
                        });

                        And("the key is an empty string", () =>
                        {
                            key = string.Empty;

                            Should("provide an empty string", () =>
                            {
                                Assert.That(result, Is.Empty);
                            });
                        });

                        And("the key is null", () =>
                        {
                            key = null;

                            Should("provide an empty string", () =>
                            {
                                Assert.That(result, Is.Empty);
                            });
                        });
                    });
                });

                And("a condition is false", () =>
                {
                    condition = false;

                    Should("provide an empty string", () =>
                    {
                        Assert.That(result, Is.Empty);
                    });
                });
            });
        }