You've already forked linux-packaging-mono
acceptance-tests
data
debian
docs
external
ikvm-native
llvm
m4
man
mcs
build
class
Accessibility
Commons.Xml.Relaxng
Cscompmgd
CustomMarshalers
Facades
I18N
IBM.Data.DB2
ICSharpCode.SharpZipLib
Microsoft.Build
Microsoft.Build.Engine
Microsoft.Build.Framework
Microsoft.Build.Tasks
Microsoft.Build.Utilities
Microsoft.CSharp
Microsoft.NuGet.Build.Tasks
Microsoft.VisualC
Microsoft.Web.Infrastructure
MicrosoftAjaxLibrary
Mono.Btls.Interface
Mono.C5
Mono.CSharp
Mono.Cairo
Mono.Cecil
Mono.Cecil.Mdb
Mono.CodeContracts
Mono.CompilerServices.SymbolWriter
Mono.Data.Sqlite
Mono.Data.Tds
Mono.Debugger.Soft
Mono.Http
Mono.Management
Mono.Messaging
Mono.Messaging.RabbitMQ
Mono.Options
Mono.Parallel
Mono.Posix
Mono.Profiler.Log
Mono.Runtime.Tests
Mono.Security
Mono.Security.Win32
Mono.Simd
Mono.Tasklets
Mono.WebBrowser
Mono.XBuild.Tasks
Novell.Directory.Ldap
PEAPI
RabbitMQ.Client
SMDiagnostics
System
System.ComponentModel.Composition.4.5
System.ComponentModel.DataAnnotations
System.Configuration
System.Configuration.Install
System.Core
System.Data
System.Data.DataSetExtensions
System.Data.Entity
System.Data.Linq
System.Data.OracleClient
System.Data.Services
System.Data.Services.Client
System.Deployment
System.Design
System.DirectoryServices
System.DirectoryServices.Protocols
System.Drawing
System.Drawing.Design
System.Dynamic
System.EnterpriseServices
System.IO.Compression
System.IO.Compression.FileSystem
System.IdentityModel
System.IdentityModel.Selectors
System.Json
System.Json.Microsoft
System.Management
System.Messaging
System.Net
System.Net.Http
System.Net.Http.Formatting
System.Net.Http.WebRequest
System.Net.Http.WinHttpHandler
System.Numerics
System.Numerics.Vectors
System.Reactive.Core
System.Reactive.Debugger
System.Reactive.Experimental
System.Reactive.Interfaces
System.Reactive.Linq
System.Reactive.Observable.Aliases
System.Reactive.PlatformServices
System.Reactive.Providers
System.Reactive.Runtime.Remoting
System.Reactive.Windows.Forms
System.Reactive.Windows.Threading
System.Reflection.Context
System.Runtime.Caching
System.Runtime.CompilerServices.Unsafe
System.Runtime.DurableInstancing
System.Runtime.Remoting
System.Runtime.Serialization
System.Runtime.Serialization.Formatters.Soap
System.Security
System.ServiceModel
System.ServiceModel.Activation
System.ServiceModel.Discovery
System.ServiceModel.Internals
System.ServiceModel.Routing
System.ServiceModel.Web
System.ServiceProcess
System.Threading.Tasks.Dataflow
System.Transactions
System.Web
Assembly
Documentation
Mono.Web.Util
ReferenceSources
System.Collections.Concurrent
System.Web
System.Web.Caching
System.Web.Compilation
System.Web.Configuration_2.0
System.Web.Handlers
System.Web.Hosting
System.Web.Mail
System.Web.Management
System.Web.Profile
System.Web.Properties
System.Web.Security
System.Web.SessionState_2.0
System.Web.UI
System.Web.UI.Adapters
System.Web.UI.HtmlControls
System.Web.UI.WebControls
System.Web.UI.WebControls.Adapters
System.Web.UI.WebControls.WebParts
System.Web.Util
Test
Cas
System.Web
System.Web.Caching
System.Web.Compilation
System.Web.Configuration
System.Web.Handlers
System.Web.Hosting
System.Web.Mail
System.Web.Profile
System.Web.Security
System.Web.SessionState
System.Web.UI
System.Web.UI.Adapters
System.Web.UI.HtmlControls
System.Web.UI.WebControls
AccessDataSourceTest.cs
AdCreatedEventArgsCas.cs
AdCreatedEventArgsTest.cs
AutoGeneratedFieldTest.cs
BaseCompareValidatorCas.cs
BaseCompareValidatorTest.cs
BaseDataBoundControlCas.cs
BaseDataBoundControlTest.cs
BaseDataListCas.cs
BaseDataListTest.cs
BaseValidatorCas.cs
BaseValidatorTest.cs
BoundColumnCas.cs
BoundColumnTest.cs
BoundFieldTest.cs
BulletedListTest.cs
ButtonColumnCas.cs
ButtonColumnTest.cs
ButtonFieldBaseTest.cs
ButtonFieldTest.cs
ButtonTest.cs
CalandarCas.cs
CalendarDayCas.cs
CalendarDayTest.cs
CalendarTest.cs
CallBackTest.cs
ChangePasswordTest.cs
CheckBoxCas.cs
CheckBoxFieldTest.cs
CheckBoxListCas.cs
CheckBoxListTest.cs
CheckBoxTest.cs
CircleHotSpotTest.cs
CommandFieldTest.cs
CompareValidatorCas.cs
CompareValidatorTest.cs
CompleteWizardStepTest.cs
CompositeControlCas.cs
CompositeControlTest.cs
CompositeDataBoundControlTest.cs
ContentTest.cs
ControlParameterTest.cs
CookieParameterTest.cs
CreateUserWizardStepTest.cs
CreateUserWizardTest.cs
CrossPagePostingTest.cs
CustomValidatorCas.cs
CustomValidatorTest.cs
DataBoundControlCas.cs
DataBoundControlTest.cs
DataControlFieldCollectionTest.cs
DataControlFieldTest.cs
DataGridCas.cs
DataGridColumnCas.cs
DataGridColumnTest.cs
DataGridItemCas.cs
DataGridItemCollectionCas.cs
DataGridItemCollectionTest.cs
DataGridItemTest.cs
DataGridPagerStyleCas.cs
DataGridPagerStyleTest.cs
DataGridTest.cs
DataKeyArrayTest.cs
DataKeyCollectionCas.cs
DataKeyCollectionTest.cs
DataKeyTest.cs
DataListCas.cs
DataListItemCas.cs
DataListItemCollectionCas.cs
DataListItemCollectionTest.cs
DataListItemTest.cs
DataListTest.cs
DataSourceControlTest.cs
DataSourceViewTest.cs
DetailsViewRowCollectionTest.cs
DetailsViewRowTest.cs
DetailsViewTest.cs.REMOVED.git-id
DropDownListCas.cs
DropDownListTest.cs
EditCommandColumnCas.cs
EditCommandColumnTest.cs
FileUploadTest.cs
FontInfoCas.cs
FontInfoTest.cs
FontNamesConverterCas.cs
FontNamesConverterTest.cs
FontUnitCas.cs
FontUnitTest.cs
FormParameterTest.cs
FormViewCas.cs
FormViewRowTest.cs
FormViewTest.cs
GridViewRowCollectionTest.cs
GridViewRowTest.cs
GridViewTest.cs.REMOVED.git-id
HierarchicalDataBoundControlTest.cs
HotSpotCollectionTest.cs
HotSpotTest.cs
HyperLinkCas.cs
HyperLinkColumnCas.cs
HyperLinkColumnTest.cs
HyperLinkFieldTest.cs
HyperLinkTest.cs
ImageButtonCas.cs
ImageButtonTest.cs
ImageCas.cs
ImageFieldTest.cs
ImageMapTest.cs
ImageTest.cs
LabelCas.cs
LabelTest.cs
LinkButtonCas.cs
LinkButtonTest.cs
ListBoxCas.cs
ListBoxTest.cs
ListControlCas.cs
ListControlTest.cs
ListItemCas.cs
ListItemCollectionCas.cs
ListItemCollectionTest.cs
ListItemTest.cs
LiteralCas.cs
LiteralTest.cs
LoginCas.cs
LoginNameCas.cs
LoginNameTest.cs
LoginStatusCas.cs
LoginStatusTest.cs
LoginTest.cs
MappingUrlTest.cs
MasterPageTest.cs
MenuItemBindingTest.cs
MenuTest.cs
MonthChangedEventArgsCas.cs
MonthChangedEventArgsTest.cs
MultiViewControlBuilderTest.cs
MultiViewTest.cs
ObjectDataSourceTest.cs
ObjectDataSourceViewTest.cs
PagedDataSourceCas.cs
PagedDataSourceTest.cs
PagerSettingsTest.cs
PanelCas.cs
PanelTest.cs
ParameterTest.cs
PasswordRecoveryTest.cs
PolygonHotSpotTest.cs
QueryStringParameterTest.cs
RadioButtonCas.cs
RadioButtonListCas.cs
RadioButtonListTest.cs
RadioButtonTest.cs
RangeValidatorCas.cs
RangeValidatorTest.cs
RectangleHotSpotTest.cs
RegularExpressionValidatorCas.cs
RegularExpressionValidatorTest.cs
RepeatInfoCas.cs
RepeatInfoTest.auto.4.0.cs.REMOVED.git-id
RepeatInfoTest.cs
RepeatInfoUser.cs
RepeaterCas.cs
RepeaterItemCollectionTest.cs
RepeaterTest.cs
RequiredFieldValidatorCas.cs
RoleGroupCas.cs
RoleGroupCollectionCas.cs
RoleGroupCollectionTest.cs
RoleGroupTest.cs
RouteParameterTest.cs
SelectedDatesCollectionCas.cs
SelectedDatesCollectionTest.cs
SessionParameterTest.cs
SiteMapDataSourceTest.cs
SiteMapPathTest.cs
SqlDataSourceTest.cs
SqlDataSourceViewTest.cs
StyleCas.cs
StyleTest.cs
TableCas.cs
TableCellCas.cs
TableCellTest.cs
TableFooterRowCas.cs
TableFooterRowTest.cs
TableHeaderCellCas.cs
TableHeaderCellTest.cs
TableHeaderRowCas.cs
TableHeaderRowTest.cs
TableItemStyleCas.cs
TableItemStyleTest.cs
TableRowCas.cs
TableRowTest.cs
TableSectionStyleCas.cs
TableSectionStyleTest.cs
TableStyleCas.cs
TableStyleTest.cs
TableTest.cs
TargetConverterCas.cs
TargetConverterTest.cs
TemplateFieldTest.cs
TestControlIDConverter.cs
TextBoxCas.cs
TextBoxTest.cs
ThemeTest.cs
TreeNodeBindingCollectionTest.cs
TreeNodeBindingTest.cs
TreeNodeCollectionTest.cs
TreeNodeStyleCollectionTest.cs
TreeNodeStyleTest.cs
TreeNodeTest.cs
TreeViewCas.cs
TreeViewTest.cs.REMOVED.git-id
UnitCas.cs
UnitConverterCas.cs
UnitConverterTest.cs
UnitTest.cs
ValidatedControlConverterCas.cs
ValidatedControlConverterTest.cs
ValidationSummaryCas.cs
ValidationSummaryTest.cs
ValidatorTest.cs
ViewTest.cs
WebColorConverterCas.cs
WebColorConverterTest.cs
WebControlCas.cs
WebControlTest.cs
WizardStepBaseTest.cs
WizardStepCollectionTest.cs
WizardStepTest.cs
WizardTest.cs
XmlCas.cs
XmlDataSourceCas.cs
XmlDataSourceTest.cs
XmlTest.cs
System.Web.UI.WebControls.Adapters
System.Web.UI.WebControls.WebParts
System.Web.Util
TestMonoWeb
mainsoft
standalone
standalone-runner-support
standalone-tests
tools
DataBinderTests.cs
Makefile
test.aspx
test2.aspx
test3.aspx
test4.aspx
test5.aspx
test6.aspx
resources
ASPState.sql
Makefile
SQLiteProviders_DatabaseSchema.sql
System.Web.dll.sources
System.Web_standalone_test.dll.sources
System.Web_test.dll.sources
UplevelHelperDefinitions.xml
standalone-runner-support.dll.sources
System.Web.Abstractions
System.Web.ApplicationServices
System.Web.DynamicData
System.Web.Extensions
System.Web.Extensions.Design
System.Web.Http
System.Web.Http.SelfHost
System.Web.Http.WebHost
System.Web.Mobile
System.Web.Mvc3
System.Web.Razor
System.Web.RegularExpressions
System.Web.Routing
System.Web.Services
System.Web.WebPages
System.Web.WebPages.Deployment
System.Web.WebPages.Razor
System.Windows
System.Windows.Forms
System.Windows.Forms.DataVisualization
System.Workflow.Activities
System.Workflow.ComponentModel
System.Workflow.Runtime
System.XML
System.Xaml
System.Xml.Linq
System.Xml.Serialization
SystemWebTestShim
WebMatrix.Data
WindowsBase
aot-compiler
corlib
dlr
doc
legacy
lib
monodoc
notes
reference-assemblies
referencesource
test-helpers
LICENSE
Makefile
Open.snk
README
ecma.pub
mono.pub
mono.snk
msfinal.pub
reactive.pub
silverlight.pub
winfx.pub
winfx3.pub
docs
errors
ilasm
jay
mcs
packages
tests
tools
AUTHORS
COPYING
INSTALL.txt
Makefile
MonoIcon.png
README
ScalableMonoIcon.svg
mkinstalldirs
mk
mono
msvc
netcore
po
runtime
samples
scripts
support
tools
COPYING.LIB
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
code_of_conduct.md
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-uninstalled.pc.in
test-driver
winconfig.h
547 lines
18 KiB
C#
547 lines
18 KiB
C#
//
|
|
// Tests for System.Web.UI.WebControls.BoundFieldTest.cs
|
|
//
|
|
// Author:
|
|
// Yoni Klein (yonik@mainsoft.com)
|
|
//
|
|
//
|
|
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
|
|
//
|
|
// Permission is hereby granted, free of charge, to any person obtaining
|
|
// a copy of this software and associated documentation files (the
|
|
// "Software"), to deal in the Software without restriction, including
|
|
// without limitation the rights to use, copy, modify, merge, publish,
|
|
// distribute, sublicense, and/or sell copies of the Software, and to
|
|
// permit persons to whom the Software is furnished to do so, subject to
|
|
// the following conditions:
|
|
//
|
|
// The above copyright notice and this permission notice shall be
|
|
// included in all copies or substantial portions of the Software.
|
|
//
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using System.IO;
|
|
using System.Drawing;
|
|
using System.Collections;
|
|
using System.Collections.Specialized;
|
|
using Image = System.Web.UI.WebControls.Image;
|
|
using NUnit.Framework;
|
|
using System.Globalization;
|
|
using MonoTests.SystemWeb.Framework;
|
|
using MonoTests.stand_alone.WebHarness;
|
|
|
|
|
|
|
|
namespace MonoTests.System.Web.UI.WebControls
|
|
{
|
|
class EncodingTest
|
|
{
|
|
public override string ToString ()
|
|
{
|
|
return "<EncodingTest>&";
|
|
}
|
|
}
|
|
|
|
class PokerBoundField : BoundField
|
|
{
|
|
public Button bindbutoon;
|
|
|
|
public PokerBoundField () {
|
|
TrackViewState ();
|
|
bindbutoon = new Button ();
|
|
bindbutoon.DataBinding += new EventHandler (OnDataBindField);
|
|
}
|
|
|
|
|
|
public StateBag StateBag {
|
|
get { return base.ViewState; }
|
|
}
|
|
|
|
public bool DoSupportsHtmlEncode {
|
|
get {
|
|
return base.SupportsHtmlEncode;
|
|
}
|
|
}
|
|
|
|
public void DoCopyProperties (DataControlField newField) {
|
|
base.CopyProperties (newField);
|
|
}
|
|
|
|
public DataControlField DoCreateField () {
|
|
return base.CreateField ();
|
|
}
|
|
|
|
public string DoFormatDataValue (object dataValue, bool encode) {
|
|
return this.FormatDataValue (dataValue, encode);
|
|
}
|
|
|
|
public object DoGetDesignTimeValue () {
|
|
return base.GetDesignTimeValue ();
|
|
}
|
|
|
|
public object DoGetValue (Control controlContainer) {
|
|
return base.GetValue (controlContainer);
|
|
}
|
|
|
|
public void DoInitializeDataCell (DataControlFieldCell cell, DataControlRowState rowState) {
|
|
base.InitializeDataCell (cell, rowState);
|
|
}
|
|
|
|
public void DoOnDataBindField (object sender, EventArgs e) {
|
|
base.OnDataBindField (sender, e);
|
|
}
|
|
|
|
public Control GetControl {
|
|
get { return base.Control; }
|
|
}
|
|
|
|
public object DoSaveViewState ()
|
|
{
|
|
return SaveViewState ();
|
|
}
|
|
}
|
|
|
|
|
|
[Serializable]
|
|
[TestFixture]
|
|
public class BoundFieldTest
|
|
{
|
|
[TestFixtureSetUp]
|
|
public void SetUp ()
|
|
{
|
|
WebTest.CopyResource (GetType (), "BoundField_Bug646505.aspx", "BoundField_Bug646505.aspx");
|
|
WebTest.CopyResource (GetType (), "BoundField_Bug646505.aspx.cs", "BoundField_Bug646505.aspx.cs");
|
|
}
|
|
|
|
[Test (Description="Bug 646505")]
|
|
public void BoundField_Bug646505 ()
|
|
{
|
|
string originalHtml = "<div>\n\t<table cellspacing=\"0\" rules=\"all\" border=\"1\" id=\"gridView\" style=\"border-collapse:collapse;\">\n\t\t<tr>\n\t\t\t<th scope=\"col\"> </th><th scope=\"col\"> </th>\n\t\t</tr><tr>\n\t\t\t<td><a href=\"javascript:__doPostBack('gridView$ctl02$ctl00','')\">Update</a> <a href=\"javascript:__doPostBack('gridView','Cancel$0')\">Cancel</a></td><td><input name=\"gridView$ctl02$ctl02\" type=\"text\" value=\"False\" /></td>\n\t\t</tr><tr>\n\t\t\t<td><a href=\"javascript:__doPostBack('gridView','Edit$1')\">Edit</a></td><td>False</td>\n\t\t</tr>\n\t</table>\n</div>\n";
|
|
WebTest t = new WebTest ("BoundField_Bug646505.aspx");
|
|
t.Run ();
|
|
|
|
FormRequest fr = new FormRequest (t.Response, "form1");
|
|
fr.Controls.Add ("__EVENTTARGET");
|
|
fr.Controls.Add ("__EVENTARGUMENT");
|
|
fr.Controls ["__EVENTTARGET"].Value = "gridView";
|
|
fr.Controls ["__EVENTARGUMENT"].Value = "Edit$0";
|
|
t.Request = fr;
|
|
string pageHtml = t.Run ();
|
|
string renderedHtml = HtmlDiff.GetControlFromPageHtml (pageHtml);
|
|
|
|
HtmlDiff.AssertAreEqual (originalHtml, renderedHtml, "#A1");
|
|
}
|
|
|
|
[Test]
|
|
public void BoundField_DefaultProperty () {
|
|
PokerBoundField bf = new PokerBoundField ();
|
|
Assert.AreEqual ("!", PokerBoundField.ThisExpression, "StaticThisExpression");
|
|
Assert.AreEqual ("", bf.DataField, "DataField");
|
|
Assert.AreEqual ("", bf.DataFormatString, "DataFormatString");
|
|
Assert.AreEqual ("", bf.HeaderText, "HeaderText");
|
|
Assert.AreEqual (true, bf.HtmlEncode, "HtmlEncode");
|
|
Assert.AreEqual ("", bf.NullDisplayText, "NullDisplayText");
|
|
Assert.AreEqual (false, bf.ReadOnly, "ReadOnly");
|
|
|
|
//Protected
|
|
Assert.AreEqual (true, bf.DoSupportsHtmlEncode, "SupportsHtmlEncode");
|
|
}
|
|
|
|
[Test]
|
|
public void BoundField_DefaultPropertyNotWorking () {
|
|
PokerBoundField bf = new PokerBoundField ();
|
|
Assert.AreEqual (false, bf.ApplyFormatInEditMode, "ApplyFormatInEditMode");
|
|
Assert.AreEqual (true, bf.ConvertEmptyStringToNull, "ConvertEmptyStringToNull");
|
|
}
|
|
|
|
[Test]
|
|
public void BoundField_AssignProperty () {
|
|
PokerBoundField bf = new PokerBoundField ();
|
|
bf.ConvertEmptyStringToNull = false;
|
|
Assert.AreEqual (false, bf.ConvertEmptyStringToNull, "ConvertEmptyStringToNull");
|
|
bf.DataField = "test";
|
|
Assert.AreEqual ("test", bf.DataField, "DataField");
|
|
bf.DataFormatString = "test";
|
|
Assert.AreEqual ("test", bf.DataFormatString, "DataFormatString");
|
|
bf.HeaderText = "test";
|
|
Assert.AreEqual ("test", bf.HeaderText, "HeaderText");
|
|
bf.HtmlEncode = false;
|
|
Assert.AreEqual (false, bf.HtmlEncode, "HtmlEncode");
|
|
bf.NullDisplayText = "test";
|
|
Assert.AreEqual ("test", bf.NullDisplayText, "NullDisplayText");
|
|
bf.ReadOnly = true;
|
|
Assert.AreEqual (true, bf.ReadOnly, "ReadOnly");
|
|
}
|
|
|
|
[Test]
|
|
public void BoundField_AssignPropertyNotWorking () {
|
|
PokerBoundField bf = new PokerBoundField ();
|
|
bf.ApplyFormatInEditMode = true;
|
|
Assert.AreEqual (true, bf.ApplyFormatInEditMode, "ApplyFormatInEditMode");
|
|
}
|
|
|
|
[Test]
|
|
public void BoundField_ExtractValuesFromCell () {
|
|
PokerBoundField bf = new PokerBoundField ();
|
|
OrderedDictionary dictionary = new OrderedDictionary ();
|
|
DataControlFieldCell cell = new DataControlFieldCell (null);
|
|
cell.Text = "test";
|
|
bf.ExtractValuesFromCell (dictionary, cell, DataControlRowState.Normal, true);
|
|
Assert.AreEqual (1, dictionary.Count, "ExtractValuesFromCellCount");
|
|
Assert.AreEqual ("test", dictionary [0].ToString (), "ExtractValuesFromCellValue");
|
|
}
|
|
|
|
[Test]
|
|
public void BoundField_Initialize () {
|
|
// This method initilize to private fields in a base class DataControlField
|
|
// Always return false
|
|
PokerBoundField bf = new PokerBoundField ();
|
|
Control control = new Control ();
|
|
control.ID = "test";
|
|
bool res = bf.Initialize (true, control);
|
|
// Assert.AreEqual (false, res, "InitializeResult");
|
|
Assert.AreEqual ("test", bf.GetControl.ID, "InitializeControl");
|
|
}
|
|
|
|
[Test]
|
|
public void BoundField_InitializeCell () {
|
|
PokerBoundField bf = new PokerBoundField ();
|
|
// Header text
|
|
DataControlFieldCell cell = new DataControlFieldCell (null);
|
|
bf.HeaderText = "headertext";
|
|
|
|
bf.InitializeCell (cell, DataControlCellType.Header, DataControlRowState.Edit, 1);
|
|
Assert.AreEqual ("headertext", cell.Text, "InitializeCellHeaderText");
|
|
// Empty header text
|
|
bf.HeaderText = "";
|
|
bf.InitializeCell (cell, DataControlCellType.Header, DataControlRowState.Edit, 1);
|
|
Assert.AreEqual (" ", cell.Text, "InitializeCellEmpty");
|
|
|
|
bf.HeaderText = "headertext";
|
|
// Header image url not empty
|
|
bf.HeaderImageUrl = "headerurl";
|
|
bf.InitializeCell (cell, DataControlCellType.Header, DataControlRowState.Edit, 1);
|
|
if (cell.Controls [0] is Image) {
|
|
Image image = (Image) cell.Controls [0];
|
|
Assert.AreEqual ("headerurl", image.ImageUrl, "InitializeCellHeaderImageUrl");
|
|
}
|
|
else {
|
|
Assert.Fail ("Header Image dos not created");
|
|
}
|
|
|
|
// Footer empty
|
|
bf.FooterText = "footertext";
|
|
bf.InitializeCell (cell, DataControlCellType.Footer, DataControlRowState.Edit, 1);
|
|
Assert.AreEqual ("footertext", cell.Text, "InitializeCellFooterText");
|
|
bf.FooterText = "";
|
|
bf.InitializeCell (cell, DataControlCellType.Footer, DataControlRowState.Edit, 1);
|
|
Assert.AreEqual (" ", cell.Text, "InitializeCellFooterEmpty");
|
|
}
|
|
|
|
[Test]
|
|
public void BoundField_ValidateSupportsCallback () {
|
|
//This method has been implemented as an empty method
|
|
}
|
|
|
|
[Test]
|
|
public void BoundField_SortExpression () {
|
|
// Sorting enable = true , link button must be created
|
|
PokerBoundField bf = new PokerBoundField ();
|
|
// Header text
|
|
DataControlFieldCell cell = new DataControlFieldCell (null);
|
|
|
|
bf.HeaderImageUrl = "";
|
|
bf.SortExpression = "a";
|
|
bf.HeaderText = "sortbutton";
|
|
bf.Initialize (true, new Control ()); // _base._sortingenable set to true
|
|
bf.InitializeCell (cell, DataControlCellType.Header, DataControlRowState.Edit, 1);
|
|
if (cell.Controls [0] is Button) { // mono
|
|
Button lb = (Button) cell.Controls [0];
|
|
Assert.AreEqual ("Sort", lb.CommandName, "InitializeCellHeaderSortButtonCommand");
|
|
Assert.AreEqual ("a", lb.CommandArgument, "InitializeCellHeaderSortButtonArgument");
|
|
Assert.AreEqual ("sortbutton", lb.Text, "InitializeCellHeaderSortButtonText");
|
|
|
|
}
|
|
else if (cell.Controls [0] is LinkButton) { // .net
|
|
LinkButton lb = (LinkButton) cell.Controls [0];
|
|
Assert.AreEqual ("Sort", lb.CommandName, "InitializeCellHeaderSortButtonCommand");
|
|
Assert.AreEqual ("a", lb.CommandArgument, "InitializeCellHeaderSortButtonArgument");
|
|
Assert.AreEqual ("sortbutton", lb.Text, "InitializeCellHeaderSortButtonText");
|
|
|
|
}
|
|
else {
|
|
Assert.Fail ("Sort button does not created");
|
|
}
|
|
}
|
|
|
|
|
|
[Test]
|
|
public void BoundField_CopyProperties () {
|
|
PokerBoundField bf = new PokerBoundField ();
|
|
BoundField copy = new BoundField ();
|
|
// Look not working property
|
|
// bf.ApplyFormatInEditMode = true;
|
|
bf.ConvertEmptyStringToNull = true;
|
|
bf.DataField = "test";
|
|
bf.DataFormatString = "test";
|
|
bf.HtmlEncode = true;
|
|
bf.NullDisplayText = "test";
|
|
bf.ReadOnly = true;
|
|
bf.DoCopyProperties (copy);
|
|
// Look not working property
|
|
// Assert.AreEqual (true, copy.ApplyFormatInEditMode, "ApplyFormatInEditMode");
|
|
Assert.AreEqual (true, copy.ConvertEmptyStringToNull, "ConvertEmptyStringToNull");
|
|
Assert.AreEqual ("test", copy.DataField, "DataField");
|
|
Assert.AreEqual ("test", copy.DataFormatString, "DataFormatString");
|
|
Assert.AreEqual (true, copy.HtmlEncode, "HtmlEncode");
|
|
Assert.AreEqual ("test", copy.NullDisplayText, "NullDisplayText");
|
|
Assert.AreEqual (true, copy.ReadOnly, "ReadOnly");
|
|
}
|
|
|
|
[Test]
|
|
public void BoundField_CreateField () {
|
|
PokerBoundField bf = new PokerBoundField ();
|
|
BoundField newfield = (BoundField) bf.DoCreateField ();
|
|
Assert.IsNotNull (newfield, "CreateField");
|
|
}
|
|
|
|
[Test]
|
|
public void BoundField_FormatDataValue () {
|
|
string result;
|
|
PokerBoundField bf = new PokerBoundField ();
|
|
|
|
bf.NullDisplayText = "NullDisplayText";
|
|
result = bf.DoFormatDataValue (null, false);
|
|
Assert.AreEqual ("NullDisplayText", result, "FormatDataValueNullDataValue");
|
|
|
|
result = bf.DoFormatDataValue ("test", true);
|
|
Assert.AreEqual ("test", result, "FormatDataValueTextDataValue");
|
|
|
|
result = bf.DoFormatDataValue ("", true);
|
|
Assert.AreEqual ("NullDisplayText", result, "FormatEmptyDataValue");
|
|
|
|
bf.DataFormatString = "-{0,8:G}-";
|
|
result = bf.DoFormatDataValue (10, false);
|
|
Assert.AreEqual ("- 10-", result, "FormatDataValueWithFormat");
|
|
|
|
bf.DataFormatString = "-{0:X}-";
|
|
result = bf.DoFormatDataValue (10, true);
|
|
Assert.AreEqual ("-A-", result, "FormatDataValueWithFormatAndHtmlEncode");
|
|
|
|
bf.DataFormatString = "-{0:X}-";
|
|
result = bf.DoFormatDataValue (10, false);
|
|
Assert.AreEqual ("-A-", result, "FormatDataValueWithFormatAndNoHtmlEncode");
|
|
|
|
bf.HtmlEncodeFormatString = false;
|
|
bf.DataFormatString = "-{0:X}-";
|
|
result = bf.DoFormatDataValue (10, true);
|
|
Assert.AreEqual ("-10-", result, "NoHtmlEncodeFormatString_HtmlEncode");
|
|
|
|
bf.DataFormatString = "-{0:X}-";
|
|
result = bf.DoFormatDataValue (10, false);
|
|
Assert.AreEqual ("-A-", result, "NoHtmlEncodeFormatString_NoHtmlEncode");
|
|
}
|
|
|
|
[Test]
|
|
public void HtmlEncodeFormatString ()
|
|
{
|
|
string formatString = "<script>alert ('{0}');</script>";
|
|
var bf = new PokerBoundField ();
|
|
|
|
Assert.IsTrue (bf.HtmlEncodeFormatString, "#A1-2");
|
|
Assert.IsTrue (bf.HtmlEncode, "#A1-2");
|
|
Assert.IsTrue (bf.DoSupportsHtmlEncode, "#A1-3");
|
|
|
|
bf.DataFormatString = formatString;
|
|
Assert.AreEqual ("<script>alert ('<test>');</script>", bf.DoFormatDataValue ("<test>", true), "#A2");
|
|
Assert.AreEqual (String.Format (formatString, "<test>"), bf.DoFormatDataValue ("<test>", false), "#A3");
|
|
|
|
bf.HtmlEncodeFormatString = false;
|
|
Assert.AreEqual ("<script>alert ('<test>');</script>", bf.DoFormatDataValue ("<test>", true), "#A4");
|
|
|
|
var ec = new EncodingTest ();
|
|
bf.HtmlEncodeFormatString = true;
|
|
Assert.AreEqual ("<script>alert ('<EncodingTest>&');</script>", bf.DoFormatDataValue (ec, true), "#A4");
|
|
}
|
|
|
|
[Test]
|
|
public void BoundField_GetDesignTimeValue () {
|
|
string result;
|
|
PokerBoundField bf = new PokerBoundField ();
|
|
result = (string) bf.DoGetDesignTimeValue ();
|
|
Assert.AreEqual ("Databound", result, "GetDesignTimeValue");
|
|
}
|
|
|
|
[Test]
|
|
[ExpectedException(typeof(HttpException), ExpectedMessage="A data item was not found in the container. The container must either implement IDataItemContainer, or have a property named DataItem.")]
|
|
public void BoundField_GetValueNull () {
|
|
PokerBoundField bf = new PokerBoundField ();
|
|
SimpleSpreadsheetRow ds = new SimpleSpreadsheetRow (0, null);
|
|
bf.DataField = PokerBoundField.ThisExpression;
|
|
string result = (string) bf.DoGetValue (ds);
|
|
}
|
|
|
|
[Test]
|
|
public void BoundField_GetValue () {
|
|
PokerBoundField bf = new PokerBoundField ();
|
|
SimpleSpreadsheetRow ds = new SimpleSpreadsheetRow (0, "test");
|
|
bf.DataField = PokerBoundField.ThisExpression;
|
|
string result = (string) bf.DoGetValue (ds);
|
|
Assert.AreEqual ("test", result, "GetValueFromIDataItemContainer");
|
|
}
|
|
|
|
[Test]
|
|
public void BoundField_GetValueDataItem () {
|
|
PokerBoundField bf = new PokerBoundField ();
|
|
ControlWithDataItem ds = new ControlWithDataItem ("test");
|
|
bf.DataField = PokerBoundField.ThisExpression;
|
|
string result = (string) bf.DoGetValue (ds);
|
|
Assert.AreEqual ("test", result, "GetValueFromIDataItemContainer");
|
|
}
|
|
|
|
[Test]
|
|
public void BoundField_InitializeDataCell () {
|
|
PokerBoundField bf = new PokerBoundField ();
|
|
bf.HeaderText = "headertest";
|
|
DataControlFieldCell cell = new DataControlFieldCell (null);
|
|
DataControlRowState state = DataControlRowState.Edit;
|
|
Assert.AreEqual (0, cell.Controls.Count, "InitializeDataCellControlsBeforeInit");
|
|
bf.DoInitializeDataCell (cell, state);
|
|
Assert.AreEqual (1, cell.Controls.Count, "InitializeDataCellControlsAfterInit");
|
|
}
|
|
|
|
[Test]
|
|
[ExpectedException (typeof (HttpException))]
|
|
public void BoundField_OnDataBindFieldExeption () {
|
|
PokerBoundField bf = new PokerBoundField ();
|
|
bf.bindbutoon.DataBind ();
|
|
|
|
}
|
|
|
|
[Test]
|
|
[ExpectedException (typeof (HttpException))]
|
|
public void BoundField_GetValueExeption () {
|
|
PokerBoundField bf = new PokerBoundField ();
|
|
bf.DoGetValue (null);
|
|
}
|
|
|
|
[Test]
|
|
[Category ("NunitWeb")]
|
|
public void BoundField_NullValueRender ()
|
|
{
|
|
string html = new WebTest (PageInvoker.CreateOnLoad (new PageDelegate (BasicRenderTestInit))).Run ();
|
|
string orightml = "<div>\r\n\t<table cellspacing=\"0\" rules=\"all\" border=\"1\" style=\"border-collapse:collapse;\">\r\n\t\t<tr>\r\n\t\t\t<th scope=\"col\"> </th><th scope=\"col\"> </th>\r\n\t\t</tr><tr>\r\n\t\t\t<td>Norway</td><td>Norway</td>\r\n\t\t</tr><tr>\r\n\t\t\t<td>Sweden</td><td>Sweden</td>\r\n\t\t</tr><tr>\r\n\t\t\t<td>EMPTY</td><td> </td>\r\n\t\t</tr><tr>\r\n\t\t\t<td>Italy</td><td>Italy</td>\r\n\t\t</tr>\r\n\t</table>\r\n</div>";
|
|
html = HtmlDiff.GetControlFromPageHtml (html);
|
|
HtmlDiff.AssertAreEqual (orightml, html, "NullValueRender");
|
|
}
|
|
|
|
public static void BasicRenderTestInit (Page p)
|
|
{
|
|
ArrayList myds = new ArrayList ();
|
|
myds.Add (new myds_data ("Norway"));
|
|
myds.Add (new myds_data ("Sweden"));
|
|
myds.Add (new myds_data (""));
|
|
myds.Add (new myds_data ("Italy"));
|
|
|
|
BoundField bf = new BoundField ();
|
|
bf.DataField = "Field1";
|
|
bf.NullDisplayText = "EMPTY";
|
|
|
|
BoundField bf2 = new BoundField ();
|
|
bf2.DataField = "Field1";
|
|
|
|
GridView GridView1 = new GridView();
|
|
GridView1.AutoGenerateColumns = false;
|
|
GridView1.Columns.Add (bf);
|
|
GridView1.Columns.Add (bf2);
|
|
GridView1.DataSource = myds;
|
|
GridView1.DataBind ();
|
|
|
|
LiteralControl lcb = new LiteralControl (HtmlDiff.BEGIN_TAG);
|
|
LiteralControl lce = new LiteralControl (HtmlDiff.END_TAG);
|
|
|
|
p.Form.Controls.Add (lcb);
|
|
p.Form.Controls.Add (GridView1);
|
|
p.Form.Controls.Add (lce);
|
|
}
|
|
|
|
class myds_data
|
|
{
|
|
string _s = "";
|
|
public myds_data (string s)
|
|
{
|
|
_s = s;
|
|
}
|
|
|
|
public string Field1
|
|
{
|
|
get { return _s; }
|
|
}
|
|
}
|
|
|
|
|
|
class ControlWithDataItem : Control
|
|
{
|
|
readonly object _data;
|
|
public ControlWithDataItem (object data) {
|
|
_data = data;
|
|
}
|
|
|
|
public object DataItem {
|
|
get {
|
|
return _data;
|
|
}
|
|
}
|
|
}
|
|
|
|
public class SimpleSpreadsheetRow : TableRow, IDataItemContainer
|
|
{
|
|
private object data;
|
|
private int _itemIndex;
|
|
|
|
public SimpleSpreadsheetRow (int itemIndex, object o) {
|
|
data = o;
|
|
_itemIndex = itemIndex;
|
|
}
|
|
|
|
public virtual object Data {
|
|
get {
|
|
return data;
|
|
}
|
|
}
|
|
|
|
object IDataItemContainer.DataItem {
|
|
get {
|
|
return Data;
|
|
}
|
|
}
|
|
|
|
int IDataItemContainer.DataItemIndex {
|
|
get {
|
|
return _itemIndex;
|
|
}
|
|
}
|
|
|
|
int IDataItemContainer.DisplayIndex {
|
|
get {
|
|
return _itemIndex;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|