Showing posts with label Code. Show all posts
Showing posts with label Code. Show all posts

Friday, 20 January 2012

Unit Testing Principles

General Principles

Test anything that might break.
Test everything that does break.
New code is guilty until proven innocent.
Write at least as much test code as production code.
Run local tests with each compile.
Run all tests before check-in to the repository.
Questions to Ask

If the code ran correctly, how would I know?
How am I going to test this?
What else can go wrong?
Could this same kind of problem happen anywhere else?
What to Test: Use Your “Right BICEP”

Are the results right?
Are all the boundary conditions CORRECT?
Can you check inverse relationships?
Can you cross-check results using other means?
Can you force error conditions to happen?
Are performance characteristics within bounds?
Good tests are “A TRIP”

Automatic
Thorough
Repeatable
Independent
Professional
CORRECT Boundary Conditions

Conformance: Does the value conform to an expected format?
Ordering: Is the set of values ordered or unordered as appropriate?
Range: Is the value within reasonable minimum and maximum values?
Reference: Does the code reference anything external that isn’t under direct control of the code itself?
Existence: Does the value exist (for example, is non-null, non-zero, present in a set, and so on)?
Cardinality: Are there exactly enough values?
Time (absolute and relative): Is everything happening in order? At the right time? In time?

Monday, 12 December 2011

Where is the code snippets folder for Visual Studio

C:\Users\Kelvin\Documents\Visual Studio 2010\Code Snippets

Saturday, 28 May 2011

Hello NZ. How to post source code in Blogger BlogSpot

This is a test post.

// This is called Generic Type
    class Pair
    {
        public TKey Key { get; set; }
        public TValue Value { get; set; }

        public Pair(TKey key, TValue value){
            Key = key;
            Value = value;
        }

        // This is called Generic Method
        public void InferredTypeArgument(T sameAsTypeParameter)
        {
            Console.WriteLine(typeof(T));
        }
    }