• 单元测试工具


    [TestMethod()]
          public void SearchForWatiNOnGoogle()
          {
              // 打开IE浏览器,并来到Google站点  
              using (var browser = new IE("http://www.google.com.hk/%22))
              {               
                 
                  // 定位到搜索框,并输入WatiN  
                  browser.TextField(Find.ByName("q")).TypeText("WatiN");
                  // 点击“搜索”按钮  
                  browser.Button(Find.ByName("btnG")).Click();
                  // 验证搜索结果中是否包含关键字“WatiN”  
                  Assert.IsTrue(browser.ContainsText("google"));
              }
          } 

    from WatiN.dll

    [TestMethod]
           public void Test_FindByName_GetCalled()
           {
               // create some mock data
               IList<Product> products = new List<Product>{
               new Product { ProductId = 1, Name = "C# Unleashed",Description = "Short description here", Price = 49.99 },
               new Product { ProductId = 2, Name = "ASP.Net Unleashed",Description = "Short description here", Price = 59.99 },
               new Product { ProductId = 3, Name = "Silverlight Unleashed",Description = "Short description here", Price = 29.99 }};

               Mock<IProductRepository> mock = new Mock<IProductRepository>();
               mock
               .Setup(sender => sender.FindById(It.IsAny<int>()))
               .Returns((int s) =>
                   products.Where(x => x.ProductId == s).Single());

               var Product = new Product { ProductId = 1, Name = "C# Unleashed", Description = "Short description here", Price = 49.99 };

               Assert.AreEqual(Product.ProductId, mock.Object.FindById(1).ProductId);

               //mock.Object.FindById(1);
               //mock
               //.Verify(x => x.FindById(1), Times.Once());
           }

    moq.dll

    /Files/zbw911/ss.zip 

    TestRunner

  • 相关阅读:
    Thinking in java(八)-正则表达式
    order by与索引
    order by与索引
    004_常量的设置
    008_ajax没有跳转页面的错误
    007_缺少aspactj依赖
    006_为什么我的本机地址是0.0.0.0.0.1
    005_mybatis逆向工程错误
    004_当用数据库账号密码不对时?
    059_SSM——JDK动态代理是怎么回事?它又是怎么运用到了SSM框架中的?
  • 原文地址:https://www.cnblogs.com/zbw911/p/2387169.html
Copyright © 2020-2023  润新知