Click here to Skip to main content
15,886,833 members
Articles / DevOps / Testing

Mocking Methods and Properties Using PostSharp

Rate me:
Please Sign up or sign in to vote.
4.00/5 (1 vote)
14 Aug 2012CPOL4 min read 19K   97   7  
Mock test without interface, on static methods and properties, using PostSharp
using System;
using Framework;

namespace TestCases
{
    public class StaticProvider
    {
        /// <summary>
        /// Suppose to return a bool, purposely not implemented
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [MockMethod]
        public static bool Provide(int input)
        {
            throw new NotImplementedException("Static Provider Not Implemented");
        }

        [MockProperty]
        public static int Value { get; set; }

        public static int Field;
    }
}

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) 3PLearning
Australia Australia
Lead Developer, MMO Game Company
Testor, Microsoft

Comments and Discussions