Exemple #1
0
        public void CanCreateNewHtmlTextWriter()
        {
            HtmlTextWriter writer = MockRenderer.CreateHtmlTextWriter();

            Assert.IsNotNull(writer, "Unable to create HtmlTextWriter");
            Assert.IsInstanceOfType(typeof(StringWriter), writer.InnerWriter, "HtmlTextWriter's inner writer is not StringWriter");
        }
Exemple #2
0
        public void SetsCustomAttributes()
        {
            control.Attributes["someattrib"]      = "somevalue";
            control.Attributes["someotherattrib"] = null;
            MockRenderer.AddDefautAttributesToCollection(control, attributes);

            Assert.AreEqual("somevalue", attributes["someattrib"], "custom attribute with string value not set");
            Assert.IsNull(attributes["someotherattrib"], "custom attribute with null value improperly set");
        }
        public void InvokesRenderOnRendererWhenRenderIsInvoked()
        {
            var gameObject   = new GameObject();
            var mockRenderer = new MockRenderer();

            gameObject.AddComponent(mockRenderer);
            gameObject.Render(new DummyGameTime());
            Assert.IsTrue(mockRenderer.RenderWasInvoked);
        }
Exemple #4
0
        public void SetsColor()
        {
            control.ForeColor = Color.Empty;
            MockRenderer.AddDefautAttributesToCollection(control, attributes);
            Assert.IsNull(attributes.CssStyle["color"], "color improperly set when undefined");

            control.ForeColor = Color.Black;
            MockRenderer.AddDefautAttributesToCollection(control, attributes);
            Assert.AreEqual(ColorTranslator.ToHtml(control.ForeColor), attributes.CssStyle["color"], "color not set");
        }
Exemple #5
0
        public void SetsBorderWidth()
        {
            control.BorderWidth = Unit.Empty;
            MockRenderer.AddDefautAttributesToCollection(control, attributes);
            Assert.IsNull(attributes.CssStyle["border-width"], "border-width improperly set when undefined");

            control.BorderWidth = new Unit(1.0, UnitType.Em);
            MockRenderer.AddDefautAttributesToCollection(control, attributes);
            Assert.AreEqual(control.BorderWidth.ToString(), attributes.CssStyle["border-width"], "border-width not set");
        }
Exemple #6
0
        public void SetsBorderStyle()
        {
            control.BorderStyle = BorderStyle.NotSet;
            MockRenderer.AddDefautAttributesToCollection(control, attributes);
            Assert.IsNull(attributes.CssStyle["border-style"], "border-style improperly set when undefined");

            control.BorderStyle = BorderStyle.Dotted;
            MockRenderer.AddDefautAttributesToCollection(control, attributes);
            Assert.AreEqual(control.BorderStyle.ToString().ToLowerInvariant(), attributes.CssStyle["border-style"], "border-style not set");
        }
Exemple #7
0
        public void SetsHeight()
        {
            control.Height = Unit.Empty;
            MockRenderer.AddDefautAttributesToCollection(control, attributes);
            Assert.IsNull(attributes.CssStyle["height"], "height improperly set when undefined");

            control.Height = new Unit(1.0, UnitType.Em);
            MockRenderer.AddDefautAttributesToCollection(control, attributes);
            Assert.AreEqual(control.Height.ToString(), attributes.CssStyle["height"], "height not set");
        }
Exemple #8
0
        public void WritesAttributesProperly()
        {
            control.BackColor = Color.Black;
            control.Attributes["someattrib"] = "somevalue";
            MockRenderer.AddDefautAttributesToCollection(control, attributes);

            HtmlTextWriter writer = new HtmlTextWriter(new System.IO.StringWriter());

            MockRenderer.WriteAttributes(writer, attributes);

            Assert.AreEqual(" style=\"background-color:Black;\" someattrib=\"somevalue\"", writer.InnerWriter.ToString());
        }
Exemple #9
0
        public void WritesStylesProperly()
        {
            control.BackColor = Color.Black;
            control.ForeColor = Color.White;
            MockRenderer.AddDefautAttributesToCollection(control, attributes);

            HtmlTextWriter writer = new HtmlTextWriter(new System.IO.StringWriter());

            MockRenderer.WriteStyles(writer, attributes.CssStyle);

            Assert.AreEqual(" style=\"background-color:Black;color:White;\"", writer.InnerWriter.ToString());
        }
Exemple #10
0
        public void ConcatenateCssClassTests()
        {
            //normal
            Assert.AreEqual("test1 test2 test3",
                            MockRenderer.ConcatenateCssClasses("test1", "test2", "test3"),
                            "CSS classes not properly concatenated");

            //with spaces
            Assert.AreEqual(" test1   test2 test3 ",
                            MockRenderer.ConcatenateCssClasses(" test1 ", " test2", "test3 "),
                            "CSS classes not properly concatenated");

            //null strings
            Assert.AreEqual("test1 test3",
                            MockRenderer.ConcatenateCssClasses("test1", null, "test3"),
                            "CSS classes not properly concatenated");

            //empty strings
            Assert.AreEqual("test2",
                            MockRenderer.ConcatenateCssClasses(String.Empty, "test2", ""),
                            "CSS classes not properly concatenated");
        }
Exemple #11
0
 public void InitializeMocks()
 {
     mockRenderer    = new MockRenderer();
     mockInputMethod = new MockInputMethod();
 }