コード例 #1
0
        public void WriteFormatStringWithArgumentArray()
        {
            var value = "{0}{1}{2}{3}";
            var arg1  = 10;
            var arg2  = 20;
            var arg3  = 30;
            var arg4  = 40;

            bool eventWasRaised = false;

            using (var pipe = new ScriptOutputPipe())
            {
                pipe.OnScriptOutput +=
                    (s, e) =>
                {
                    eventWasRaised = true;
                    Assert.AreEqual(
                        string.Format(
                            CultureInfo.CurrentCulture,
                            value,
                            arg1,
                            arg2,
                            arg3,
                            arg4),
                        e.Text);
                };
                pipe.Write(value, arg1, arg2, arg3, arg4);
            }

            Assert.IsTrue(eventWasRaised);
        }
コード例 #2
0
        public void WriteFormatStringWithThreeArguments()
        {
            var value = "{0} - {1} + {2}";
            var arg1  = 10;
            var arg2  = 5;
            var arg3  = 7;

            bool eventWasRaised = false;

            using (var pipe = new ScriptOutputPipe())
            {
                pipe.OnScriptOutput +=
                    (s, e) =>
                {
                    eventWasRaised = true;
                    Assert.AreEqual(
                        string.Format(
                            CultureInfo.CurrentCulture,
                            value,
                            arg1,
                            arg2,
                            arg3),
                        e.Text);
                };
                pipe.Write(value, arg1, arg2, arg3);
            }

            Assert.IsTrue(eventWasRaised);
        }
コード例 #3
0
        public void WriteCharacter()
        {
            var value = 'c';
            bool eventWasRaised = false;
            using (var pipe = new ScriptOutputPipe())
            {
                pipe.OnScriptOutput +=
                    (s, e) =>
                    {
                        eventWasRaised = true;
                        Assert.AreEqual(value.ToString(CultureInfo.InvariantCulture), e.Text);
                    };
                pipe.Write(value);
            }

            Assert.IsTrue(eventWasRaised);
        }
コード例 #4
0
        public void WriteUnsignedLong()
        {
            var  value          = 10UL;
            bool eventWasRaised = false;

            using (var pipe = new ScriptOutputPipe())
            {
                pipe.OnScriptOutput +=
                    (s, e) =>
                {
                    eventWasRaised = true;
                    Assert.AreEqual(value.ToString(CultureInfo.InvariantCulture), e.Text);
                };
                pipe.Write(value);
            }

            Assert.IsTrue(eventWasRaised);
        }
コード例 #5
0
        public void WriteObject()
        {
            var  value          = new object();
            bool eventWasRaised = false;

            using (var pipe = new ScriptOutputPipe())
            {
                pipe.OnScriptOutput +=
                    (s, e) =>
                {
                    eventWasRaised = true;
                    Assert.AreEqual(value.ToString(), e.Text);
                };
                pipe.Write(value);
            }

            Assert.IsTrue(eventWasRaised);
        }
コード例 #6
0
        public void WriteCharacterArray()
        {
            var value = new[] { 'a', 'b', 'c' };

            bool eventWasRaised = false;
            using (var pipe = new ScriptOutputPipe())
            {
                pipe.OnScriptOutput +=
                    (s, e) =>
                    {
                        eventWasRaised = true;
                        Assert.AreEqual("abc", e.Text);
                    };
                pipe.Write(value);
            }

            Assert.IsTrue(eventWasRaised);
        }
コード例 #7
0
        public void WritePartOfCharacterArray()
        {
            var value = new[] { 'a', 'b', 'c' };

            bool eventWasRaised = false;

            using (var pipe = new ScriptOutputPipe())
            {
                pipe.OnScriptOutput +=
                    (s, e) =>
                {
                    eventWasRaised = true;
                    Assert.AreEqual("b", e.Text);
                };
                pipe.Write(value, 1, 1);
            }

            Assert.IsTrue(eventWasRaised);
        }
コード例 #8
0
        public void WriteObject()
        {
            var value = new object();
            bool eventWasRaised = false;
            using (var pipe = new ScriptOutputPipe())
            {
                pipe.OnScriptOutput +=
                    (s, e) =>
                    {
                        eventWasRaised = true;
                        Assert.AreEqual(value.ToString(), e.Text);
                    };
                pipe.Write(value);
            }

            Assert.IsTrue(eventWasRaised);
        }
コード例 #9
0
        public void WriteFormatStringWithTwoArguments()
        {
            var value = "{0} - {1}";
            var arg1 = 10;
            var arg2 = 5;

            bool eventWasRaised = false;
            using (var pipe = new ScriptOutputPipe())
            {
                pipe.OnScriptOutput +=
                    (s, e) =>
                    {
                        eventWasRaised = true;
                        Assert.AreEqual(
                            string.Format(
                                CultureInfo.CurrentCulture,
                                value,
                                arg1,
                                arg2),
                            e.Text);
                    };
                pipe.Write(value, arg1, arg2);
            }

            Assert.IsTrue(eventWasRaised);
        }
コード例 #10
0
        public void WriteFormatStringWithArgumentArray()
        {
            var value = "{0}{1}{2}{3}";
            var arg1 = 10;
            var arg2 = 20;
            var arg3 = 30;
            var arg4 = 40;

            bool eventWasRaised = false;
            using (var pipe = new ScriptOutputPipe())
            {
                pipe.OnScriptOutput +=
                    (s, e) =>
                    {
                        eventWasRaised = true;
                        Assert.AreEqual(
                            string.Format(
                                CultureInfo.CurrentCulture,
                                value,
                                arg1,
                                arg2,
                                arg3,
                                arg4),
                            e.Text);
                    };
                pipe.Write(value, arg1, arg2, arg3, arg4);
            }

            Assert.IsTrue(eventWasRaised);
        }