Introducing WPF Application Quality Guide v.0.4
WPF Application Quality Guide v0.4 has been released today at the WindowsClient.NET with new topics and updates.
This release includes several new topics and updates:
1. Suggested Roadmap – updated to include new topics
2. Data-Driven Testing – a new article about the data-driven testing practice.
3. Globalization and Localization Testing – updated w/ more details including creating localizable UI layouts in WPF and approaches to localizing WPF applications.
4. Stability and Stress Testing – a new article about stress testing principles, best practices, and useful resources.
5. Accessibility Testing – a new article about accessibility considerations, best practices and key resources.
6. Tools / TestAPI – a brief intro about the newly released TestAPIs.
The full online version can be found here.
Regular expression builder
I was doing some input verification of data to method when it did hit me that it would be nice if I could do it with regular expression since I was only check if the string data was in correct format. Since I’m not an expert in regular expression I needed some type of builder or verification tool. After some searching I found this free tool RegExr that has both an online version and desktop version. The thing that I did like most was the online version that was only a click away. The program doesn’t help you that much building the regular express but it helps a lot for verifying your expressions. It also has a bunch “code snippets” that you can use as building block.
Anyway this little program did save my day to tryout some different expression to find one that did fit my needs.
So I hope that you also will find it useful.
RegExr
RegExr desktop
Fun with UIAutomation and calc
Last night I got a cool idea how to show some basic ideas of UIAutomation. I did decide to-do a UIAutomation example with calc as my test subject. The idea is to give a mathematical expression to the program, which will then use calc to solve the problem and show you the result. The main thing is to show how UIAutomation is working and not to calculate.
The first thing that we need is a method that can find an AutomationElement for us. An AutomationElement is anything that you can see on the screen as buttons and input fields. The method take a root AutomationElement that define where to start to search, a name and a class name for the object that we are looking for. We then create two property conditions based on the name and class name. These two conditions are then combined in an AndCondition. We also have OrCondition and NotCondition to use. The last thing we do is to search for the first AutomationElement that match the condition.
private static AutomationElement GetElement(AutomationElement root, string name, string className) { PropertyCondition condName = new PropertyCondition(AutomationElement.NameProperty, name); PropertyCondition condClassName = new PropertyCondition(AutomationElement.ClassNameProperty, className); AndCondition cond = new AndCondition(condName, condClassName); return root.FindFirst(TreeScope.Descendants, cond); }
Next method that we need is one that can return a invoke pattern. Invoke pattern is used for example to click on a button. This will be used to be able to click on the different buttons in calc
private static InvokePattern GetInvokePattern(AutomationElement element) { return element.GetCurrentPattern(InvokePattern.Pattern) as InvokePattern; }
.NET Cheat Sheets
When I was surfing around today I found this site that contain a bunch of different cheat sheets for .NET. The one that I find really useful was ‘Visual Studio 2005 Built-in Code Snippets‘. So simple have fun with this findings
Working with GAC from code
For some day ago I was working on testing an installer that did add some files to the GAC during installation. To ensure that the installer was working correct I needed some code that could check if some files did exist, add files and remove files from the GAC. I did need this for mainly 3 test cases; files already exist in GAC, files are installed correct and repair scenario when some files are deleted. I did find a good API wrapper on Junfena Zhana’s blog that did wrap the needed COM interactions. Based on this wrapper I did create a small class that did solve my problem.
Install assembly example
public static void InstallAssembly(string assemblyPath) { if (String.IsNullOrEmpty(assemblyPath)) { throw new ArgumentNullException("assemblyPath"); } AssemblyCache.InstallAssembly(assemblyPath, null, AssemblyCommitFlags.Force); }