概述
使用单元测试框架,Nunit。包括对controller的测试,以及moq框架的使用。
详解
1,数据库层Service的单元测试

 

引入:using NUnit.Framework;

    [TestFixture]
    
public class SystemConfigServiceTest
    {

        [Test]
        
public void GetByIdTest()
        {
            SystemConfig configExcept 
= new SystemConfig();
            configExcept.PkId 
= 78;
            SystemConfig configActual 
= new SystemConfigService().GetById(78);
            Assert.AreEqual(configExcept.PkId, configActual.PkId,
"插叙编号为78的,如果测试不通过,请检查");
        }
    }

相关文章: