public void TestAddField( ) { NewProfileControl profileCtrl = new NewProfileControl( ); Assert.IsNotNull( profileCtrl.Fields ); Assert.AreEqual( 0, profileCtrl.Fields.Length ); profileCtrl.AddField( new MockFieldInfo( "Field1" ) ); profileCtrl.AddField( new MockFieldInfo( "Field2" ) ); Assert.AreEqual( 2, profileCtrl.Fields.Length ); Assert.AreEqual( "Field1", profileCtrl.Fields[ 0 ].Name ); Assert.AreEqual( "", profileCtrl.Fields[ 0 ].Value ); Assert.AreEqual( "Field2", profileCtrl.Fields[ 1 ].Name ); Assert.AreEqual( "", profileCtrl.Fields[ 1 ].Value ); }
public void TestUpdateData( ) { NewProfileControl profileCtrl = new NewProfileControl( ); profileCtrl.AddField( new MockFieldInfo( "Field1" ) ); profileCtrl.AddField( new MockFieldInfo( "Field2" ) ); FieldControl fc = profileCtrl.flowLayoutPanelFields.Controls[ "Field1" ] as FieldControl; fc.itemCtrl.Control.Text = "Value1"; fc = profileCtrl.flowLayoutPanelFields.Controls[ "Field2" ] as FieldControl; fc.itemCtrl.Control.Text = "Value2"; Assert.AreEqual( "", profileCtrl.Fields[ 0 ].Value ); Assert.AreEqual( "", profileCtrl.Fields[ 1 ].Value ); profileCtrl.UpdateData(); Assert.AreEqual( 2, profileCtrl.Fields.Length ); Assert.AreEqual( "Value1", profileCtrl.Fields[ 0 ].Value ); Assert.AreEqual( "Value2", profileCtrl.Fields[ 1 ].Value ); }