Example #1
0
        public void SetFlag_Zero_NoChange()
        {
            ZeroFlags twoAndThree = ZeroFlags.Two | ZeroFlags.Three;

            Assert.That(twoAndThree.ToString(), Is.EqualTo("Two, Three"));
            var noneExtra = twoAndThree.SetFlag(ZeroFlags.Zero);

            Assert.That(noneExtra.ToString(), Is.EqualTo("Two, Three"));
        }
Example #2
0
        public void ToggleFlag_Zero_NoChange()
        {
            ZeroFlags twoAndThree = ZeroFlags.Two | ZeroFlags.Three;

            Assert.That(twoAndThree.ToString(), Is.EqualTo("Two, Three"));

            var toggleFlagNone = twoAndThree.ToggleFlag(ZeroFlags.Zero);

            Assert.That(toggleFlagNone.ToString(), Is.EqualTo("Two, Three"));
        }
Example #3
0
        public void UnsetFlag_Zero_NoChange()
        {
            ZeroFlags twoAndThree = ZeroFlags.Two | ZeroFlags.Three;

            Assert.That(twoAndThree.ToString(), Is.EqualTo("Two, Three"));

            var unsetNone = twoAndThree.UnsetFlag(ZeroFlags.Zero);

            Assert.That(unsetNone.ToString(), Is.EqualTo("Two, Three"));
        }
Example #4
0
        public void GetFlags_DoesNotReturnUnsetFields()
        {
            NoZeroFlags nzf = NoZeroFlags.One | NoZeroFlags.Three;

            Assert.That(nzf.GetFlags(),
                        Has.No.Member(NoZeroFlags.Two)
                        .And.No.Member(NoZeroFlags.Four));

            ZeroFlags zf = ZeroFlags.One | ZeroFlags.Three;

            Assert.That(zf.GetFlags(), Has
                        .No.Member(ZeroFlags.Two)
                        .And.No.Member(ZeroFlags.Four)
                        .And.Member(ZeroFlags.Zero));
        }
Example #5
0
        public void GetFlags_ReturnsSetFieldsInOrderOfDefinition()
        {
            NoZeroFlags nzf = NoZeroFlags.One | NoZeroFlags.Three;

            Assert.That(nzf.GetFlags(true), Is.EquivalentTo(new[] { NoZeroFlags.One, NoZeroFlags.Three }));
            Assert.That(nzf.GetFlags(false), Is.EquivalentTo(new[] { NoZeroFlags.One, NoZeroFlags.Three }));

            nzf = NoZeroFlags.Four | NoZeroFlags.One;
            Assert.That(nzf.GetFlags(true), Is.EquivalentTo(new[] { NoZeroFlags.One, NoZeroFlags.Four }));
            Assert.That(nzf.GetFlags(false), Is.EquivalentTo(new[] { NoZeroFlags.One, NoZeroFlags.Four }));

            ZeroFlags zf = ZeroFlags.One | ZeroFlags.Three;

            Assert.That(zf.GetFlags(true), Is.EquivalentTo(new[] { ZeroFlags.One, ZeroFlags.Three }));
            Assert.That(zf.GetFlags(false), Is.EquivalentTo(new[] { ZeroFlags.Zero, ZeroFlags.One, ZeroFlags.Three }));
            Assert.That(zf.GetFlags(), Is.EquivalentTo(new[] { ZeroFlags.Zero, ZeroFlags.One, ZeroFlags.Three }));

            zf = ZeroFlags.Four | ZeroFlags.One;
            Assert.That(zf.GetFlags(true), Is.EquivalentTo(new[] { ZeroFlags.One, ZeroFlags.Four }));
            Assert.That(zf.GetFlags(false), Is.EquivalentTo(new[] { ZeroFlags.Zero, ZeroFlags.One, ZeroFlags.Four }));
            Assert.That(zf.GetFlags(), Is.EquivalentTo(new[] { ZeroFlags.Zero, ZeroFlags.One, ZeroFlags.Four }));
        }