Esempio n. 1
0
        public void Flags()
        {
            ap.Parse(new[] { "-a", "/b", "c" });

            Assert.True(ap.CheckFlag("a"));
            Assert.True(ap.CheckFlag("b"));
            Assert.False(ap.CheckFlag("c"));
        }
Esempio n. 2
0
        private PacketContent UpdatePasswordAction(SerializedInfo request, Token token)
        {
            List <string> argList = ArgumentsParser.Parse(request.Content);

            return(PasswordService.UpdatePassword(request.ClientInfo.Session, argList[0], argList[1], argList[2])
                   .ToPacketContent());
        }
Esempio n. 3
0
        private PacketContent saveLogAction(SerializedInfo request, Token token)
        {
            List <string> argList = ArgumentsParser.Parse(request.Content);

            return(LogService.SaveLog(request.ClientInfo.Session, argList[0], DateTime.Parse(argList[1]), argList[2], Guid.Parse(argList[3]))
                   .ToPacketContent());
        }
Esempio n. 4
0
        private PacketContent GetLostCommandsAction(SerializedInfo request, Token token)
        {
            List <string> argList = ArgumentsParser.Parse(request.Content);

            return(CommandManager.Default.GetLostCommands(request.ClientInfo.Session, int.Parse(argList[0]), int.Parse(argList[1]))
                   .ToPacketContent());
        }
Esempio n. 5
0
        private PacketContent GetAccountBankReferenceDataAction(SerializedInfo request, Token token)
        {
            List <string> argList = ArgumentsParser.Parse(request.Content);

            return(AccountManager.Default.GetAccountBankReferenceData(argList[0], argList[1])
                   .ToPacketContent());
        }
Esempio n. 6
0
        private PacketContent GetNewsList2Action(SerializedInfo request, Token token)
        {
            List <string> argList = ArgumentsParser.Parse(request.Content);

            return(NewsService.GetNewsList2(argList[0], argList[1], DateTime.Parse(argList[2]))
                   .ToPacketContent());
        }
Esempio n. 7
0
        private PacketContent AccountSummaryForJava2Action(SerializedInfo request, Token token)
        {
            var args = ArgumentsParser.Parse(request.Content);

            return(StatementService.AccountSummaryForJava2(request.ClientInfo.Session, args[0], args[1], args[2], args[3])
                   .ToPacketContent());
        }
Esempio n. 8
0
        private PacketContent ModifyTelephoneIdentificationCodeAction(SerializedInfo request, Token token)
        {
            var args = ArgumentsParser.Parse(request.Content);

            return(PasswordService.ModifyTelephoneIdentificationCode(request.ClientInfo.Session, Guid.Parse(args[0]), args[1], args[2])
                   .ToPacketContent());
        }
Esempio n. 9
0
        private PacketContent ChangeMarginPinAction(SerializedInfo request, Token token)
        {
            var args = ArgumentsParser.Parse(request.Content);

            return(PasswordService.ChangeMarginPin(Guid.Parse(args[0]), args[1], args[2])
                   .ToPacketContent());
        }
Esempio n. 10
0
        private PacketContent MultipleCloseAction(SerializedInfo request, Token token)
        {
            var args = ArgumentsParser.Parse(request.Content);

            return(TransactionService.MultipleClose(request.ClientInfo.Session, args[0].ToGuidArray())
                   .ToPacketContent());
        }
Esempio n. 11
0
        private PacketContent GetAccountBanksApprovedAction(SerializedInfo request, Token token)
        {
            var args = ArgumentsParser.Parse(request.Content);

            return(AccountManager.Default.GetAccountBanksApproved(Guid.Parse(args[0]), args[1])
                   .ToPacketContent());
        }
Esempio n. 12
0
        private PacketContent GetDeliveryAddressAction(SerializedInfo request, Token token)
        {
            var args = ArgumentsParser.Parse(request.Content);

            return(_DeliveryService.GetDeliveryAddress(request.ClientInfo.Session, args[0].ToGuid())
                   .ToPacketContent());
        }
Esempio n. 13
0
        private PacketContent ApplyDeliveryAction(SerializedInfo request, Token token)
        {
            var args = ArgumentsParser.Parse(request.Content);

            return(_DeliveryService.ApplyDelivery(request.ClientInfo.Session, args[0].ToXmlNode())
                   .ToPacketContent());
        }
Esempio n. 14
0
        private PacketContent GetInterestRateByInterestRateIdAction(SerializedInfo request, Token token)
        {
            var args = ArgumentsParser.Parse(request.Content);

            return(InterestRateService.GetInterestRate2(request.ClientInfo.Session, args[0].ToGuid())
                   .ToPacketContent());
        }
Esempio n. 15
0
        private PacketContent StatementForJava2Action(SerializedInfo request, Token token)
        {
            List <string> argList = ArgumentsParser.Parse(request.Content);

            return(StatementService.StatementForJava2(request.ClientInfo.Session, int.Parse(argList[0]), argList[1], argList[2], argList[3], argList[4])
                   .ToPacketContent());
        }
Esempio n. 16
0
        private PacketContent RecoverPasswordDatasAction(SerializedInfo request, Token token)
        {
            List <string> argList = ArgumentsParser.Parse(request.Content);
            var           args    = argList[0].To2DArray();

            return(PasswordService.RecoverPasswordDatas(request.ClientInfo.Session, args).ToPacketContent());
        }
Esempio n. 17
0
        private PacketContent GetMerchantInfoFor99BillAction(SerializedInfo request, Token token)
        {
            List <string> argList = ArgumentsParser.Parse(request.Content);

            Guid[] organizationIds = argList[0].ToGuidArray();
            return(PaymentService.GetMerchantInfoFor99Bill(organizationIds).ToPacketContent());
        }
Esempio n. 18
0
        private PacketContent Quote2Action(SerializedInfo request, Token token)
        {
            List <string> argList = ArgumentsParser.Parse(request.Content);

            return(_Service.Quote2(request.ClientInfo.Session, argList[0], double.Parse(argList[1]), double.Parse(argList[2]), int.Parse(argList[3]))
                   .ToPacketContent());
        }
Esempio n. 19
0
        private PacketContent PlaceAction(SerializedInfo request, Token token)
        {
            var args = ArgumentsParser.Parse(request.Content);

            if (token != null && token.AppType == iExchange.Common.AppType.Mobile)
            {
                ICollection <Mobile.Server.Transaction> transactions = Mobile.Manager.ConvertPlacingRequest(token, args[0].ToXmlNode());
                XElement element = new XElement("Result");
                if (transactions != null)
                {
                    foreach (Mobile.Server.Transaction transaction in transactions)
                    {
                        ICollection <XElement> errorCodes = MobileHelper.GetPlaceResultForMobile(transaction, token);
                        foreach (XElement orderErrorElement in errorCodes)
                        {
                            element.Add(orderErrorElement);
                        }
                    }
                }
                XElement changes = Mobile.Manager.GetChanges(request.ClientInfo.Session.ToString(), false);
                element.Add(changes);
                return(element.ToPacketContent());
            }
            return(TransactionService.Place(request.ClientInfo.Session, args[0].ToXmlNode()).ToPacketContent());
        }
Esempio n. 20
0
        private PacketContent AsyncGetChartData2Action(SerializedInfo request, Token token)
        {
            var args = ArgumentsParser.Parse(request.Content);

            return(TickService.AsyncGetChartData2(request.ClientInfo.Session, Guid.Parse(args[0]), DateTime.Parse(args[1]), DateTime.Parse(args[2]), args[3])
                   .ToPacketContent());
        }
Esempio n. 21
0
        private PacketContent GetQuotePolicyDetailsAndRefreshInstrumentsStateAction(SerializedInfo request, Token token)
        {
            var args = ArgumentsParser.Parse(request.Content);

            return(_Service.GetQuotePolicyDetailsAndRefreshInstrumentsState(request.ClientInfo.Session, args[0].ToGuid())
                   .ToPacketContent());
        }
Esempio n. 22
0
        static void Main(string[] args)
        {
            var parser = new ArgumentsParser();

            parser.Parse(args);

            if (parser.CheckFlag("h") || parser.CheckFlag("?"))
            {
                PrinteHelp();
                return;
            }

            var detectOpenPorts = parser.CheckFlag("o");
            var verbose         = parser.CheckFlag("v");

            if (parser.CheckFlag("a"))
            {
                PrintDetailList(detectOpenPorts, verbose);
            }
            else if (parser.CheckFlag("n"))
            {
                PrintOnlyNames();
            }
            else
            {
                PrintBasicList();
            }
        }
        public void When_SingleOperationWithNoArguments_Returns_OperationWithNoArguments()
        {
            string[] args = new string[] { "TestOperation" };

            Operation[] Operations = ArgumentsParser.Parse(args);

            Assert.AreEqual(0, Operations[0].Arguments.Length);
        }
        public void When_ArgumentIsNotPotentialJson_IsCorrectlyIdentified()
        {
            string[] args = new string[] { "TestOperation", "Arg1=123", "Arg2=aaaa", "Arg3=\"aaa bbbb\"" };

            Operation[] Operations = ArgumentsParser.Parse(args);

            Assert.IsFalse(Operations[0].Arguments[1].IsPotentialJson);
        }
        public void When_ArgumentIsPotentialJson_IsCorrectlyIdentified()
        {
            string[] args = new string[] { "TestOperation", "Arg1=123", "Arg2=aaaa", "Arg3={test:123}" };

            Operation[] Operations = ArgumentsParser.Parse(args);

            Assert.IsTrue(Operations[0].Arguments[2].IsPotentialJson);
        }
        public void When_ArgumentIsString_IsCorrectlyIdentified()
        {
            string[] args = new string[] { "TestOperation", "Arg1=123", "Arg2=aaaa", "Arg3=\"aaa bbbb\"" };

            Operation[] Operations = ArgumentsParser.Parse(args);

            Assert.IsTrue(Operations[0].Arguments[2].IsLiteralString);
        }
        public void When_EmptyArgs_Returns_NoOperations()
        {
            string[] args = new string[0];

            Operation[] Operations = ArgumentsParser.Parse(args);

            Assert.AreEqual(0, Operations.Length);
        }
Esempio n. 28
0
        public void Test_ParseBlockSize_CannotParseValue()
        {
            var args = new[] { "compress", "input", "output", "--block-size", "qqq" };

            var service = new ArgumentsParser(_fileService.Object);

            Assert.Throws <ArgumentException>(() => service.Parse(args));
        }
Esempio n. 29
0
        public void Should_be_able_to_Parse_multi_args_properly()
        {
            var arguments = ArgumentsParser.Parse <Arguments>(new[] { "-r", "localhost:8080", "-r", "localhost:8081", "-r", "localhost:8082" });

            Assert.That(arguments.Registries, Contains.Item("localhost:8080"));
            Assert.That(arguments.Registries, Contains.Item("localhost:8081"));
            Assert.That(arguments.Registries, Contains.Item("localhost:8082"));
        }
Esempio n. 30
0
        public void Test_ParseCompressMode_WrongValue()
        {
            var args = new[] { "decompress111", "input", "output" };

            var service = new ArgumentsParser(_fileService.Object);

            Assert.Throws <ArgumentException>(() => service.Parse(args));
        }
 public void ParseDataArgumentsWordsOnly()
 {
     string testWords = "Greece, default, default, greece";
     ArgumentsParser argParser = new ArgumentsParser();
     argParser.Parse(new string[] { "http://www.cnn.com", testWords, "-w", });
     Assert.False(argParser.CharsNumberNeeded);
     Assert.False(argParser.SentencesNeeded);
     Assert.False(argParser.Verbose);
     Assert.True(argParser.WordsNumberNeeded);
 }
Esempio n. 32
0
        public void GivenOneWhitespaceArgument_ThenParseFails()
        {
            // Arrange
            var parser = new ArgumentsParser(new string[] { " " });

            // Act
            parser.Parse();

            // Assert
            Assert.IsFalse(parser.Success);
            Assert.IsFalse(string.IsNullOrWhiteSpace(parser.ErrorMessage), "Error message must be populated");
        }
Esempio n. 33
0
        public void GivenOneValidArgument_ThenParseSucceeds()
        {
            // Arrange
            var parser = new ArgumentsParser(new string[] { "one" });

            // Act
            parser.Parse();

            // Assert
            Assert.IsTrue(parser.Success);
            Assert.AreEqual("one", parser.Filename);
        }
 public void ParseListOfUrlsTest()
 {
     string urlListPath = @"D:\github\web-scraper\Scraper\Scraper.Tests\TestData\UrlList.txt";
     string[] expectedData = new string[]
     {
         "http://www.cnn.com",
         "http://www.cnn2.com",
         "http://www.cnn3.com"
     };
     ArgumentsParser argParser = new ArgumentsParser();
     argParser.Parse(new string[] { urlListPath });
     Assert.AreEqual(3, argParser.Urls.Length);
     Assert.AreEqual(expectedData, argParser.Urls);
 }
 public void ParseWord()
 {
     string testWords = "Greece";
     ArgumentsParser argParser = new ArgumentsParser();
     argParser.Parse(new string[] { "http://www.cnn.com", testWords });
     Assert.AreEqual(1, argParser.Words.Length);
     Assert.AreEqual(new string[] { testWords }, argParser.Words);
 }
 public void ParseUrlTest()
 {
     string testUrl = "http://www.cnn.com";
     ArgumentsParser argParser = new ArgumentsParser();
     argParser.Parse(new string[] { testUrl });
     Assert.AreEqual(1, argParser.Urls.Length);
     Assert.AreEqual(testUrl, argParser.Urls[0]);
 }
 public void ParseWordsList()
 {
     string testWords = "Greece, default, default, greece";
     ArgumentsParser argParser = new ArgumentsParser();
     argParser.Parse(new string[] { "http://www.cnn.com", testWords });
     Assert.AreEqual(2, argParser.Words.Length);
     Assert.AreEqual(new string[] { "Greece", "default" }, argParser.Words);
 }