Click here to Skip to main content
15,892,005 members
Articles / Programming Languages / C#

Pragmatic Unit Tests using "yield return" for providing test cases

Rate me:
Please Sign up or sign in to vote.
4.33/5 (5 votes)
5 Feb 2013CPOL3 min read 38.7K   120   14  
How to gain better control over the testing process reducing the amount of test methods in a unit test.
using System;

namespace TestProject1
{
    /// <summary>
    /// Is used for testing
    /// </summary>
    public class ConstantTimeProvider : ITimeProvider
    {
        public ConstantTimeProvider(DateTime now)
        {
            Now = now;
        }

        #region ITimeProvider Members

        public DateTime Now { get; set; }

        #endregion
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) Polenter - Software Solutions
Germany Germany
I'm C# developer from Cologne, Germany. Here I owe a small software company. My hobby is general optimization - natural talent of all lazy people Wink | ;-)

Comments and Discussions