马会东的博客

马会东的博客

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

看代码吧

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace P2P.Tests
{
    [TestClass()]
    public sealed class DivideClassTest
    {
        [AssemblyInitialize()]
        public static void AssemblyInit(TestContext context)
        {
            //配置log4net
            //var path = AppDomain.CurrentDomain.BaseDirectory + ("\\log4net.config");
            //System.IO.FileInfo file = new System.IO.FileInfo(path);
            //log4net.Config.XmlConfigurator.ConfigureAndWatch(file);

            MessageBox.Show("AssemblyInit " + context.TestName);
        }

        [ClassInitialize()]
        public static void ClassInit(TestContext context)
        {
            MessageBox.Show("ClassInit " + context.TestName);
        }

        [TestInitialize()]
        public void Initialize()
        {
            MessageBox.Show("TestMethodInit");
        }

        [TestCleanup()]
        public void Cleanup()
        {
            MessageBox.Show("TestMethodCleanup");
        }

        [ClassCleanup()]
        public static void ClassCleanup()
        {
            MessageBox.Show("ClassCleanup");
        }

        [AssemblyCleanup()]
        public static void AssemblyCleanup()
        {
            MessageBox.Show("AssemblyCleanup");
        }

        [TestMethod()]
        [ExpectedException(typeof(System.DivideByZeroException))]
        public void DivideMethodTest()
        {
            DivideClass.DivideMethod(0);
        }
    }

    public class DivideClass
    {
        public static int DivideMethod(int denominator)
        {
            return (2 / denominator);
        }
    }
}

 

posted on 2015-09-11 10:48  马会东  阅读(184)  评论(0编辑  收藏  举报