zoukankan      html  css  js  c++  java
  • 我的酒窝.NET

    ajoo同学的酒窝有.NET版本啦!

    项目主页:
    http://dotnet.dimple.googlepages.com/home

    存在意义:
    快速制作测试用的stub。手工继承,mock框架之外的第三种选择。

    简单使用:
    public class StubDbCommand
            {
                
    public object ExecuteScalar()
                {
                    
    return "Hello";
                }
                
    public static DbCommand New()
                {
                    
    return NDimple.Implement<DbCommand>(new StubDbCommand());
                }
            }
    Console.WriteLine(StubDbCommand.New().ExecuteScalar());

    Output:
    Hello

    独家特性:
    public abstract class AbstractClass
            {
                
    protected abstract string AbstractMethod1();
                
    protected abstract string AbstractMethod2();
                
    public string InvokeAbstractMethod1()
                {
                    
    return AbstractMethod1();
                }
            }

    public abstract class StubAbstractClass : AbstractClass
            {
                
    protected override string AbstractMethod1()
                {
                    
    return "Hello";
                }
                
    public static AbstractClass New()
                {
                    
    return NDimple.Implement<AbstractClass>(typeof (StubAbstractClass));
                }
            }

    Console.WriteLine(StubAbstractClass.New().InvokeAbstractMethod1());

    Output:
    Hello
  • 相关阅读:
    MySQL必知必会(数据分组,Group by和Having子句, Select子句的顺序)
    MySQL必知必会(汇总数据, 聚集函数)
    MySQL必知必会(使用函数处理数据)
    菜根谭#206
    菜根谭#205
    菜根谭#204
    菜根谭#203
    菜根谭#202
    菜根谭#201
    菜根谭#200
  • 原文地址:https://www.cnblogs.com/taowen/p/733504.html
Copyright © 2011-2022 走看看