public void Typical()
        {
            const string input = @"protocol=https
            host=example.visualstudio.com
            path=path
            username=userName
            password=incorrect
            ";
            OperationArguments cut;
            using (var sr = new StringReader(input))
            {
                cut = new OperationArguments(sr);
            }

            Assert.AreEqual("https", cut.QueryProtocol);
            Assert.AreEqual("example.visualstudio.com", cut.QueryHost);
            Assert.AreEqual("https://example.visualstudio.com/", cut.TargetUri.ToString());
            Assert.AreEqual("path", cut.QueryPath);
            Assert.AreEqual("userName", cut.CredUsername);
            Assert.AreEqual("incorrect", cut.CredPassword);

            var expected = ReadLines(input);
            var actual = ReadLines(cut.ToString());
            CollectionAssert.AreEqual(expected, actual);
        }
コード例 #2
0
 /// <summary>
 /// Reads one or several records of a file in synchronous way.
 /// </summary>
 /// <param name="filename">File name to read.</param>
 /// <param name="recordIds">A list of item IDs to read, separated by the Record Separator character (30). Use StringFunctions.ComposeRecordIds to compose this string</param>
 /// <param name="dictionaries">List of dictionaries to read, separated by space. If this list is not set, all fields are returned. You may use the format LKFLDx where x is the attribute number.</param>
 /// <param name="readOptions">Object that defines the different reading options of the Function: Calculated, dictClause, conversion, formatSpec, originalRecords.</param>
 /// <param name="inputFormat">Indicates in what format you wish to send the record ids: MV, XML or JSON.</param>
 /// <param name="outputFormat">Indicates in what format you want to receive the data resulting from the Read, New, Update and Select operations: MV, XML, XML_DICT, XML_SCH, JSON, JSON_DICT or JSON_SCH.</param>
 /// <param name="customVars">Free text sent to the database allows management of additional behaviours in SUB.LK.MAIN.CONTROL.CUSTOM, which is called when this parameter is set.</param>
 /// <param name="receiveTimeout">Maximum time in seconds that the client will wait for a response from the server. Default = 0 to wait indefinitely.</param>
 /// <returns>The results of the operation.</returns>
 public string Read(string filename, string recordIds, string dictionaries = "", ReadOptions readOptions = null,
                    DATAFORMAT_TYPE inputFormat = DATAFORMAT_TYPE.MV, DATAFORMATCRU_TYPE outputFormat    = DATAFORMATCRU_TYPE.MV, string customVars = "", int receiveTimeout = 0)
 {
     if (this._ConnectionInfo != null)
     {
         string readArgs         = OperationArguments.GetReadArgs(filename, recordIds, dictionaries, readOptions, customVars);
         byte   opCode           = (byte)OPERATION_CODE.READ;
         byte   byteInputFormat  = (byte)inputFormat;
         byte   byteOutputFormat = (byte)outputFormat;
         string connectionInfo   = this._ConnectionInfo.ToString();
         string result           = Linkar.ExecutePersistentOperation(this._ConnectionInfo, opCode, readArgs, byteInputFormat, byteOutputFormat, receiveTimeout);
         return(result);
     }
     else
     {
         return("");
     }
 }
コード例 #3
0
        private void CreateTargetUriTestDefault(InputArg input)
        {
            using (var memory = new MemoryStream())
                using (var writer = new StreamWriter(memory))
                {
                    writer.Write(input.ToString());
                    writer.Flush();

                    memory.Seek(0, SeekOrigin.Begin);

                    var oparg = new OperationArguments(RuntimeContext.Default, memory);

                    Assert.NotNull(oparg);
                    Assert.Equal(input.Protocol ?? string.Empty, oparg.QueryProtocol, StringComparer.Ordinal);
                    Assert.Equal(input.Host ?? string.Empty, oparg.QueryHost, StringComparer.Ordinal);
                    Assert.Equal(input.Path, oparg.QueryPath, StringComparer.Ordinal);
                    Assert.Equal(input.Username, oparg.Username, StringComparer.Ordinal);
                    Assert.Equal(input.Password, oparg.Password, StringComparer.Ordinal);
                }
        }
コード例 #4
0
        public void SpecialCharacters()
        {
            var input = new InputArg
            {
                Host     = "example.visualstudio.com",
                Password = "******",
                Path     = "path",
                Protocol = Uri.UriSchemeHttps,
                Username = "******"
            };

            OperationArguments cut;

            using (var memory = new MemoryStream())
                using (var writer = new StreamWriter(memory))
                {
                    writer.Write(input.ToString());
                    writer.Flush();

                    memory.Seek(0, SeekOrigin.Begin);

                    cut = new OperationArguments(RuntimeContext.Default, memory);
                }

            Assert.Equal(input.Protocol, cut.QueryProtocol, StringComparer.Ordinal);
            Assert.Equal(input.Host, cut.QueryHost, StringComparer.Ordinal);
            Assert.Equal(input.Path, cut.QueryPath, StringComparer.Ordinal);
            Assert.Equal(input.Username, cut.Username, StringComparer.Ordinal);
            Assert.Equal(input.Password, cut.Password, StringComparer.Ordinal);

            Assert.Equal("https://userNamể@example.visualstudio.com/path", cut.TargetUri.ToString(), StringComparer.Ordinal);

            var expected = input.ToString();
            var actual   = cut.ToString();

            Assert.Equal(expected, actual, StringComparer.Ordinal);
        }
コード例 #5
0
        public void Typical()
        {
            var input = new InputArg
            {
                Host     = "example.visualstudio.com",
                Password = "******",
                Path     = "path",
                Protocol = "https",
                Username = "******",
            };

            OperationArguments cut;

            using (var memory = new MemoryStream())
                using (var writer = new StreamWriter(memory))
                {
                    writer.Write(input.ToString());
                    writer.Flush();

                    memory.Seek(0, SeekOrigin.Begin);

                    cut = new OperationArguments(RuntimeContext.Default, memory);
                }

            Assert.Equal(input.Protocol, cut.QueryProtocol);
            Assert.Equal(input.Host, cut.QueryHost);
            Assert.Equal(input.Path, cut.QueryPath);
            Assert.Equal(input.Username, cut.Username);
            Assert.Equal(input.Password, cut.Password);

            Assert.Equal("https://[email protected]/path", cut.TargetUri.ToString());

            var expected = ReadLines(input.ToString());
            var actual   = ReadLines(cut.ToString());

            Assert.Equal(expected, actual);
        }
        private void CreateTargetUriTestWithPath(InputArg input)
        {
            using (var memory = new MemoryStream())
            using (var writer = new StreamWriter(memory))
            {
                writer.Write(input.ToString());
                writer.Flush();

                memory.Seek(0, SeekOrigin.Begin);

                var oparg = new OperationArguments(memory);
                oparg.UseHttpPath = true;

                Assert.IsNotNull(oparg);
                Assert.AreEqual(input.Protocol ?? string.Empty, oparg.QueryProtocol);
                Assert.AreEqual(input.Host ?? string.Empty, oparg.QueryHost);
                Assert.AreEqual(input.Path, oparg.QueryPath);
                Assert.AreEqual(input.Username, oparg.CredUsername);
                Assert.AreEqual(input.Password, oparg.CredPassword);

                // file or unc paths are treated specially
                if (oparg.QueryUri.Scheme != "file")
                {
                    Assert.AreEqual("/" + input.Path, oparg.QueryUri.AbsolutePath);
                }
            }
        }
        public void Typical()
        {
            const string input = "protocol=https\n"
                               + "host=example.visualstudio.com\n"
                               + "path=path\n"
                               + "username=userName\n"
                               + "password=incorrect\n";

            OperationArguments cut;
            using (var memory = new MemoryStream())
            using (var writer = new StreamWriter(memory))
            {
                writer.Write(input);
                writer.Flush();

                memory.Seek(0, SeekOrigin.Begin);

                cut = new OperationArguments(memory);
            }

            Assert.AreEqual("https", cut.QueryProtocol);
            Assert.AreEqual("example.visualstudio.com", cut.QueryHost);
            Assert.AreEqual("https://example.visualstudio.com/", cut.TargetUri.ToString());
            Assert.AreEqual("path", cut.QueryPath);
            Assert.AreEqual("userName", cut.CredUsername);
            Assert.AreEqual("incorrect", cut.CredPassword);

            var expected = ReadLines(input);
            var actual = ReadLines(cut.ToString());
            CollectionAssert.AreEqual(expected, actual);
        }