Skip to content

Instantly share code, notes, and snippets.

@cromwellryan
Created September 7, 2012 13:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cromwellryan/3666439 to your computer and use it in GitHub Desktop.
Save cromwellryan/3666439 to your computer and use it in GitHub Desktop.
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