public void ViewState_LoadSaveTrack_ReturnsTheSetValue() { // Arrange: //Create the control, start tracking viewstate, then set a new Text value. var toolColorPicker = new ToolColorPicker(); toolColorPicker.EnableSsl = true; var privateObject = new PrivateObject(toolColorPicker); privateObject.Invoke("TrackViewState"); toolColorPicker.EnableSsl = false; //Save the control's state var viewState = privateObject.Invoke("SaveViewState"); //Create a new control instance and load the state //back into it, overriding any existing values var colorPicker = new ToolColorPicker(); toolColorPicker.EnableSsl = true; // Act: var pickerPrivateObject = new PrivateObject(colorPicker); pickerPrivateObject.Invoke("LoadViewState", viewState); // Assert: colorPicker.EnableSsl. ShouldBeFalse("Value restored from viewstate does not match the original value we set"); }
private void SetUp() { _shimObject = ShimsContext.Create(); _toolColorPicker = new ToolColorPicker(); _privateObject = new PrivateObject(_toolColorPicker); stubToolbar = new StubToolbar(); stubToolbar.ParentGet = () => null; stubToolbar.ImagesDirectory = DummyString; }
public void AutoPostBack_SetAndGetValue_ReturnsTheSetValue() { // Arrange: var toolColorPicker = new ToolColorPicker(); // Act: toolColorPicker.AutoPostBack = true; // Assert: toolColorPicker.AutoPostBack.ShouldBeTrue(); }
public void CellSpacing_SetAndGetValue_ReturnsTheSetValue() { // Arrange: var toolColorPicker = new ToolColorPicker(); // Act: toolColorPicker.Cellspacing = Unit.Pixel(1); // Assert: toolColorPicker.Cellspacing.ShouldBe(Unit.Pixel(1)); }
public void DropDownImage_SetAndGetValue_ReturnsTheSetValue() { // Arrange: var toolColorPicker = new ToolColorPicker(); // Act: toolColorPicker.DropDownImage = DummyDropDownImage; // Assert: toolColorPicker.DropDownImage.ShouldBe(DummyDropDownImage); }
public void BackColorItems_SetAndGetValue_ReturnsTheSetValue() { // Arrange: var toolColorPicker = new ToolColorPicker(); // Act: toolColorPicker.BackColorItems = Color.Black; // Assert: toolColorPicker.BackColorItems.ShouldBe(Color.Black); }
public void BorderStyle_SetAndGetValue_ReturnsTheSetValue() { // Arrange: var toolColorPicker = new ToolColorPicker(); // Act: toolColorPicker.BorderStyle = BorderStyle.Solid; // Assert: toolColorPicker.BorderStyle.ShouldBe(BorderStyle.Solid); }
public void BorderWidth_SetAndGetValue_ReturnsTheSetValue() { // Arrange: var toolColorPicker = new ToolColorPicker(); // Act: toolColorPicker.BorderWidth = Unit.Pixel(1); // Assert: toolColorPicker.BorderWidth.ShouldBe(Unit.Pixel(1)); }
public void BorderColorRollOver_SetAndGetValue_ReturnsTheSetValue() { // Arrange: var toolColorPicker = new ToolColorPicker(); // Act: toolColorPicker.BorderColorRollOver = Color.Black; // Assert: toolColorPicker.BorderColorRollOver.ShouldBe(Color.Black); }
public void ChangeToSelectedText_SetAndGetValue_ReturnsTheSetValue() { // Arrange: var toolColorPicker = new ToolColorPicker(); var privateObject = new PrivateObject(toolColorPicker); // Act: privateObject.SetFieldOrProperty("ChangeToSelectedText", SelectedText.Text); // Assert: var propertyValue = (SelectedText)privateObject.GetFieldOrProperty("ChangeToSelectedText"); propertyValue.ShouldBe(SelectedText.Text); }
public void ItemBorderColorRollOver_SetAndGetValue_ReturnsTheSetValue() { // Arrange: var toolColorPicker = new ToolColorPicker(); var privateObject = new PrivateObject(toolColorPicker); // Act: privateObject.SetFieldOrProperty("ItemBorderColorRollOver", Color.Black); // Assert: var propertyValue = (Color)privateObject.GetFieldOrProperty("ItemBorderColorRollOver"); propertyValue.ShouldBe(Color.Black); }
public void Text_SetAndGetValue_ReturnsDefaultValue() { // Arrange: var toolColorPicker = new ToolColorPicker(); var privateObject = new PrivateObject(toolColorPicker); privateObject.SetFieldOrProperty("ID", DummyId); // Act: // Assert: var propertyValue = privateObject.GetFieldOrProperty("Text") as string; propertyValue.ShouldNotBeNull(); propertyValue.ShouldBe(DummyId); }
public void IndentText_SetAndGetValue_ReturnsTheSetValue() { // Arrange: var toolColorPicker = new ToolColorPicker(); var privateObject = new PrivateObject(toolColorPicker); // Act: privateObject.SetFieldOrProperty("IndentText", DummyIndentText); // Assert: var propertyValue = privateObject.GetFieldOrProperty("IndentText") as string; propertyValue.ShouldBe(DummyIndentText); }
public void ItemAlign_SetAndGetValue_ReturnsTheSetValue() { // Arrange: var toolColorPicker = new ToolColorPicker(); var privateObject = new PrivateObject(toolColorPicker); // Act: privateObject.SetFieldOrProperty("ItemAlign", Align.Center); // Assert: var propertyValue = (Align)privateObject.GetFieldOrProperty("ItemAlign"); propertyValue.ShouldBe(Align.Center); }
public void ClearSelection_SetItemSelectedTrue_ItemSelectedFalse() { // Arrange var toolColorPicker = new ToolColorPicker(); var toolItem = new ToolItem { Selected = true }; toolColorPicker.Items.Add(toolItem); // Act toolColorPicker.ClearSelection(); // Assert toolItem.Selected.ShouldBeFalse(); }
public void DesignColorPicker_ForUseSquareColorFalse_WritesOutput() { // Arrange SetUp(false); var textWriter = new Moq.Mock <TextWriter>(); using (var toolColorPicker = new ToolColorPicker()) { var htmlTextWriter = new HtmlTextWriter(textWriter.Object); // Act ToolColorPickerDesigner.DesignColorPicker(ref htmlTextWriter, toolColorPicker); // Assert htmlTextWriter.ShouldSatisfyAllConditions( () => htmlTextWriter.Indent.ShouldBe(0), () => htmlTextWriter.NewLine.ShouldBeNull()); } }
public void RegisterActiveToolBarScript_ClientScriptInclude_ScriptIncluded() { // Arrange var toolColorPicker = new ToolColorPicker { Page = new Page() }; using (ShimsContext.Create()) { ShimClientScriptManager.AllInstances.GetWebResourceUrlTypeString = (type, obj1, obj2) => DummyUrl; // Act toolColorPicker.Page.RegisterActiveToolBarScript(DummyClientSideScript, ActiveToolbarScriptKey); // Assert toolColorPicker.Page.IsClientScriptBlockRegistered(ActiveToolbarScriptKey).ShouldBeTrue(); } }
/// <summary> /// Gets the HTML that is used to represent the control at design time. /// </summary> /// <returns>The HTML that is used to represent the control at design time.</returns> public override string GetDesignTimeHtml() { try { ToolColorPicker colorPicker = (ToolColorPicker)base.Component; StringWriter stringWriter = new StringWriter(); HtmlTextWriter writer = new HtmlTextWriter(stringWriter); DesignColorPicker(ref writer, colorPicker); /*StreamWriter sw = new StreamWriter(@"c:\temp\render.txt", false); * sw.Write(stringWriter.ToString()); * sw.Close();*/ return(stringWriter.ToString()); } catch (Exception e) { return(this.GetErrorDesignTimeHtml(e)); } }
/// <summary> /// Create a DropDownList object at design time. /// </summary> /// <param name="output">Output stream that contains the HTML used to represent the control.</param> /// <param name="colorPicker"><see cref="ToolColorPicker"/> object to design.</param> /// public static void DesignColorPicker(ref HtmlTextWriter output, ToolColorPicker colorPicker) { IEnumerator enumerator = colorPicker.Style.Keys.GetEnumerator(); while (enumerator.MoveNext()) { output.AddStyleAttribute((string)enumerator.Current, colorPicker.Style[(string)enumerator.Current]); } colorPicker.ControlStyle.AddAttributesToRender(output); string backImage = string.Empty; if (colorPicker.BackImage != string.Empty) { if (colorPicker.Parent != null && colorPicker.Parent is ActiveUp.WebControls.Toolbar) { backImage = "url(" + Utils.ConvertToImageDir(((Toolbar)colorPicker.Parent).ImagesDirectory, colorPicker.BackImage) + ")"; } else { backImage = "url(" + colorPicker.BackImage + ")"; } } string style = "style=\""; if (colorPicker.BackColor != Color.Empty) { style += string.Format("background-color:{0};", Utils.Color2Hex(colorPicker.BackColor)); } if (colorPicker.BorderColor != Color.Empty) { style += string.Format("border-color:{0};", Utils.Color2Hex(colorPicker.BorderColor)); } style += string.Format("border-style:{0};", colorPicker.BorderStyle.ToString()); if (colorPicker.BorderWidth != Unit.Empty) { style += string.Format("border-width:{0};", colorPicker.BorderWidth); } if (backImage != string.Empty) { style += string.Format("background-image:{0};", backImage); } style += "\""; string table = string.Empty; table += "<table"; table += string.Format(" id={0}_ddl", colorPicker.ClientID); if (colorPicker.Width != Unit.Empty) { table += string.Format(" width={0}", colorPicker.Width.ToString()); } if (colorPicker.Height != Unit.Empty) { table += string.Format(" height={0}", colorPicker.Height.ToString()); } table += " cellpadding=0 cellspacing=0"; table += string.Format(" {0}", style); table += ">"; output.Write(table); output.RenderBeginTag(HtmlTextWriterTag.Tr); output.Write("\n"); if (colorPicker.Width.IsEmpty == true) { output.AddAttribute(HtmlTextWriterAttribute.Width, "100%"); } else { output.AddAttribute(HtmlTextWriterAttribute.Width, colorPicker.Width.Value.ToString()); } output.RenderBeginTag(HtmlTextWriterTag.Td); output.AddAttribute(HtmlTextWriterAttribute.Width, "100%"); output.AddAttribute(HtmlTextWriterAttribute.Height, "100%"); output.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0"); output.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0"); output.AddAttribute(HtmlTextWriterAttribute.Border, "0"); output.RenderBeginTag(HtmlTextWriterTag.Table); output.RenderBeginTag(HtmlTextWriterTag.Tr); output.AddAttribute(HtmlTextWriterAttribute.Width, "100%"); output.AddAttribute(HtmlTextWriterAttribute.Id, colorPicker.ClientID + "_text"); if (colorPicker.UseSquareColor) { output.AddStyleAttribute("padding", "2px 2px 2px 2px"); } else { output.AddStyleAttribute("padding", "0px 0px 0px 4px"); } output.AddAttribute(HtmlTextWriterAttribute.Nowrap, null); if (colorPicker.ForeColor != Color.Empty) { output.AddStyleAttribute(HtmlTextWriterStyle.Color, Utils.Color2Hex(colorPicker.ForeColor)); } Utils.AddStyleFontAttribute(output, colorPicker.Font); output.RenderBeginTag(HtmlTextWriterTag.Td); if (colorPicker.UseSquareColor) { output.AddAttribute(HtmlTextWriterAttribute.Id, colorPicker.ClientID + "_squareColor"); output.AddAttribute(HtmlTextWriterAttribute.Width, "14px"); output.AddAttribute(HtmlTextWriterAttribute.Height, "14px"); output.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0"); output.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0"); output.AddStyleAttribute(HtmlTextWriterStyle.BackgroundColor, Utils.Color2Hex(colorPicker.SelectedColor)); output.AddStyleAttribute(HtmlTextWriterStyle.BorderColor, Utils.Color2Hex(Color.Silver)); output.AddStyleAttribute(HtmlTextWriterStyle.BorderStyle, "solid"); output.AddStyleAttribute(HtmlTextWriterStyle.BorderWidth, "1px"); output.RenderBeginTag(HtmlTextWriterTag.Table); output.RenderBeginTag(HtmlTextWriterTag.Tr); output.RenderBeginTag(HtmlTextWriterTag.Td); output.RenderEndTag(); output.RenderEndTag(); output.RenderEndTag(); } else { //output.Write(string.Format("<img src='{0}'>", Utils.ConvertToImageDir(((Toolbar)colorPicker.Parent).ImagesDirectory, colorPicker.Image,"color.gif",colorPicker.Page,colorPicker.GetType()))); output.Write(string.Format("<img src='{0}'>", Utils.ConvertToImageDir(((Toolbar)colorPicker.Parent).ImagesDirectory, colorPicker.Image, "color.gif", colorPicker.Page, colorPicker.GetType()))); } output.RenderEndTag(); output.AddAttribute(HtmlTextWriterAttribute.Height, "100%"); output.RenderBeginTag(HtmlTextWriterTag.Td); // drop down image output.AddAttribute(HtmlTextWriterAttribute.Width, "100%"); output.AddAttribute(HtmlTextWriterAttribute.Height, "100%"); // Added by PMENGAL output.AddAttribute(HtmlTextWriterAttribute.Width, "100%"); output.AddAttribute(HtmlTextWriterAttribute.Height, "100%"); output.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0"); output.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0"); output.RenderBeginTag(HtmlTextWriterTag.Table); output.RenderBeginTag(HtmlTextWriterTag.Tr); output.AddAttribute(HtmlTextWriterAttribute.Height, "100%"); output.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0"); output.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0"); output.RenderBeginTag(HtmlTextWriterTag.Td); output.AddAttribute(HtmlTextWriterAttribute.Border, "0"); if (colorPicker.DropDownImage != string.Empty) { if (colorPicker.Parent != null && colorPicker.Parent is ActiveUp.WebControls.Toolbar) { output.AddAttribute(HtmlTextWriterAttribute.Src, Utils.ConvertToImageDir(((Toolbar)colorPicker.Parent).ImagesDirectory, colorPicker.DropDownImage, "down.gif", colorPicker.Page, colorPicker.GetType())); } else { output.AddAttribute(HtmlTextWriterAttribute.Src, colorPicker.DropDownImage); } } else { if (colorPicker.Parent != null && colorPicker.Parent is ActiveUp.WebControls.Toolbar) #if (!FX1_1) { output.AddAttribute(HtmlTextWriterAttribute.Src, Utils.ConvertToImageDir(((Toolbar)colorPicker.Parent).ImagesDirectory, "", "down.gif", colorPicker.Page, colorPicker.GetType())); } #else { output.AddAttribute(HtmlTextWriterAttribute.Src, Utils.ConvertToImageDir(((Toolbar)colorPicker.Parent).ImagesDirectory, "down.gif")); }