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);

        }


    }


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

  • 相关阅读:
    mod_rewrite
    敏捷开发
    转python和ruby的相同点
    ESB总线知识小结
    使用 squid 2.7 for windows 进行无缓存反向代理
    初探K2workflow
    没激情的工作
    多易拍 二次开发
    查看数二进制代码片段
    生成随机数
  • 原文地址:https://www.cnblogs.com/Terrylee/p/548441.html
Copyright © 2011-2022 走看看