예제 #1
0
        public void TextWithEncoding_CompareTo_2()
        {
            TextWithEncoding first  = "Hello";
            TextWithEncoding second = null;

            Assert.IsTrue(first.CompareTo(second) > 0);
        }
예제 #2
0
        public void TextWithEncoding_ImplicitOperator_1()
        {
            TextWithEncoding text = "Hello";

            byte[] bytes = text.ToBytes();
            Assert.AreEqual(5, bytes.Length);
        }
예제 #3
0
        public void TextWithEncoding_CompareTo_1()
        {
            TextWithEncoding first  = "Hello";
            TextWithEncoding second = "World";

            Assert.IsTrue(first.CompareTo(second) < 0);
        }
예제 #4
0
        public void TextWithEncoding_Construction_3()
        {
            TextWithEncoding text = new TextWithEncoding("Hello", true);

            byte[] bytes = text.ToBytes();
            Assert.AreEqual(5, bytes.Length);
        }
예제 #5
0
        public void TextWithEncoding_Construction_4()
        {
            TextWithEncoding text = new TextWithEncoding("Привет", Encoding.GetEncoding(1251));

            byte[] bytes = text.ToBytes();
            Assert.AreEqual(6, bytes.Length);
        }
예제 #6
0
        public void TextWithEncoding_Construction_2()
        {
            TextWithEncoding text = new TextWithEncoding("Привет");

            byte[] bytes = text.ToBytes();
            Assert.AreEqual(12, bytes.Length);
        }
예제 #7
0
        public void TextWithEncoding_ToString_1()
        {
            TextWithEncoding text = new TextWithEncoding();

            Assert.AreEqual(string.Empty, text.ToString());

            text = "Hello";
            Assert.AreEqual("Hello", text.ToString());
        }
예제 #8
0
        public void TextWithEncoding_GetHashCode_1()
        {
            TextWithEncoding text = new TextWithEncoding();

            Assert.AreEqual(0, text.GetHashCode());

            text = "Hello";
            Assert.AreEqual("Hello".GetHashCode(), text.GetHashCode());
        }
예제 #9
0
        public void TextWithEncoding_Equals_2()
        {
            TextWithEncoding first  = new TextWithEncoding("Hello", true);
            TextWithEncoding second = new TextWithEncoding("World", false);

            Assert.IsFalse(first.Equals((object)second));
            Assert.IsTrue(first.Equals((object)first));
            Assert.IsFalse(first.Equals((object)null));
        }
예제 #10
0
        public void TextWithEncoding_Comparison_2()
        {
            TextWithEncoding first  = new TextWithEncoding("Hello", true);
            TextWithEncoding second = null;

            Assert.AreEqual
            (
                false,
                first == second
            );
        }
예제 #11
0
        public void TextWithEncoding_Comparison_4()
        {
            TextWithEncoding first  = new TextWithEncoding("Hello", true);
            TextWithEncoding second = new TextWithEncoding("World", false);

            Assert.AreEqual
            (
                true,
                first != second
            );
        }
예제 #12
0
        /// <summary>
        /// Записываем строку в произвольной кодировке.
        /// </summary>
        public static Stream EncodeTextWithEncoding
        (
            [NotNull] this Stream stream,
            [CanBeNull] TextWithEncoding text
        )
        {
            if (!ReferenceEquals(text, null))
            {
                byte[] bytes = text.ToBytes();

                stream.Write(bytes, 0, bytes.Length);
            }

            return(stream);
        }
예제 #13
0
        /// <summary>
        /// Create client query.
        /// </summary>
        public override ClientQuery CreateQuery()
        {
            ClientQuery result = base.CreateQuery();

            result.CommandCode = CommandCode.ReadDocument;

            foreach (FileSpecification fileName in Files)
            {
                TextWithEncoding text = new TextWithEncoding
                                        (
                    fileName.ToString(),
                    IrbisEncoding.Ansi
                                        );
                result.Arguments.Add(text);
            }

            return(result);
        }