zoukankan      html  css  js  c++  java
  • Moles Stub types

    The Moles Framework. The need for a stub framework that could be effectively used with Pex initially motivated the creation of the Moles framework for generating stub types and mole types:

    •  Stub types make it easy to test code that consumes interfaces, or non-sealed classes with overridable methods.
    •  Mole types allow detouring of hard-coded dependencies on static or non-overridable methods.

    Stub types sample.

    public interface IStudent
    {
      string GetName(string name);
    }

    public class ImpIStudent : StubBase, IStudent
    {
      public Func<string, string> GetNameString;
      public string GetName(string name)
      {
        if (GetNameString != null)
        {
          return GetNameString("str");
        }
        return null;
      }
    }


    [TestMethod()]
    public void GetNameTest()
    {
      IStudent target = CreateIStudent();
      string expected = "name...";

      var istu = new ClassLibrary1.Moles.SIStudent()
      {
        GetNameString = (name) => { return expected; }
      };

      IStudent stu = istu;

      string actual = stu.GetName(expected);

      Assert.AreEqual(expected, actual);

    }

  • 相关阅读:
    深度学习中的Data Augmentation方法(转)基于keras
    caffe pytho接口
    finetuning caffe
    windows下配置Faster-RCNN
    caffe中的props
    centos上搭建git服务--3
    centos上搭建git服务--2
    Centos上搭建git服务
    loadrunner--基础2
    loadrunner11--基础使用
  • 原文地址:https://www.cnblogs.com/wzh206/p/3081990.html
Copyright © 2011-2022 走看看