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

  • 相关阅读:
    103.Binary Tree Zigzag Level Order Traversal
    6.ZigZag Conversion
    102.Binary Tree Level Order Traversal
    interrupted()和isInterrupted()比较+终止线程的正确方法+暂停线程
    117.Populating Next Right Pointers in Each Node II
    Thread.currentThread()与this的区别
    116.Populating Next Right Pointers in Each Node
    UNIX 技巧: UNIX 高手的另外 10 个习惯
    UNIX 高手的 10 个习惯
    关于CGI:Tomcat、PHP、Perl、Python和FastCGI之间的关系
  • 原文地址:https://www.cnblogs.com/zbw911/p/2387169.html
Copyright © 2011-2022 走看看