locked
Linq Unit Testing Not Supported? RRS feed

  • Question

  •  

    I am writing unit test for my Linq Project using VS 2008 B2 and VS 2008 Test

     I get the following compiler error in my unit test project if I use a linq select new {...} in the actual project.  

     

    Warning 1 Method '<WhenEver>b__3' does not have a method body. LinqUnitTest

     

    The actual project compiles and runs fine but the unit test does not compile..

     

    Also if I put this code directly into the unit test project it will compile as well. (if the actual project does not have the select new ....)

     

    Has anyone seen thius error before or any ideas on how to correct.  Is this just a bug in the Beta or is Linq not supported by the VSTS testing framework.

     

    Thanks!

     

    ---  Test project

    public class test

    {

    public string v1;

    public string v2;

    }

    public class WhatEver

    {

    public void WhenEver()

    {

    var tests = new List<test>

    {

    new test { v1 = "A", v2 = "b" },

    new test { v1 = "A", v2 = "b" }

    };

    var result = from x in tests

    //select x.v1 ;                              --- This compiles fine in project and unit

    -- test project

    select new { x1 = x.v1, x2 = x.v2 };    --- This compile fine in project but causes

        ---the unit test project compile to fail

    }

    }



    Wednesday, November 14, 2007 10:23 AM

Answers

All replies