Lazy Exceptions for Fake LINQ Queries

Posted by: K. Scott Allen, on 22 Jun 2011 | View original | Bookmarked: 0 time(s)

If you want to simulate an exception from an IQueryable data source, be careful about when the exception is thrown. As an example, let's use the following interface. public interface IContext { IQueryable<Person> People { get; set; } } To simulate an IllegalOperationException from the data source, you might setup a mock with the following code. var mockContext = new Mock<IContext>(); mockContext.SetupGet(c => c.People) .Throws<InvalidOperationException>(); But,...

Advertisement
Free Agile Project Management Tool from Telerik
TeamPulse Community Edition helps your team effectively capture requirements, manage project plans, assign and track work, and most importantly, be continually connected with each other.
Category: XLinq | Other Posts: View all posts by this blogger | Report as irrelevant | View bloggers stats | Views: 674 | Hits: 35

Similar Posts

  • LINQ in Action samples in LINQPad more
  • Creating LINQToTwitter library using LinqExtender more
  • DevConnections Spring Slides and Demos more
  • Mocking static methods with Typemock more
  • Dynamic Queries and LINQ Expressions more
  • Speed Development Time by 50% more
  • Dynamic LINQ (Part 1: Using the LINQ Dynamic Query Library) more
  • LINQ for the Web Using VB (By Paul Yuknewicz) more
  • Mocking LINQ Queries, Extension methods and Anonymous Types more
  • Linq Data Services and the Business Logic Layer more

News Categories

.NET | Agile | Ajax | Architecture | ASP.NET | BizTalk | C# | Certification | Data | DataGrid | DataSet | Debugger | DotNetNuke | Events | GridView | IIS | Indigo | JavaScript | Mobile | Mono | Patterns and Practices | Performance | Podcast | Refactor | Regex | Security | Sharepoint | Silverlight | Smart Client Applications | Software | SQL | VB.NET | Visual Studio | W3 | WCF | WinFx | WPF | WSE | XAML | XLinq | XML | XSD