Welcome to Windows Presentation Foundation (WPF)
Top Tasks :

WPF Community Bloggers

Write your own NUnit constraint (in VB) - Part 2

So in part 1 we created our own constraint and want some of that syntax sugar, the Is helper class uses static (shared) methods to create the constraints so we either hack the NUnit source or try something else. What I ended up doing may not be ideal as it really plays with the syntax but it was fun all the same :) I created a new class called This and did the following. Imports System.Collections Imports NUnit.Framework.Constraints Imports NUnit.Framework.SyntaxHelpers Public Class This Inherits SyntaxHelper Public Shared ReadOnly Property [Is]() As This Get Return New This() End Get End Property Public Function AssignableFrom(ByVal expectedType As Type) As Constraint Return New AssignableFromConstraint(expectedType) End Function Public Function AtLeast(ByVal expected As IComparable) As Constraint Return GreaterThanOrEqualTo(expected) End Function Public Function AtMost(ByVal expected As IComparable) As Constraint Return LessThanOrEqualTo(expected) End Function Public Function EqualTo(ByVal Read More...
Published Wednesday, August 06, 2008 7:35 AM by Andrew Stopford's Weblog
Filed under: ,

Comments

No Comments
Anonymous comments are disabled

Copyright © 2006 Microsoft Corporation. All Rights Reserved. | Terms of Use | Privacy Statement | Contact Us