GetBytes() public method

Encodes a set of characters from the specified character array into the specified byte array.
is null.-or- is null. or or is less than zero.-or- and do not denote a valid range in .-or- is not a valid index in . does not have enough capacity from to the end of the array to accommodate the resulting bytes.
public GetBytes ( char chars, int charIndex, int charCount, byte bytes, int byteIndex ) : int
chars char The character array containing the set of characters to encode.
charIndex int The index of the first character to encode.
charCount int The number of characters to encode.
bytes byte The byte array to contain the resulting sequence of bytes.
byteIndex int The index at which to start writing the resulting sequence of bytes.
return int
示例#1
0
 public void GetBytesTest()
 {
     ASCIIEncoding target = new ASCIIEncoding(); // TODO: Initialize to an appropriate value
     char[] chars = null; // TODO: Initialize to an appropriate value
     int charIndex = 0; // TODO: Initialize to an appropriate value
     int charCount = 0; // TODO: Initialize to an appropriate value
     byte[] bytes = null; // TODO: Initialize to an appropriate value
     int byteIndex = 0; // TODO: Initialize to an appropriate value
     int expected = 0; // TODO: Initialize to an appropriate value
     int actual;
     actual = target.GetBytes(chars, charIndex, charCount, bytes, byteIndex);
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
        public void Test_PasswordConnectionInfo_PasswordExpired()
        {
            var host = Resources.HOST;
            var username = Resources.USERNAME;
            var password = Resources.PASSWORD;

            #region Example PasswordConnectionInfo PasswordExpired
            var connectionInfo = new PasswordConnectionInfo("host", "username", "password");
            var encoding = new Renci.SshNet.Common.ASCIIEncoding();
            connectionInfo.PasswordExpired += delegate(object sender, AuthenticationPasswordChangeEventArgs e)
            {
                e.NewPassword = encoding.GetBytes("123456");
            };

            using (var client = new SshClient(connectionInfo))
            {
                client.Connect();

                client.Disconnect();
            }
            #endregion

            Assert.Inconclusive();
        }
示例#3
0
        public void Test_PasswordConnectionInfo_PasswordExpired()
        {
            var host     = Resources.HOST;
            var username = Resources.USERNAME;
            var password = Resources.PASSWORD;

            #region Example PasswordConnectionInfo PasswordExpired
            var connectionInfo = new PasswordConnectionInfo("host", "username", "password");
            var encoding       = new Renci.SshNet.Common.ASCIIEncoding();
            connectionInfo.PasswordExpired += delegate(object sender, AuthenticationPasswordChangeEventArgs e)
            {
                e.NewPassword = encoding.GetBytes("123456");
            };

            using (var client = new SshClient(connectionInfo))
            {
                client.Connect();

                client.Disconnect();
            }
            #endregion

            Assert.Inconclusive();
        }
示例#4
0
        public bool InitRepositoryLocal ()
        {
            // Error out if the target folder is not empty
            if (!Directory.Exists (DatabasePath)) {
                Directory.CreateDirectory (DatabasePath);

            } else {
                Utils.Log ("Could not init local: " + DatabasePath + " already exists");
                return false;
            }

            // Create structure locally
            Directory.CreateDirectory (Path.Combine (DatabasePath, "objects"));
            StreamWriter writer = new StreamWriter (Path.Combine (DatabasePath, "HEAD"));
            writer.WriteLine ("0:0");
            writer.Close ();

            // Create a randomish ID
            writer = new StreamWriter (Path.Combine (DatabasePath, "ID"));
            string random = DateTime.Now.ToString ("YYDDMMhhmmssFFF") + new Random ().Next (0, 1000);
            ASCIIEncoding encoding = new ASCIIEncoding ();
            writer.WriteLine (Utils.SHA1 (encoding.GetBytes (random)));
            writer.Close ();

            return true;
        }