zoukankan      html  css  js  c++  java
  • 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);

        }


    }


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

  • 相关阅读:
    Java Switch
    老徐杂谈:年后的第一个双休,你在做什么?
    测试必备技能系列4:如何用SSH向linux服务器上传下载文件
    Git从零教你入门(4):Git服务之 gogs部署安装
    你知道哪些linux命令,能把文件上传到远程linux服务器
    一个7年以上测试工程师的2016思考
    老徐谈谈软件测试职业的现状,以及市场情况
    mac 远程连接服务器
    Git从零开始怎么学?
    分享 | Git常用的一些命令
  • 原文地址:https://www.cnblogs.com/Terrylee/p/548441.html
Copyright © 2011-2022 走看看