Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

LINQ Performance Test: My First Visual Studio 2008 Project

, 21 Dec 2007
A sample Visual Studio 2008 project that compares the performance of LINQ to simpler loops
linqtest_src.zip
Properties
TestProject1
obj
Debug
TempPE
Release
LinqTest_Accessor.dll
LinqTest_Accessor.pdb
ResolveAssemblyReference.cache
TempPE
TestProject1.dll
TestProject1.pdb
Properties
Test References
LinqTest.accessor
using LinqTest;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace TestProject1
{
    
    
    /// <summary>
    ///This is a test class for ProgramTest and is intended
    ///to contain all ProgramTest Unit Tests
    ///</summary>
    [TestClass()]
    public class ProgramTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for FillArray
        ///</summary>
        [TestMethod()]
        [DeploymentItem("LinqTest.exe")]
        public void FillArrayTest()
        {
            int n = 10; // TODO: Initialize to an appropriate value
            Program_Accessor.FillArray(n);
            Assert.AreEqual(n, Program_Accessor.theArray.Length);
        }

        /// <summary>
        ///A test for GetOdd
        ///</summary>
        [TestMethod()]
        [DeploymentItem("LinqTest.exe")]
        public void GetOddTest()
        {
            int expected = 1; // In every 2 numbers, one is odd
            int actual;
            Program_Accessor.FillArray(2);
            actual = Program_Accessor.GetOdd();
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for GetOddForEach
        ///</summary>
        [TestMethod()]
        [DeploymentItem("LinqTest.exe")]
        public void GetOddForEachTest()
        {
            int expected = 1; // In every 2 numbers, one is odd
            int actual;
            Program_Accessor.FillArray(2);
            actual = Program_Accessor.GetOddForEach();
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for GetOddLinq
        ///</summary>
        [TestMethod()]
        [DeploymentItem("LinqTest.exe")]
        public void GetOddLinqTest()
        {
            int expected = 1; // In every 2 numbers, one is odd
            int actual;
            Program_Accessor.FillArray(2);
            actual = Program_Accessor.GetOddLinq();
            Assert.AreEqual(expected, actual);
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Guy Vider
Product Manager
United States United States
Currently, I manage the West Coast Professional Services team for a large company. Part of my job includes implementing solutions and developing "glue" applications.
 
I love RAD (Rapid Application Development) - specify a problem, come up with the solution, code it - and change later. This is where coding comes closest to art. Just let it flow...
 
If you want more biographical items, look at my LinkedIn profile at http://www.linkedin.com/in/gvider and if you'd like to see my opinion on other tech-related subjects, read my blog at http://www.guyvider.com.

| Advertise | Privacy | Mobile
Web04 | 2.8.140827.1 | Last Updated 22 Dec 2007
Article Copyright 2007 by Guy Vider
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid