InCisif.net 2.0 and anonymous method
8/29/2007 2:15:00 AM
InCisif.net 2.0 is now compiled with C# 2.0. In the future of InCisif.net 2.x versions we will allow the tester/developer to customize the Api.
What does it mean ?
Page.Control()
First the delegate
public delegate bool MatchHTMLControlPredicat(HTMLControl c);
The method Page.Control() method has a new implementation
InCisif.net.Library.HTMLControl Control(MatchHTMLControlPredicat matchControlPredicat);
which allows the tester/developer to define the code that will select the HTML control.
Combined with C# 2.0 anonymous method the source code look like this
Page.Control(delegate(HTMLControl c) { return c.Name=="LastName"; }).Text = "Hi!";
InCisif.net HTML control look up Algorithm can now be customized to answer unexpected cases.
Page.ElementsByTagName()
We aslo implemented the same idea with the method ElementsByTagName to gather more than one HTML controls in a collections.
InCisif.net.Library.HTMLControls Elements(MatchHTMLControlPredicat matchControlPredicat);
And the InCisif.net.Library.HTMLControls collection exposes the method
HTMLControls Elements(MatchHTMLControlPredicat matchControlPredicat);
which allow to extract a subset of the collection.
Sample
HTMLControls Ctls = Page.Elements( delegate(HTMLControl c) { return c.Tag == "IMG"; } );
t.ASSERT(Ctls.Count == 5, "Ctls.Count - Count All Image");
HTMLControls JpegImages = Ctls.Elements( delegate(HTMLControl c) { return c.Src.ToLower().IndexOf(".jpg")>=0; } );
t.ASSERT(JpegImages.Count == 3, "Ctls.Count - Count JPG Image");
HTMLControls GifImages = Ctls.Elements( delegate(HTMLControl c) { return c.Src.ToLower().IndexOf(".gif")>=0; } );
t.ASSERT(GifImages.Count == 2, "Ctls.Count - Count GIF Image");