Created
September 10, 2014 07:10
-
-
Save masaru-b-cl/73b01ad7ea3687908784 to your computer and use it in GitHub Desktop.
好きな項目でMax/Minするケース
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.VisualStudio.TestTools.UnitTesting; | |
using System; | |
using System.Linq; | |
namespace UnitTestProject2 | |
{ | |
class Person : IComparable<Person> | |
{ | |
public int Age { get; set; } | |
public string Name { get; set; } | |
public int CompareTo(Person other) | |
{ | |
return this.Age.CompareTo(other.Age); | |
} | |
} | |
[TestClass] | |
public class UnitTest1 | |
{ | |
[TestMethod] | |
public void TestMethod1() | |
{ | |
var source = new Person[] | |
{ | |
new Person{Age=24, Name="John"}, | |
new Person{Age=19, Name="Jack"}, | |
new Person{Age=32, Name="Brown"}, | |
}; | |
Assert.AreEqual("Brown", source.Max().Name); // Sucess | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment