public void Changing_Language_Causes_Reformatting()
        {
            _box = SetupCodeBox(_someCode, new SizeF(200, 400));

            _mockFormatter.ExpectAndReturn("Format", _someCode, new object[] { _someCode.Text, "C#" });
            _mockRenderer.ExpectAndReturn("GetDocumentSize", new SizeF(200, 400),
                                          new object[] { _someCode, _box.RenderingContext.Graphics, _box.RenderingContext.Font });

            _box.Language = "C#";
            Assert.That(_box.Language, Is.EqualTo("C#"));

            _mockFormatter.Verify();
            _mockRenderer.Verify();

            // setting null in language is same as setting "" or "Plain text"

            _mockFormatter.ExpectAndReturn("Format", _someText, new object[] { _someCode.Text, "" });
            _mockRenderer.ExpectAndReturn("GetDocumentSize", new SizeF(100, 100),
                                          new object[] { _box.FormattedCode, _box.RenderingContext.Graphics, _box.RenderingContext.Font });

            _box.Language = null;
            Assert.That(_box.Language, Is.EqualTo(""));

            return;
        }
Beispiel #2
0
        public void CurrentLine()
        {
            FormattedCode data = Format(
                "line 0\r\nline 1\r\nline 2\r\nline 3\r\nline 4\r\nline 5\r\nline 6\r\nline 7\r\n", "");

            _box        = SetupCodeBox(data, new SizeF(200, 400));
            _box.Height = 30;

            // CurrentLine: 0

            _mockRenderer.LineIndexToYCoordinate(0, _box.RenderingContext.Graphics, _box.RenderingContext.Font).Returns(0f);

            _box.CurrentLine = 0;

            Assert.That(_box.CurrentLine, Is.EqualTo(0));
            Assert.That(_box.AutoScrollPosition, Is.EqualTo(new Point(0, 0)));

            // CurrentLine: 7

            _mockRenderer.LineIndexToYCoordinate(7, _box.RenderingContext.Graphics, _box.RenderingContext.Font).Returns(390f);

            _box.CurrentLine = 7;

            Assert.That(_box.CurrentLine, Is.EqualTo(7));
            Assert.That(_box.AutoScrollPosition, Is.EqualTo(new Point(0, -375)));

            return;
        }
Beispiel #3
0
        public void OnPaint()
        {
            TestingCodeBox box = SetupCodeBox(_someText, new SizeF(300, 400));

            box.Width  = 150;
            box.Height = 150;

            box.FireOnPaint();

            _mockRenderer.Received().DrawToGraphics(_someText, box.RenderingContext, new Rectangle(0, 0, 150, 150));

            return;
        }
Beispiel #4
0
        TestingCodeBox SetupCodeBox(FormattedCode code, SizeF size)
        {
            TestingCodeBox box;

            box = new TestingCodeBox(_mockFormatter, _mockRenderer);

            _mockFormatter.Format(code.Text, "").Returns(code);
            _mockRenderer.GetDocumentSize(code, box.RenderingContext.Graphics, box.RenderingContext.Font).Returns(size);

            box.Text = code.Text;
            Assert.That(box.Text, Is.EqualTo(code.Text));

            return (box);
        }
Beispiel #5
0
        public void SetUp()
        {
            _mockFormatter = Substitute.For<IFormatterCatalog>();
            _mockRenderer = Substitute.For<ICodeRenderer>();

            _box = new TestingCodeBox(_mockFormatter, _mockRenderer);
            _box.Width = 150;
            _box.Height = 150;

            _someText = Format("some C# code", "");
            _someCode = Format("some C# code", "C#");

            return;
        }
Beispiel #6
0
        public void SetUp()
        {
            _mockFormatter = Substitute.For <IFormatterCatalog>();
            _mockRenderer  = Substitute.For <ICodeRenderer>();

            _box        = new TestingCodeBox(_mockFormatter, _mockRenderer);
            _box.Width  = 150;
            _box.Height = 150;

            _someText = Format("some C# code", "");
            _someCode = Format("some C# code", "C#");

            return;
        }
Beispiel #7
0
        TestingCodeBox SetupCodeBox(FormattedCode code, SizeF size)
        {
            TestingCodeBox box;

            box = new TestingCodeBox(_mockFormatter, _mockRenderer);

            _mockFormatter.Format(code.Text, "").Returns(code);
            _mockRenderer.GetDocumentSize(code, box.RenderingContext.Graphics, box.RenderingContext.Font).Returns(size);

            box.Text = code.Text;
            Assert.That(box.Text, Is.EqualTo(code.Text));

            return(box);
        }
Beispiel #8
0
        public void Changing_Font_Causes_Reformatting()
        {
            Font courier14 = new Font("Courier New", 14);

            _box = SetupCodeBox(_someCode, new SizeF(200, 400));

            _mockFormatter.Format(_someCode.Text, "").Returns(_someCode);
            _mockRenderer.GetDocumentSize(_someCode, _box.RenderingContext.Graphics, courier14).Returns(new SizeF(200, 400));

            _box.Font = courier14;

            Assert.That(_box.RenderingContext.Font, Is.SameAs(_box.Font));

            return;
        }
        public void OnPaint()
        {
            TestingCodeBox box = SetupCodeBox(_someText, new SizeF(300, 400));

            box.Width  = 150;
            box.Height = 150;

            _mockRenderer.Expect("DrawToGraphics",
                                 new object[] { _someText, box.RenderingContext, new Rectangle(0, 0, 150, 150) });

            box.FireOnPaint();
            _mockRenderer.Verify();

            return;
        }
        public void SetUp()
        {
            _mockFormatter = new DynamicMock(typeof(IFormatterCatalog));
            _mockRenderer = new DynamicMock(typeof(ICodeRenderer));

            _box = new TestingCodeBox((IFormatterCatalog)_mockFormatter.MockInstance,
                                (ICodeRenderer)_mockRenderer.MockInstance);
            _box.Width = 150;
            _box.Height = 150;

//            _emptyText = Format("", "");
            _someText = Format("some C# code", "");
            _someCode = Format("some C# code", "C#");

            return;
        }
Beispiel #11
0
        public void SetUp()
        {
            _mockFormatter = new DynamicMock(typeof(IFormatterCatalog));
            _mockRenderer  = new DynamicMock(typeof(ICodeRenderer));

            _box = new TestingCodeBox((IFormatterCatalog)_mockFormatter.MockInstance,
                                      (ICodeRenderer)_mockRenderer.MockInstance);
            _box.Width  = 150;
            _box.Height = 150;

//            _emptyText = Format("", "");
            _someText = Format("some C# code", "");
            _someCode = Format("some C# code", "C#");

            return;
        }
Beispiel #12
0
        public void Changing_Font_Causes_Reformatting()
        {
            Font courier14 = new Font("Courier New", 14);

            _box = SetupCodeBox(_someCode, new SizeF(200, 400));

            _mockFormatter.ExpectAndReturn("Format", _someCode, new object[] { _someCode.Text, "" });
            _mockRenderer.ExpectAndReturn("GetDocumentSize", new SizeF(200, 400),
                                          new object[] { _someCode, _box.RenderingContext.Graphics, courier14 });

            _box.Font = courier14;

            _mockFormatter.Verify();
            _mockRenderer.Verify();

            Assert.That(_box.RenderingContext.Font, Is.SameAs(_box.Font));

            return;
        }
Beispiel #13
0
        public void Changing_Language_Causes_Reformatting()
        {
            _box = SetupCodeBox(_someCode, new SizeF(200, 400));

            _mockFormatter.Format(_someCode.Text, "C#").Returns(_someCode);
            _mockRenderer.GetDocumentSize(_someCode, _box.RenderingContext.Graphics, _box.RenderingContext.Font).Returns(new SizeF(200, 400));

            _box.Language = "C#";
            Assert.That(_box.Language, Is.EqualTo("C#"));

            // setting null in language is same as setting "" or "Plain text"

            _mockFormatter.Format(_someCode.Text, "").Returns(_someText);
            _mockRenderer.GetDocumentSize(_box.FormattedCode, _box.RenderingContext.Graphics, _box.RenderingContext.Font).Returns(new SizeF(100, 100));

            _box.Language = null;
            Assert.That(_box.Language, Is.EqualTo(""));

            return;
        }
        TestingCodeBox SetupCodeBox(FormattedCode code, SizeF size)
        {
            TestingCodeBox box;

            box = new TestingCodeBox(
                (IFormatterCatalog)_mockFormatter.MockInstance,
                (ICodeRenderer)_mockRenderer.MockInstance);

            _mockFormatter.ExpectAndReturn("Format", code, new object[] { code.Text, "" });

            _mockRenderer.ExpectAndReturn("GetDocumentSize", size,
                new object[] { code, box.RenderingContext.Graphics, box.RenderingContext.Font });

            box.Text = code.Text;
            Assert.That(box.Text, Is.EqualTo(code.Text));

            _mockFormatter.Verify();
            _mockRenderer.Verify();

            return (box);
        }
Beispiel #15
0
        TestingCodeBox SetupCodeBox(FormattedCode code, SizeF size)
        {
            TestingCodeBox box;

            box = new TestingCodeBox(
                (IFormatterCatalog)_mockFormatter.MockInstance,
                (ICodeRenderer)_mockRenderer.MockInstance);

            _mockFormatter.ExpectAndReturn("Format", code, new object[] { code.Text, "" });

            _mockRenderer.ExpectAndReturn("GetDocumentSize", size,
                                          new object[] { code, box.RenderingContext.Graphics, box.RenderingContext.Font });

            box.Text = code.Text;
            Assert.That(box.Text, Is.EqualTo(code.Text));

            _mockFormatter.Verify();
            _mockRenderer.Verify();

            return(box);
        }
Beispiel #16
0
        public void Can_Disable_ShowCurrentLine()
        {
            TestingRenderer renderer = new TestingRenderer();

            _box                 = new TestingCodeBox(new GeneralCodeFormatter(), renderer);
            _box.Text            = "line 1\r\nline 2\r\nline 3\r\n";
            _box.ShowCurrentLine = true;

            _box.CurrentLine = 1;
            _box.FireOnPaint();
            Assert.That(renderer.CURRENTLINE_INDEX, Is.EqualTo(1));

            _box.ShowCurrentLine = false;
            _box.FireOnPaint();
            Assert.That(renderer.CURRENTLINE_INDEX, Is.EqualTo(-1));

            _box.ShowCurrentLine = true;
            _box.FireOnPaint();
            Assert.That(renderer.CURRENTLINE_INDEX, Is.EqualTo(1));

            return;
        }
Beispiel #17
0
        public void SetUp()
        {
            TestingCodeBox box = new TestingCodeBox();

            _context = box.RenderingContext;
        }
Beispiel #18
0
        public void CurrentLine()
        {
            FormattedCode data = Format(
                "line 0\r\nline 1\r\nline 2\r\nline 3\r\nline 4\r\nline 5\r\nline 6\r\nline 7\r\n", "");

            _box = SetupCodeBox(data, new SizeF(200, 400));
            _box.Height = 30;

            // CurrentLine: 0

            _mockRenderer.ExpectAndReturn("LineIndexToYCoordinate", 0f,
                new object[] { 0, _box.RenderingContext.Graphics, _box.RenderingContext.Font });

            _box.CurrentLine = 0;
            _mockRenderer.Verify();

            Assert.That(_box.CurrentLine, Is.EqualTo(0));
            Assert.That(_box.AutoScrollPosition, Is.EqualTo(new Point(0, 0)));

            // CurrentLine: 7

            _mockRenderer.ExpectAndReturn("LineIndexToYCoordinate", 390f,
                new object[] { 7, _box.RenderingContext.Graphics, _box.RenderingContext.Font });

            _box.CurrentLine = 7;
            _mockRenderer.Verify();

            Assert.That(_box.CurrentLine, Is.EqualTo(7));
            Assert.That(_box.AutoScrollPosition, Is.EqualTo(new Point(0, -375)));

            return;
        }
Beispiel #19
0
        public void Changing_Language_Causes_Reformatting()
        {
            _box = SetupCodeBox(_someCode, new SizeF(200, 400));

            _mockFormatter.ExpectAndReturn("Format", _someCode, new object[] { _someCode.Text, "C#" });
            _mockRenderer.ExpectAndReturn("GetDocumentSize", new SizeF(200, 400),
                new object[] { _someCode, _box.RenderingContext.Graphics, _box.RenderingContext.Font });

            _box.Language = "C#";
            Assert.That(_box.Language, Is.EqualTo("C#"));

            _mockFormatter.Verify();
            _mockRenderer.Verify();

            // setting null in language is same as setting "" or "Plain text"

            _mockFormatter.ExpectAndReturn("Format", _someText, new object[] { _someCode.Text, "" });
            _mockRenderer.ExpectAndReturn("GetDocumentSize", new SizeF(100, 100),
                new object[] { _box.FormattedCode, _box.RenderingContext.Graphics, _box.RenderingContext.Font });

            _box.Language = null;
            Assert.That(_box.Language, Is.EqualTo(""));

            return;
        }
Beispiel #20
0
        public void Changing_Font_Causes_Reformatting()
        {
            Font courier14 = new Font("Courier New", 14);

            _box = SetupCodeBox(_someCode, new SizeF(200, 400));

            _mockFormatter.Format(_someCode.Text, "").Returns(_someCode);
            _mockRenderer.GetDocumentSize(_someCode, _box.RenderingContext.Graphics, courier14).Returns(new SizeF(200, 400));

            _box.Font = courier14;

            Assert.That(_box.RenderingContext.Font, Is.SameAs(_box.Font));

            return;
        }
Beispiel #21
0
        public void Can_Disable_ShowCurrentLine()
        {
            TestingRenderer renderer = new TestingRenderer();

            _box = new TestingCodeBox(new GeneralCodeFormatter(), renderer);
            _box.Text = "line 1\r\nline 2\r\nline 3\r\n";
            _box.ShowCurrentLine = true;

            _box.CurrentLine = 1;
            _box.FireOnPaint();
            Assert.That(renderer.CURRENTLINE_INDEX, Is.EqualTo(1));

            _box.ShowCurrentLine = false;
            _box.FireOnPaint();
            Assert.That(renderer.CURRENTLINE_INDEX, Is.EqualTo(-1));

            _box.ShowCurrentLine = true;
            _box.FireOnPaint();
            Assert.That(renderer.CURRENTLINE_INDEX, Is.EqualTo(1));

            return;
        }
Beispiel #22
0
        public void Changing_Font_Causes_Reformatting()
        {
            Font courier14 = new Font("Courier New", 14);

            _box = SetupCodeBox(_someCode, new SizeF(200, 400));

            _mockFormatter.ExpectAndReturn("Format", _someCode, new object[] { _someCode.Text, "" });
            _mockRenderer.ExpectAndReturn("GetDocumentSize", new SizeF(200, 400),
                new object[] { _someCode, _box.RenderingContext.Graphics, courier14 });

            _box.Font = courier14;

            _mockFormatter.Verify();
            _mockRenderer.Verify();

            Assert.That(_box.RenderingContext.Font, Is.SameAs(_box.Font));

            return;
        }
 public void SetUp()
 {
     TestingCodeBox box = new TestingCodeBox();
     _context = box.RenderingContext;
 }
Beispiel #24
0
        public void Changing_Language_Causes_Reformatting()
        {
            _box = SetupCodeBox(_someCode, new SizeF(200, 400));

            _mockFormatter.Format(_someCode.Text, "C#").Returns(_someCode);
            _mockRenderer.GetDocumentSize(_someCode, _box.RenderingContext.Graphics, _box.RenderingContext.Font).Returns(new SizeF(200, 400));

            _box.Language = "C#";
            Assert.That(_box.Language, Is.EqualTo("C#"));

            // setting null in language is same as setting "" or "Plain text"

            _mockFormatter.Format(_someCode.Text, "").Returns(_someText);
            _mockRenderer.GetDocumentSize(_box.FormattedCode, _box.RenderingContext.Graphics, _box.RenderingContext.Font).Returns(new SizeF(100, 100));

            _box.Language = null;
            Assert.That(_box.Language, Is.EqualTo(""));

            return;
        }