public void Flags() { var Test = new NotebookDialog<FlagsTest>("Which is good?"); FlagsTest Result = new FlagsTest(); Assert.IsTrue(Test.Run(Result)); Assert.AreEqual(Fruit.Apple | Fruit.Banana, Result.Choose); Assert.AreEqual(Fruit.Apple | Fruit.Banana, Result.Choose2); }
static void FlagsBinaryTest() { FlagsTest flags1 = FlagsTest.First; FlagsTest flags2 = FlagsTest.First | FlagsTest.Second; FlagsTest flags3 = FlagsTest.Third | FlagsTest.Fifth; FlagsTest flags4 = FlagsTest.Second | FlagsTest.Third | FlagsTest.Fourth; FlagsTest flags5 = flags2 | FlagsTest.Fourth; Debug.Log(string.Format("Flags1: {0}", flags1)); Debug.Log(string.Format("Flags2: {0}", flags2)); Debug.Log(string.Format("Flags3: {0}", flags3)); Debug.Log(string.Format("Flags4: {0}", flags4)); Debug.Log(string.Format("Flags1 included in 2: {0}", (flags1 & flags2) > 0)); Debug.Log(string.Format("Fifth included in Flags4: {0}", (FlagsTest.Fifth & flags4) > 0)); Debug.Log(string.Format("Second not included in 3: {0}", (FlagsTest.Second & flags3) == 0)); Debug.Log(string.Format("Flags1 and Second only in 2: {0}", (flags1 | FlagsTest.Second) == flags2)); Debug.Log(string.Format("Flags3 and Fourth only in 4: {0}", (flags3 | FlagsTest.Fourth) == flags4)); Debug.Log(string.Format("Flags2 and 4 share values: {0}", (flags2 & flags4) > 0)); Debug.Log(string.Format("Flags3 and 5 don't share values: {0}", (flags3 & flags5) == 0)); Debug.Log(string.Format("Flags3 and 5 don't share values: {0}", flags3 == ~flags5)); Debug.Log(string.Format("Both Flags1 and 3 share values with 4: {0}", ((flags1 & flags4) > 0 && (flags3 & flags4) > 0))); Debug.Log(string.Format("Values of Flags1 or 2 included in 4: {0}", ((flags1 | flags2) & flags4) > 0)); }