zoukankan      html  css  js  c++  java
  • 单元测试工具

    [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

  • 相关阅读:
    Python lambda 多变量
    Python 的 zip 和 dict 组合 生成新字典
    Solr集群Replication配置与实践(四)
    linux系统搭建zookeeper集群(二)
    linux系统中安装solr搜索引擎(一)
    Solr搜索引擎集群搭建(三)
    CentOS7的yum重装
    安装konga 路由设置
    安装Snipe-IT资产管理系统
    安装GLPI资产管理
  • 原文地址:https://www.cnblogs.com/zbw911/p/2387169.html
Copyright © 2011-2022 走看看