Clover.NET coverage report - Coverage

Coverage timestamp: viernes, 12 de agosto de 2005 12:53:38 PM

File Stats: LOC: 154   Methods: 5
NCLOC: 71 Classes: 1
 
Source File Conditionals Statements Methods TOTAL
Web\WebControls\ChangePassword.cs 83,3 % 93,5 % 100,0 % 92,9 %
coverage coverage
1   #region Copyright
2   /*
3   ShowX. Maps business objects into presentation layer.
4   Copyright (C) 2005 Jesus Diaz.
5  
6   This library is free software; you can redistribute it and/or
7   modify it under the terms of the GNU Lesser General Public
8   License as published by the Free Software Foundation; either
9   version 2.1 of the License, or (at your option) any later version.
10  
11   This library is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14   Lesser General Public License for more details.
15  
16   You should have received a copy of the GNU Lesser General Public
17   License along with this library; if not, write to the Free Software
18   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
19  
20   For project details see: http://showx.sourceforge.net
21   */
22   #endregion
23  
24   using System.ComponentModel;
25   using System.Web.UI;
26   using System.Web.UI.WebControls;
27   using ShowX.Model;
28  
29   namespace ShowX.Web.WebControls
30   {
31   /// <summary>
32   /// ChangePassword control defines a box useful to update a user password, with
33   /// equality checking.
34   /// </summary>
35   [DefaultProperty("Text"),
36   ToolboxData("<{0}:ChangePassword runat=server></{0}:ChangePassword>")]
37   public class ChangePassword : ValidatedControl
38   {
39   /// <summary>
40   /// Textbox to store password
41   /// </summary>
42   protected TextBox passTB1;
43  
44   /// <summary>
45   /// Textbox to store confirmation of password
46   /// </summary>
47   protected TextBox passTB2;
48  
49   /// <summary>
50   /// Constructor
51   /// </summary>
52 29 public ChangePassword()
53   {
54 29 Controls.Add(passTB1 = new TextBox());
55 29 Controls.Add(passTB2 = new TextBox());
56 29 passTB1.TextMode = TextBoxMode.Password;
57 29 passTB1.Width = Unit.Percentage(100);
58 29 passTB2.TextMode = TextBoxMode.Password;
59 29 passTB2.Width = Unit.Percentage(100);
60 29 messageL.Text = "don't match";
61   }
62  
63   /// <summary>
64   /// Allow to check whether the password entered are te same
65   /// </summary>
66   /// <returns>True if the input value is te same, false otherwise</returns>
67 6 public override bool Validate(object context)
68   {
69 6 string message = string.Empty;
70 6 Validated = true;
71  
72 6 foreach(IValidationMap val in Validators) {
73  
74 12 if (!val.Validate(context,passTB1.Text)) {
75  
76 4 message += " " + val.Message + ".";
77 4 Validated = false ;
78  
79   }
80   }
81  
82 6 if (passTB1.Text != passTB2.Text) {
83  
84 0 message += " Passwords don't match.";
85 0 Validated = false ;
86   }
87  
88 6 messageL.Text = message;
89  
90 6 return Validated;
91   }
92  
93   /// <summary>
94   /// Reflex the password value
95   /// </summary>
96   public string Password
97   {
98 4 get { return passTB1.Text; }
99   }
100  
101   /// <summary>
102   /// Merge current styles with a new one.
103   /// </summary>
104   /// <param name="style">New style to merge.</param>
105 29 public override void MergeControlStyle(Style style)
106   {
107 29 passTB1.MergeStyle(style);
108 29 passTB2.MergeStyle(style);
109   }
110  
111   /// <summary>
112   /// Method Render is in charge of render the control to html code
113   /// </summary>
114   /// <param name="writer">Writer to output html code</param>
115 25 protected override void Render(HtmlTextWriter writer)
116   {
117 25 writer.Write(@"
118   <table border=0 cellpadding=0 width=100%>
119   <tbody>
120   <tr>
121   <td>");
122  
123 25 passTB1.RenderControl(writer);
124  
125 25 writer.Write(@"
126   </td>
127   </tr>
128   <tr>
129   <td>");
130  
131 25 passTB2.RenderControl(writer);
132  
133 25 writer.Write(@"
134   </td>
135   </tr>");
136  
137 25 if (!Validated) {
138  
139 2 writer.Write(@"
140   <tr>
141   <td>");
142  
143 2 messageL.RenderControl(writer);
144 2 writer.Write(@"
145   </td>
146   </tr>");
147  
148   }
149 25 writer.Write(@"
150   </tbody>
151   </table>");
152   }
153   }
154   }