• Castle 1.0 RC2 尝鲜


    今天才看到Castle 1.0 RC2 发布的消息,便迫不及待的载了下来,看看有什么新鲜的玩艺儿。

    下载安装Castle 1.0后,在VS2005中会发现多出了两个项目模版:Castle ActiveRecord ProjectCastle MonoRail Project,如下图:

    新建一个ActiveRecord项目,它会在解决方案中生成一个实体类项目的同时,还会生成一个单元测试项目:

    并且提供一个用于测试实体的抽象类,在这里面已经设置好了要做单元测试的一切,写自己的测试类时只需要继承于该类:

    public abstract class AbstractModelTestCase

    {
        
    protected SessionScope scope;

        [TestFixtureSetUp]

        
    public virtual void FixtureInit()

        
    {
            InitFramework();
        }


        [SetUp]

        
    public virtual void Init()

        
    {
            PrepareSchema();

            CreateScope();
        }


        [TearDown]

        
    public virtual void Terminate()

        
    {
            DisposeScope();

            DropSchema();
        }


        [TestFixtureTearDown]

        
    public virtual void TerminateAll()

        
    {

        }


        
    protected void Flush()

        
    {
            SessionScope.Current.Flush();
        }


        
    protected void CreateScope()

        
    {
            scope 
    = new SessionScope(FlushAction.Never);
        }


        
    protected void DisposeScope()

        
    {
            scope.Dispose();
        }


        
    /// <summary>

        
    /// If you want to delete everything from the model.

        
    /// Remember to do it in a descendent dependency order

        
    /// </summary>


        
    protected virtual void PrepareSchema()

        
    {
            
    // If you want to delete everything from the model.

            
    // Remember to do it in a descendent dependency order

            
    // Office.DeleteAll();

            
    // User.DeleteAll();

            
    // Another approach is to always recreate the schema 

            
    // (please use a separate test database if you want to do that)

            ActiveRecordStarter.CreateSchema();
        }


        
    protected virtual void DropSchema()

        
    {
            ActiveRecordStarter.DropSchema();
        }


        
    protected virtual void InitFramework()

        
    {
            IConfigurationSource source 
    = ActiveRecordSectionHandler.Instance;

            ActiveRecordStarter.Initialize(source);

            
    // Remember to add the types, for example

            
    // ActiveRecordStarter.Initialize( source, typeof(Blog), typeof(Post) );

            
    // Or to use the assembly that holds the ActiveRecord types

            
    // ActiveRecordStarter.Initialize(System.Reflection.Assembly.Load("MyARProject"), source);

        }


    }


    看来又要很多东西要去研究了:)

  • 相关阅读:
    fiddler如何抓取夜神模拟器上的包
    关于在虚拟机上安装iOS所遇到的问题
    ADB WiFi连接手机
    ADB命令总结(1)
    ADB连接手机遇到的问题:list of devices attached
    win 7 查看端口被占用
    APP测试用例要考虑的一些方面
    什么是阿尔法测试?
    关于ADB push 出现failed to copy 'D:file.xtxt' to '/system/temp/' : Read-only file system 的报错信息解决办法
    ADB push 和ADB pull命令
  • 原文地址:https://www.cnblogs.com/Terrylee/p/548441.html
Copyright © 2020-2023  润新知