When writing tests for your application it is often desirable to avoid hitting the database.  Entity Framework allows you to achieve this by creating a context – with behavior defined by your tests – that makes use of in-memory data. This article wil…
Googletest - Google Testing and Mocking Framework https://github.com/google/googletest…
Data Developer Center > Learn > Entity Framework > Get Started > Working with Transactions (EF6 Onwards) EF6 Onwards Only - The features, APIs, etc. discussed in this page were introduced in Entity Framework 6. If you are using an earlier vers…
本文转自:http://www.cnblogs.com/xiepeixing/p/5275999.html Working with Transactions (EF6 Onwards) This document will describe using transactions in EF6 including the enhancements we have added since EF5 to make working with transactions easy. What EF doe…
Today I want to talk about mocking frameworks and why they are useful. In order to do that I first need to propose a scenario to you in which we will be testing a piece of functionality in an application. I will show you how you would test it without…
原位地址:http://codetunnel.com/blog/post/what-is-a-mocking-framework-why-is-it-useful 今天我想讲下关于mocking frameworks,并且解释下他为什么有用处.我将给你们展示用和不用mocking framework两种测试方法. 假设我们已经有了一个Driver类: public class Driver { private IVehicle vehicleToDrive; public Driver(IVeh…
[译] 什么是Mocking framework?它有什么用? 原位地址:http://codetunnel.com/blog/post/what-is-a-mocking-framework-why-is-it-useful 今天我想讲下关于mocking frameworks,并且解释下他为什么有用处.我将给你们展示用和不用mocking framework两种测试方法. 假设我们已经有了一个Driver类: public class Driver { private IVehicle ve…
今天我想讲下关于mocking frameworks,并且解释下他为什么有用处.我将给你们展示用和不用mocking framework两种测试方法. 假设我们已经有了一个Driver类: public class Driver { private IVehicle vehicleToDrive; public Driver(IVehicle vehicleToDrive) { this.vehicleToDrive = vehicleToDrive; } public bool Evasive…
What is Data Driven Testing? Data-driven is a test automation framework which stores test data in a table or spread spreadsheet format. This allows automation engineers to have a single test script which can execute tests for all the test data in the…
EF6使用MySQL数据库时,第一次创建数据库出现“Specified key was too long; max key length is 767 bytes”错误,解决办法请见以下连接. http://stackoverflow.com/questions/20832546/entity-framework-with-mysql-and-migrations-failing-because-max-key-length-is-76…
一.前言 在实际编写程序时,往往需要与数据库打交道,在单元测试中直接使用数据库又显得太重,如果可以方便的编写一些测试数据,这样更易于检测功能.如何模拟数据库行为便是本篇的主题.微软有教程说明Moq Entity Framework,需注意的是EF的版本必须是6以上.但在这篇教程中是直接使用DbContext,而自己的应用程序中都是用UnitOfWork模式.经过修改后也可以实现类似功能. 二.参考文献 https://msdn.microsoft.com/en-us/data/dn314429…
通过 Nuget 安装 2.   官网下载(官网不行点这里) 3.   帮助文档 商业版和免费版区别概览 MockingContainer 测试类准备:一般来说也是业务类 public class ClassUnderTest { private IFirstDependency firstDep; private ISecondDependency secondDep; public ClassUnderTest(IFirstDependency first, ISecondDependenc…
https://msdn.microsoft.com/en-us/data/jj680699#Using…
UnitTesting shanzm 右键-->在新标签页中打开图片,即可查看原图,图片超乎你想像的大! 源代码:https://github.com/shanzm/UnitTesting…
现在EF越来越流行了,很多时候业务成都是直接访问DbContext 和DbSet来操作数据的. 那么我们测试的时候如何来mock这2个对象了?现在时间很晚了, 就直接贴code吧 首先看看的我们DbContext的类吧: public class BloggerEntities : DbContext { public BloggerEntities() : base("BloggerEntities") { Configuration.ProxyCreationEnabled = f…
本篇原文链接:Advanced Entity Framework Scenarios 本篇主要讲一些使用Code First建立ASP.NET WEB应用的时候除了基础的方式以外的一些扩展方式方法: 1.Performing Raw SQL Queries (执行真正的SQL语句) 2.Performing no-tracking queries (执行无跟踪的SQL语句) 3.Examining SQL sent to the database (检查发到数据库的SQL语句) Performi…
原文:Advanced Entity Framework 6 Scenarios for an MVC 5 Web Application 1.执行原生SQL查询: EF Code First API包含直接传递SQL命令到数据库的方法: 使用DbSet.SqlQuery方法查询返回实体类型.返回的对象必须是DbSet对象所期望的类型,并且数据库上下文会自动追踪它们除非我们关闭了追踪. 使用Database.SqlQuery方法查询返回非实体类型.返回的数据不会被数据库上下文追踪,即使我们为该方…
为ASP.NET MVC应用程序使用高级功能 这是微软官方教程Getting Started with Entity Framework 6 Code First using MVC 5 系列的翻译,这里是第十二篇:为ASP.NET MVC应用程序使用高级功能 原文:Advanced Entity Framework 6 Scenarios for an MVC 5 Web Application 译文版权所有,谢绝全文转载——但您可以在您的网站上添加到该教程的链接. 在之前的教程中,您已经实现…
学习总目录:ASP.NET MVC5 及 EF6 学习笔记 - (目录整理) 上篇链接:EF学习笔记(十一):实施继承 本篇原文链接:Advanced Entity Framework Scenarios 本篇主要讲一些使用Code First建立ASP.NET WEB应用的时候除了基础的方式以外的一些扩展方式方法: 1.Performing Raw SQL Queries (执行真正的SQL语句) 2.Performing no-tracking queries (执行无跟踪的SQL语句) 3…
刚用上Moq,就用它解决了一个IUnitOfWork的mock问题,在这篇博文中记录一下. 开发场景 Application服务层BlogCategoryService的实现代码如下: public class BlogCategoryService : IBlogCategoryService { private IBlogCategoryRepository _blogCategoryRepository; public BlogCategoryServiceImp(IBlogCategor…
目录(?)[-] Android automated testing 1 How to test Android applications Tip 2 Unit tests vs functional tests 3 JUnit 3 4 Running tests on a server without display Test hooks into the Android framework 1 Instrumentation 2 How the Android system executes…
Interaction Based Testing Peter Niederwieser, The Spock Framework TeamVersion 1.1 Interaction-based testing is a design and testing technique that emerged in the Extreme Programming (XP) community in the early 2000’s. Focusing on the behavior of obje…
最近开发的服务放到IIS上寄宿之后,遇到一些现象,比如刚部署之后,第一次启动很慢:程序放置一会儿,再次请求也会比较慢.比如第一个问题,可以解释为初次请求某一个服务的时候,需要把程序集加载到内存中可能比较慢,第二个问题有可能是IIS的线程回收机制导致放置若干长时间,空闲的进程被回收了,再次请求的话可能比较慢. 刚开始的时候没有太在意,但是随着系统的发布,这种初次请求,或者闲置若干时间后第一次请求的漫长等待使得App的体验很差,很多时候App加载好半天数据都没过来.如果前端没处理好,还会导致App的…
These are the contents of my training session about unit testing, and also have some introductions about how could we write better unit tests with NSubstitute framework. The related sessions: Unit Testing with NSubstitute Building the Testing Pipelin…
引言 在EntityFramework的开发过程中我们有时因需求变化或者数据结构设计的变化经常会改动表结构.但数据库Schema发生变化时EF会要求我们做DataMigration 和UpdateDatabase.但在这个过程中如何才能保证现有数据库的数据存在. 另外本文只针对CodeFirst的方式来做.   准备一个简单的 EFCodeFirst Demo   创建一个控制台程序 MigrationsDemo NuGet 获取最新版 EntityFramework  Tools –> Lib…
上篇博文说过当我们定义的类不能遵循约定(Conventions)的时候,Code First 提供了两种方式来配置你的类:DataAnnotations 和 Fluent API, 本文将关注 Fluent API.  一般来说我们访问 Fluent API 是通过重写继承自 DbContext 的类中方法 OnModelCreating. 为了便于例示,我们先创建一个继承自 DbContext 的类,以及其它的一些类以便使用 public class SchoolEntities : DbCo…
Entity Framework 6.x Code Frist For Oracle 实践与注意点 开发环境 Visual Studio.net 2015/2017 Oracle 11g/12c 数据库 Oracle Client 可以不安装 Asp.net mvc Project Nuget 组件 EntityFramework 6.1.3 Oracle.ManagedDataAccess 12.1.2400 Oracle.ManagedDataAccess.EntityFramework 1…
http://www.opensourcetesting.org/unit_c.php API Sanity AutoTest Description: An automatic generator of basic unit tests for a shared C/C++ library. It helps to quickly generate simple ("sanity" or "shallow"-quality) test cases for ever…
Unit Testing a zend-mvc application A solid unit test suite is essential for ongoing development in large projects, especially those with many people involved. Going back and manually testing every individual component of an application after every c…
Summary: Guest blogger, Dave Wyatt, discusses using Pester to analyze small pieces of Windows PowerShell code. Note   This is a five-part series that includes the following posts: What is Pester and Why Should I Care?Learn about a new test framework…