Created
September 7, 2012 13:53
-
-
Save cromwellryan/3666439 to your computer and use it in GitHub Desktop.
This file contains 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
namespace ClassLibrary3 | |
{ | |
using System.Diagnostics; | |
using Xunit; | |
public class CombiningEnums | |
{ | |
[Fact] | |
public void EnumsCanBeXored() | |
{ | |
const Colors Green = Colors.Blue | Colors.Yellow; | |
Green.Contains(Colors.Yellow); | |
Green.Contains(Colors.Blue); | |
Green.DoesNotContain(Colors.Red); | |
} | |
} | |
public static class ColorAsserts | |
{ | |
public static void Contains(this Colors color, Colors target) | |
{ | |
Assert.Equal(color & target, target); | |
} | |
public static void DoesNotContain(this Colors color, Colors target) | |
{ | |
Assert.NotEqual(color | target, target); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment