人生是一场不能存盘的RPG,我只能尽量多搞几个Screenshot

May 21, 2006

多启动xp安装盘制作

Filed under: 使用技巧

需要的工具:easyboot, 在网上找的一个带Ghost的启动系统:ghost.img
1. 把xp的安装盘copy到e:\Disk 下
2. 把sp2 copy到e盘,并解压缩到e:\sp2\,在命令行下运行e:\SP2\UPDATE\UPDATE.EXE /integrate:e:\Disk, 这样就把sp2 merge到了xp的安装文件中。
3. 在e:\Disk 下建一个名为ezboot的目录,把eazyboot要用的文件copy进去:
     w2ksect.bin: 用来装xp
     ghost.img:带ghost的引导系统
4.  用easyboot来制作一个多引导光盘,
     我做的有4个选项:
     1 Install xp vs sp2 ,命令为run w2ksect.bin
     2 Run Ghost  ,命令为run ghost.img
     3 Boot from HD ,命令为boot 80
     4 ReBoot ,命令为reboot
   
    把结果存到e:\Disk \ezboot\
     最终e:\Disk \ezboot\会有4个文件:
     ghost.img(在网上下的一个ghost系统)
     w2ksect.bin(ezboot带的装xp的程序)
     loader.bin(ezboot 生成,用于启动)
     myboot.EZB(ezboot 生成,用于记录菜单的设置)

5. 做ISO,指定文件位置为e:\Disk
   引导信息为e:\Disk \ezboot\loader.bin

VS2005 Team Test 数据驱动的unit test

Filed under: Visual Studio

1.测试数据放在数据库中.
在测试方法的属性窗口中设置 connection string 和data table name
  [TestMethod]
  [Owner("Mark Michaelis")]
  [TestProperty("TestCategory", "Developer"), DataSource("System.Data.SqlClient", "Data Source=.\\SQLEXPRESS;AttachDbFilename="myTestData.mdf";Integrated Security=True", "LogonInfoTest", DataAccessMethod.Sequential)]
  public void ChangePasswordTest()
  {
     //得到测试数据
     string userId = (string)TestContext.DataRow[(int)Column.UserId];
     string password = (string)TestContext.DataRow[(int)Column.Password];
     bool isValid = (bool)TestContext.DataRow[(int)Column.IsValid];

     LogonInfo logonInfo = new LogonInfo(userId, "P@ssw0rd");

     if (!isValid)
     {
        Exception exception = null;
        try
        {
           logonInfo.ChangePassword( "P@ssw0rd", password);
        }
        catch (Exception tempException)
        {
           exception = tempException;
        }
        Assert.IsNotNull(exception, "The expected exception was not thrown.");
        Assert.AreEqual<Type>( typeof(ArgumentException), exception.GetType(),"The exception type was unexpected.");
     }
     else
     {
        logonInfo.ChangePassword("P@ssw0rd", password);
        Assert.AreEqual<string>(password, logonInfo.Password, "The password was not changed.");
     }
  }

2.测试数据方法Excel文件中
    [TestMethod()]
    [DeploymentItem("EmailData\\EmailData.xls")]  //将excel文件部署到测试程序所在的目录,似乎不必要
    [DataSource("System.Data.Odbc","Dsn=Excel Files;dbq=D:\\TestData.xls;defaultdir=.; driverid=790;maxbuffersize=2048;pagetimeout=5", "Sheet1$", DataAccessMethod.Sequential)]
    public void MyFunctionTest()
    {
        //得到测试数据
        string testData = TestContext.DataRow[0].ToString();
        …
    }

3.使用配置文件
测试工程的app.config:

    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <configSections>
            <section name="microsoft.visualstudio.testtools" type="Microsoft.VisualStudio.TestTools.UnitTesting.TestConfigurationSection, Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
        </configSections>
      
        <connectionStrings>
            <add name="MyJetConn" connectionString="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\testdatasource.mdb; Persist Security Info=False;" providerName="System.Data.OleDb" />
            <add name="MyExcelConn" connectionString="Dsn=Excel Files;dbq=data.xls;defaultdir=.; driverid=790;maxbuffersize=2048;pagetimeout=5" providerName="System.Data.Odbc" />
        </connectionStrings>
       
        <microsoft.visualstudio.testtools>
            <dataSources>
                <add name="MyJetDataSource" connectionString="MyJetConn" dataTableName="MyDataTable" dataAccessMethod="Sequential"/>
                <add name="MyExcelDataSource" connectionString="MyExcelConn" dataTableName="Sheet1$" dataAccessMethod="Sequential"/>
            </dataSources>
        </microsoft.visualstudio.testtools>
    </configuration>

测试代码:
    [TestMethod()]
    [DeploymentItem("MyTestProject\\testdatasource.mdb")]
    [DataSource("MyJetDataSource")]
    public void MyTestMethod()
    {
    int a = Int32.Parse(context.DataRow["Arg1"].ToString());
    int b = Int32.Parse(context.DataRow["Arg2"].ToString());
    Assert.AreNotEqual(a, b, "A value was equal.");
    }

    [TestMethod()]
    [DeploymentItem("MyTestProject\\data.xls")]
    [DataSource("MyExcelDataSource")]
    public void MyTestMethod2()
    {
        Assert.AreEqual(context.DataRow["Val1"], context.DataRow["Val2"]);
    }

个人认为:DeploymentItem

参考

Strengthening Visual Studio Unit Tests(by John Robbins)
http://msdn.microsoft.com/msdnmag/issues/06/03/Bugslayer/

演练:使用 Visual Studio Team Test 进行单元测试
http://www.microsoft.com/china/msdn/library/langtool/vsts/vstsunittesting.mspx?mfr=true

演练:使用配置文件定义数据源 
http://msdn2.microsoft.com/zh-cn/library/ms243192.aspx

DeploymentItemAttribute
http://msdn2.microsoft.com/zh-cn/library/ms245570.aspx






















Get free blog up and running in minutes with Blogsome
Theme designed by Hadley Wickham