示例#1
0
        public void ConnectionEncodingWorksCorrectly()
        {
            Connection.Encoding = Encoding.GetEncoding("windows-1250");
            ITikCommand readCmd          = Connection.CreateCommand("/system/identity/print");
            var         originalIdentity = readCmd.ExecuteScalar();

            //modify
            const string testStringWithExoticCharacters = "Příliš žluťoučký kůň úpěl ďábelské ódy.";
            ITikCommand  setCmd = Connection.CreateCommand("/system/identity/set");

            setCmd.AddParameterAndValues("name", testStringWithExoticCharacters);
            setCmd.ExecuteNonQuery();

            //read modified
            var newIdentity = readCmd.ExecuteScalar();

            Assert.AreEqual(testStringWithExoticCharacters, newIdentity);

            //cleanup
            setCmd.Parameters.Clear();
            setCmd.AddParameterAndValues("name", originalIdentity);
            setCmd.ExecuteNonQuery();
        }
示例#2
0
        public void ConnectionEncodingWorksCorrectly()
        {
            using (var connection = ConnectionFactory.OpenConnection(TikConnectionType.ApiSsl, ConfigurationManager.AppSettings["host"], ConfigurationManager.AppSettings["user"], ConfigurationManager.AppSettings["pass"]))
            {
                connection.Encoding = Encoding.GetEncoding("windows-1250");
                ITikCommand readCmd          = connection.CreateCommand("/system/identity/print");
                var         originalIdentity = readCmd.ExecuteScalar();

                //modify
                const string testStringWithExoticCharacters = "Příliš žluťoučký kůň úpěl ďábelské ódy.";
                ITikCommand  setCmd = connection.CreateCommand("/system/identity/set");
                setCmd.AddParameterAndValues("name", testStringWithExoticCharacters);
                setCmd.ExecuteNonQuery();

                //read modified
                var newIdentity = readCmd.ExecuteScalar();
                Assert.AreEqual(testStringWithExoticCharacters, newIdentity);

                //cleanup
                setCmd.Parameters.Clear();
                setCmd.AddParameterAndValues("name", originalIdentity);
                setCmd.ExecuteNonQuery();
            }
        }