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

  • 相关阅读:
    AppScan安全问题解决方案
    WPF方法 获取控件在屏幕的位置和自动控件位置
    WPF获取鼠标点击位置和API使用
    system.windows.controls
    .net 获取项目的根目录
    InvokeRequired
    控件取图片和矩形框 小测试
    mariadb 设置远程访问
    代码生成器 链接
    分享个网站
  • 原文地址:https://www.cnblogs.com/zbw911/p/2387169.html
Copyright © 2011-2022 走看看