Click here to Skip to main content
15,886,079 members
Articles / Programming Languages / C#

Improving LINQ Code Reusability: Select Method

Rate me:
Please Sign up or sign in to vote.
5.00/5 (2 votes)
27 Nov 2012CPOL3 min read 9.9K   41   8  
A simple approach that will allow you to reuse the code used in the Select method
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!--This file represents the results of running a test suite-->
<test-results name="C:\Projects\LINQ-Select\Tests\bin\Debug\Tests.dll" total="8" errors="0" failures="0" not-run="0" inconclusive="0" ignored="0" skipped="0" invalid="0" date="2012-11-24" time="20:49:19">
  <environment nunit-version="2.6.2.12296" clr-version="2.0.50727.5456" os-version="Microsoft Windows NT 6.1.7601 Service Pack 1" platform="Win32NT" cwd="C:\Program Files (x86)\NUnit 2.6.2\bin" machine-name="RUI-PC" user="Rui" user-domain="RUI-PC" />
  <culture-info current-culture="pt-PT" current-uiculture="en-US" />
  <test-suite type="Assembly" name="C:\Projects\LINQ-Select\Tests\bin\Debug\Tests.dll" executed="True" result="Success" success="True" time="0.203" asserts="0">
    <results>
      <test-suite type="Namespace" name="Tests" executed="True" result="Success" success="True" time="0.172" asserts="0">
        <results>
          <test-suite type="TestFixture" name="ObjectMapperTests" executed="True" result="Success" success="True" time="0.172" asserts="0">
            <results>
              <test-case name="Tests.ObjectMapperTests.Given_a_non_existing_mapping_when_mapping_object_then_should_throw_InvalidOperationException" executed="True" result="Success" success="True" time="0.063" asserts="1" />
              <test-suite type="ParameterizedTest" name="Given_an_album_when_mapping_to_album_detail_should_equals_expected_album_detail" executed="True" result="Success" success="True" time="0.031" asserts="0">
                <results>
                  <test-case name="Tests.ObjectMapperTests.Given_an_album_when_mapping_to_album_detail_should_equals_expected_album_detail(null,null)" executed="True" result="Success" success="True" time="0.016" asserts="1" />
                  <test-case name="Tests.ObjectMapperTests.Given_an_album_when_mapping_to_album_detail_should_equals_expected_album_detail([No Artist] - . Genre: [No Genre],[null] - [null]. Genre: [null])" executed="True" result="Success" success="True" time="0.016" asserts="1" />
                </results>
              </test-suite>
              <test-suite type="ParameterizedTest" name="Given_an_album_when_mapping_to_album_summary_should_equals_expected_album_summary" executed="True" result="Success" success="True" time="0.016" asserts="0">
                <results>
                  <test-case name="Tests.ObjectMapperTests.Given_an_album_when_mapping_to_album_summary_should_equals_expected_album_summary(null,null)" executed="True" result="Success" success="True" time="0.000" asserts="1" />
                  <test-case name="Tests.ObjectMapperTests.Given_an_album_when_mapping_to_album_summary_should_equals_expected_album_summary([No Artist] - . Genre: [No Genre],[null] - [null])" executed="True" result="Success" success="True" time="0.000" asserts="1" />
                  <test-case name="Tests.ObjectMapperTests.Given_an_album_when_mapping_to_album_summary_should_equals_expected_album_summary(José James - The Dreamer. Genre: Jazz,José James - The Dreamer)" executed="True" result="Success" success="True" time="0.000" asserts="1" />
                  <test-case name="Tests.ObjectMapperTests.Given_an_album_when_mapping_to_album_summary_should_equals_expected_album_summary(The Butterfly Effect - Final Conversation of Kings. Genre: Progressive Rock,The Butterfly Effect - Final Conversation of Kings)" executed="True" result="Success" success="True" time="0.000" asserts="1" />
                  <test-case name="Tests.ObjectMapperTests.Given_an_album_when_mapping_to_album_summary_should_equals_expected_album_summary(Opeth - Heritage. Genre: Metal,Opeth - Heritage)" executed="True" result="Success" success="True" time="0.000" asserts="1" />
                </results>
              </test-suite>
            </results>
          </test-suite>
        </results>
      </test-suite>
    </results>
  </test-suite>
</test-results>

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)


Written By
Software Developer (Senior)
Italy Italy
My name is Rui Jarimba and I was born in Madeira island, Portugal and I currently live in Rome, Italy.

I have more than 10 years of experience developing software using the .NET Framework and other technologies (Web development, Databases, ...).

Some of my professional interests are: software development best practices, software architecture, cloud computing, Continuous Integration (CI), Continuous Delivery (CD) and agile methodologies such as Scrum, Kanban, Lean and any other methodology that can help me to become a better and more productive software engineer.

I believe in good code - code that is readable, maintainable, reusable, testable and deployable. This means that I'm not the "quick and dirty" type, I write code for the medium/long term whenever possible.

Something else about me - I love music, I am an amateur photographer, not a big fan of gyms (I prefer to do some outdoor activity such as walking/hiking), big foodie (I love Mediterranean cuisine and my glass of wine!).

Comments and Discussions