コード例 #1
0
        public void HasValidValue()
        {
            Assert.ThrowsExact <ArgumentNullException>(() => EnumExtensions.HasValidValue(null));

            bool result = false;

            Assert.DoesNotThrow(() => result = EnumSimpleFlags.BitOne.HasValidValue());
            Assert.True(result);
            Assert.DoesNotThrow(() => result = (~EnumSimpleFlags.BitOne).HasValidValue());
            Assert.False(result);
            Assert.DoesNotThrow(() => result = EnumSimpleFlags.None.HasValidValue());
            Assert.True(result);

            Assert.DoesNotThrow(() => result = EnumSimpleDuplicateFlags.BitThree.HasValidValue());
            Assert.True(result);
            Assert.DoesNotThrow(() => result = EnumSimpleDuplicateFlags.BitAlsoThree.HasValidValue());
            Assert.True(result);
            Assert.DoesNotThrow(() => result = (~EnumSimpleDuplicateFlags.BitThree).HasValidValue());
            Assert.False(result);
            Assert.DoesNotThrow(() => result = EnumSimpleDuplicateFlags.None.HasValidValue());
            Assert.True(result);

            Assert.DoesNotThrow(() => result = EnumVanilla.Three.HasValidValue());
            Assert.True(result);
            Assert.DoesNotThrow(() => result = ((EnumVanilla)(-1)).HasValidValue());
            Assert.False(result);
            Assert.DoesNotThrow(() => result = EnumVanilla.None.HasValidValue());
            Assert.True(result);

            Assert.DoesNotThrow(() => result = EnumVanillaDuplicate.One.HasValidValue());
            Assert.True(result);
            Assert.DoesNotThrow(() => result = EnumVanillaDuplicate.AlsoOne.HasValidValue());
            Assert.True(result);
            Assert.DoesNotThrow(() => result = ((EnumVanillaDuplicate)(-1)).HasValidValue());
            Assert.False(result);
            Assert.DoesNotThrow(() => result = EnumVanillaDuplicate.None.HasValidValue());
            Assert.True(result);

            Assert.DoesNotThrow(() => result = EnumComboFlags.BitsOneThree.HasValidValue());
            Assert.True(result);
            Assert.DoesNotThrow(() => result = (EnumComboFlags.BitOne | (EnumComboFlags)(1 << 4)).HasValidValue());
            Assert.False(result);
            Assert.DoesNotThrow(() => result = EnumComboFlags.BitsOneTwoThree.HasValidValue());
            Assert.True(result);
            Assert.DoesNotThrow(() => result = (EnumComboFlags.BitsOneTwoThree | (EnumComboFlags)(1 << 4)).HasValidValue());
            Assert.False(result);
            Assert.DoesNotThrow(() => result = ((EnumComboFlags)(0)).HasValidValue());
            Assert.False(result);

            Assert.DoesNotThrow(() => result = EnumComboOnlyFlags.BitsOneFour.HasValidValue());
            Assert.True(result);
            Assert.DoesNotThrow(() => result = (EnumComboOnlyFlags.BitOne | (EnumComboOnlyFlags)(1 << 5)).HasValidValue());
            Assert.False(result);
            Assert.DoesNotThrow(() => result = EnumComboOnlyFlags.BitsOneTwoFour.HasValidValue());
            Assert.True(result);
            Assert.DoesNotThrow(() => result = (EnumComboOnlyFlags.BitsOneTwoFour | (EnumComboOnlyFlags)(1 << 5)).HasValidValue());
            Assert.False(result);
            Assert.DoesNotThrow(() => result = ((EnumComboOnlyFlags)(1 << 3)).HasValidValue());
            Assert.False(result);
        }
コード例 #2
0
        public void ArgumentValidation()
        {
            var reader = new PackedBitReader(sPackedBitWriterOutput);

            string output;

            Assert.ThrowsExact <ArgumentNullException>(() => reader.TryRead(out output, null));
        }
コード例 #3
0
        public void ArgumentValidation()
        {
            var inst = new PackedBitSerializer(typeof(ImplementingType));

            Assert.ThrowsExact <ArgumentNullException>(() => inst.Deserialize(null));
            Assert.ThrowsExact <ArgumentNullException>(() => inst.Serialize(null, true));
            Assert.ThrowsExact <ArgumentNullException>(() => inst.Serialize(new PackedBitWriter(), null as string));
        }
コード例 #4
0
        public void As()
        {
            Assert.ThrowsExact <ArgumentNullException>(() => EnumExtensions.As <int>(null));
            Assert.ThrowsExact <InvalidOperationException>(() => EnumExtensions.As <double>(EnumVanilla.None));
            Assert.ThrowsExact <InvalidOperationException>(() => EnumExtensions.As <Guid>(EnumVanilla.None));
            Assert.ThrowsExact <InvalidOperationException>(() => EnumExtensions.As <DateTime>(EnumVanilla.None));

            int value = 0;

            value = 0;
            Assert.DoesNotThrow(() => value = EnumVanilla.One.As <sbyte>());
            Assert.Equal(value, 1);

            value = 0;
            Assert.DoesNotThrow(() => value = EnumVanilla.One.As <short>());
            Assert.Equal(value, 1);

            value = 0;
            Assert.DoesNotThrow(() => value = EnumVanilla.One.As <int>());
            Assert.Equal(value, 1);

            value = 0;
            Assert.DoesNotThrow(() => value = (int)EnumVanilla.One.As <long>());
            Assert.Equal(value, 1);

            value = 0;
            Assert.DoesNotThrow(() => value = EnumVanilla.One.As <byte>());
            Assert.Equal(value, 1);

            value = 0;
            Assert.DoesNotThrow(() => value = EnumVanilla.One.As <ushort>());
            Assert.Equal(value, 1);

            value = 0;
            Assert.DoesNotThrow(() => value = (int)EnumVanilla.One.As <uint>());
            Assert.Equal(value, 1);

            value = 0;
            Assert.DoesNotThrow(() => value = (int)EnumVanilla.One.As <ulong>());
            Assert.Equal(value, 1);

            value = 0;
            Assert.ThrowsExact <OverflowException>(() => value = EnumVanilla.Huge.As <byte>());
            Assert.ThrowsExact <OverflowException>(() => value = EnumVanilla.Huge.As <sbyte>());
            Assert.ThrowsExact <OverflowException>(() => value = EnumVanilla.Huge.As <ushort>());
            Assert.ThrowsExact <OverflowException>(() => value = EnumVanilla.Huge.As <short>());
            Assert.ThrowsExact <OverflowException>(() => value = ((EnumVanilla)(-1)).As <ushort>());

            value = 0;
            Assert.DoesNotThrow(() => value = default(EnumNoValues).As <byte>());
            Assert.Equal(value, 0);
        }
コード例 #5
0
 public void Constructor()
 {
     Assert.ThrowsExact <ArgumentNullException>(() => new PackedBitSerializer(null));
     Assert.ThrowsExact <ArgumentException>(() => new PackedBitSerializer(typeof(NonImplementingType)));
     Assert.ThrowsExact <ArgumentException>(() => new PackedBitSerializer(typeof(NonImplementingTypeWithProperty)));
     Assert.DoesNotThrow(() => new PackedBitSerializer(typeof(ImplementingType)));
     Assert.DoesNotThrow(() => new PackedBitSerializer(typeof(ImplementingTypeWithProperty)));
     Assert.DoesNotThrow(() => new PackedBitSerializer(typeof(NonImplementingTypeWithAttribute)));
     Assert.ThrowsExact <ArgumentException>(() => new PackedBitSerializer(typeof(NonImplementingTypeWithConflictingAttribute)));
     Assert.ThrowsExact <ArgumentException>(() => new PackedBitSerializer(typeof(NonImplementingTypeWithString)));
     Assert.ThrowsExact <ArgumentException>(() => new PackedBitSerializer(typeof(NonImplementingTypeWithList)));
     Assert.DoesNotThrow(() => new PackedBitSerializer(typeof(ImplementingTypeWithStringProperty)));
 }
コード例 #6
0
ファイル: Extensions.cs プロジェクト: LazyBui/BitPackerTools
        public void Implements()
        {
            Type t = null;

            Assert.ThrowsExact <ArgumentNullException>(() => t.Implements <ITestImplement>());

            t = typeof(TestNoInterface);
            Assert.DoesNotThrow(() => t.Implements <ITestImplement>());
            Assert.False(t.Implements <ITestImplement>());

            t = typeof(TestInterface);
            Assert.DoesNotThrow(() => t.Implements <ITestImplement>());
            Assert.True(t.Implements <ITestImplement>());
        }
コード例 #7
0
        public void HasNoFlags()
        {
            EnumSimpleFlags invalid = (EnumSimpleFlags)(-1);

            Assert.ThrowsExact <ArgumentNullException>(() => EnumExtensions.HasNoFlags(null));
            Assert.ThrowsExact <ArgumentNullException>(() => EnumExtensions.HasNoFlags(null, EnumSimpleFlags.None));
            Assert.ThrowsExact <ArgumentNullException>(() => EnumExtensions.HasNoFlags(EnumSimpleFlags.None, null));
            Assert.ThrowsExact <ArgumentNullException>(() => EnumExtensions.HasNoFlags(EnumSimpleFlags.None, EnumSimpleFlags.None, null));
            Assert.ThrowsExact <ArgumentException>(() => EnumExtensions.HasNoFlags(invalid, EnumSimpleFlags.None));
            Assert.ThrowsExact <ArgumentException>(() => EnumExtensions.HasNoFlags(EnumSimpleFlags.None, invalid));
            Assert.ThrowsExact <ArgumentException>(() => EnumExtensions.HasNoFlags(EnumSimpleFlags.None, EnumSimpleFlags.None, null as Enum));
            Assert.ThrowsExact <ArgumentException>(() => EnumExtensions.HasNoFlags(EnumSimpleFlags.None, EnumSimpleFlags.None, invalid));
            Assert.ThrowsExact <ArgumentException>(() => EnumExtensions.HasNoFlags(EnumComboFlags.BitOne, EnumSimpleFlags.None));
            Assert.ThrowsExact <ArgumentException>(() => EnumExtensions.HasNoFlags(EnumSimpleFlags.None, EnumComboFlags.BitOne));
            Assert.ThrowsExact <ArgumentException>(() => EnumExtensions.HasNoFlags(EnumSimpleFlags.None, EnumSimpleFlags.None, EnumComboFlags.BitOne));

            bool result = false;

            Assert.DoesNotThrow(() => result = EnumSimpleFlags.BitOne.HasNoFlags());
            Assert.False(result);
            Assert.DoesNotThrow(() => result = EnumSimpleFlags.None.HasNoFlags());
            Assert.True(result);
            Assert.DoesNotThrow(() => result = (EnumSimpleFlags.BitOne | EnumSimpleFlags.BitTwo | EnumSimpleFlags.BitThree | EnumSimpleFlags.BitFour).HasNoFlags());
            Assert.False(result);

            Assert.DoesNotThrow(() => result = EnumComboFlags.BitOne.HasNoFlags(EnumComboFlags.BitsOneThree));
            Assert.False(result);
            Assert.DoesNotThrow(() => result = EnumComboFlags.BitsOneThree.HasNoFlags(EnumComboFlags.BitOne));
            Assert.False(result);
            Assert.DoesNotThrow(() => result = EnumComboFlags.BitsOneThree.HasNoFlags(EnumComboFlags.BitTwo));
            Assert.True(result);
            Assert.DoesNotThrow(() => result = EnumComboFlags.BitsOneThree.HasNoFlags(EnumComboFlags.BitOne, EnumComboFlags.BitTwo));
            Assert.False(result);
            Assert.DoesNotThrow(() => result = EnumComboFlags.BitsOneThree.HasNoFlags(EnumComboFlags.BitOne, EnumComboFlags.BitThree));
            Assert.False(result);

            Assert.DoesNotThrow(() => result = EnumComboOnlyFlags.BitOne.HasNoFlags(EnumComboOnlyFlags.BitsOneFour));
            Assert.False(result);
            Assert.DoesNotThrow(() => result = EnumComboOnlyFlags.BitsOneFour.HasNoFlags(EnumComboOnlyFlags.BitOne));
            Assert.False(result);
            Assert.DoesNotThrow(() => result = EnumComboOnlyFlags.BitsOneFour.HasNoFlags(EnumComboOnlyFlags.BitTwo));
            Assert.True(result);
            Assert.DoesNotThrow(() => result = EnumComboOnlyFlags.BitsOneFour.HasNoFlags(EnumComboOnlyFlags.None));
            Assert.True(result);
            Assert.DoesNotThrow(() => result = EnumComboOnlyFlags.None.HasNoFlags(EnumComboOnlyFlags.BitOne));
            Assert.True(result);
            Assert.DoesNotThrow(() => result = EnumComboOnlyFlags.BitsOneFour.HasNoFlags(EnumComboOnlyFlags.BitOne, EnumComboOnlyFlags.BitTwo));
            Assert.False(result);
        }
コード例 #8
0
        public void GenericEnum()
        {
            Assert.ThrowsExact <TypeInitializationException>(() => new int[0].ThrowIfAnyInvalidEnums());
            Assert.ThrowsExact <TypeInitializationException>(() => new float[0].ThrowIfAnyInvalidEnums());
            Assert.ThrowsExact <TypeInitializationException>(() => new Guid[0].ThrowIfAnyInvalidEnums());
            Assert.ThrowsExact <TypeInitializationException>(() => new DateTime[0].ThrowIfAnyInvalidEnums());
            Assert.ThrowsExact <ArgumentNullException>(() => (null as EnumVanilla[]).ThrowIfAnyInvalidEnums());
            Assert.DoesNotThrow(() => new EnumVanilla[0].ThrowIfAnyInvalidEnums());
            Assert.DoesNotThrow(() => new EnumSimpleFlags[0].ThrowIfAnyInvalidEnums());
            Assert.DoesNotThrow(() => new EnumComboFlags[0].ThrowIfAnyInvalidEnums());

            Assert.DoesNotThrow(() => new[] { EnumSimpleFlags.BitOne }.ThrowIfAnyInvalidEnums());
            Assert.ThrowsExact <ArgumentException>(() => new[] { ~EnumSimpleFlags.BitOne }.ThrowIfAnyInvalidEnums());
            Assert.DoesNotThrow(() => new[] { EnumSimpleFlags.None }.ThrowIfAnyInvalidEnums());
            Assert.ThrowsExact <ArgumentException>(() => new[] { EnumSimpleFlags.BitOne, ~EnumSimpleFlags.BitOne, EnumSimpleFlags.None }.ThrowIfAnyInvalidEnums());
        }
コード例 #9
0
        public void ArgumentValidation()
        {
            PackedBitWriter writer = new PackedBitWriter();

            Assert.ThrowsExact <BitCountException>(() => writer.Write(-1, byte.MaxValue));
            Assert.ThrowsExact <BitCountException>(() => writer.Write(-1, ushort.MaxValue));
            Assert.ThrowsExact <BitCountException>(() => writer.Write(-1, uint.MaxValue));
            Assert.ThrowsExact <BitCountException>(() => writer.Write(-1, ulong.MaxValue));
            Assert.ThrowsExact <BitCountException>(() => writer.Write(0, byte.MaxValue));
            Assert.ThrowsExact <BitCountException>(() => writer.Write(0, ushort.MaxValue));
            Assert.ThrowsExact <BitCountException>(() => writer.Write(0, uint.MaxValue));
            Assert.ThrowsExact <BitCountException>(() => writer.Write(0, ulong.MaxValue));
            Assert.ThrowsExact <BitCountException>(() => writer.Write(65, byte.MaxValue));
            Assert.ThrowsExact <BitCountException>(() => writer.Write(65, ushort.MaxValue));
            Assert.ThrowsExact <BitCountException>(() => writer.Write(65, uint.MaxValue));
            Assert.ThrowsExact <BitCountException>(() => writer.Write(65, ulong.MaxValue));
            Assert.ThrowsExact <BitCountException>(() => writer.Write(-1, sbyte.MaxValue));
            Assert.ThrowsExact <BitCountException>(() => writer.Write(-1, short.MaxValue));
            Assert.ThrowsExact <BitCountException>(() => writer.Write(-1, int.MaxValue));
            Assert.ThrowsExact <BitCountException>(() => writer.Write(-1, long.MaxValue));
            Assert.ThrowsExact <BitCountException>(() => writer.Write(0, sbyte.MaxValue));
            Assert.ThrowsExact <BitCountException>(() => writer.Write(0, short.MaxValue));
            Assert.ThrowsExact <BitCountException>(() => writer.Write(0, int.MaxValue));
            Assert.ThrowsExact <BitCountException>(() => writer.Write(0, long.MaxValue));
            Assert.ThrowsExact <BitCountException>(() => writer.Write(65, sbyte.MaxValue));
            Assert.ThrowsExact <BitCountException>(() => writer.Write(65, short.MaxValue));
            Assert.ThrowsExact <BitCountException>(() => writer.Write(65, int.MaxValue));
            Assert.ThrowsExact <BitCountException>(() => writer.Write(65, long.MaxValue));

            Assert.ThrowsExact <ArgumentNullException>(() => writer.Write(null as string));
            Assert.ThrowsExact <ArgumentNullException>(() => writer.Write(null as string, Encoding.UTF8));
            Assert.ThrowsExact <ArgumentNullException>(() => writer.Write("string", null));

            Assert.ThrowsExact <BitCountException>(() => writer.Write(-1, new byte[] { 0 }));
            Assert.ThrowsExact <BitCountException>(() => writer.Write(0, new byte[] { 0 }));
            Assert.ThrowsExact <BitCountException>(() => writer.Write(65, new byte[] { 0 }));

            Assert.ThrowsExact <ArgumentNullException>(() => writer.Write(1, null as byte[]));
            Assert.ThrowsExact <ArgumentException>(() => writer.Write(1, new byte[0]));
            Assert.ThrowsExact <ArgumentException>(() => writer.Write(1, new byte[0]));
        }
コード例 #10
0
        public void IsFlagsType()
        {
            Type enumType = null;

            Assert.ThrowsExact <ArgumentNullException>(() => enumType.IsFlagsType());
            Assert.ThrowsExact <ArgumentNullException>(() => EnumExtensions.IsFlagsType(null as Enum));

            bool result = false;

            Assert.DoesNotThrow(() => result = EnumSimpleFlags.BitOne.IsFlagsType());
            Assert.True(result);

            Assert.DoesNotThrow(() => result = EnumVanilla.Three.IsFlagsType());
            Assert.False(result);

            Assert.DoesNotThrow(() => result = EnumComboFlags.BitsOneThree.IsFlagsType());
            Assert.True(result);

            Assert.DoesNotThrow(() => result = EnumComboOnlyFlags.BitsOneFour.IsFlagsType());
            Assert.True(result);
        }
コード例 #11
0
ファイル: Extensions.cs プロジェクト: LazyBui/BitPackerTools
        public void HasAttribute()
        {
            Func <Type, PropertyInfo> getProperty = (type) => type.GetProperty("Test", BindingFlags.Public | BindingFlags.Instance);
            PropertyInfo prop   = null;
            bool         result = false;

            Assert.ThrowsExact <ArgumentNullException>(() => prop.HasAttribute <TestingAttribute>());

            prop = getProperty(typeof(NoAttributeProperty));
            Assert.DoesNotThrow(() => result = prop.HasAttribute <TestingAttribute>());
            Assert.False(result);

            Assert.DoesNotThrow(() => result = prop.HasAttribute <DifferentAttribute>());
            Assert.False(result);

            prop = getProperty(typeof(TestingAttributeProperty));
            Assert.DoesNotThrow(() => result = prop.HasAttribute <TestingAttribute>());
            Assert.True(result);

            Assert.DoesNotThrow(() => result = prop.HasAttribute <DifferentAttribute>());
            Assert.False(result);

            prop = getProperty(typeof(DifferentAttributeProperty));
            Assert.DoesNotThrow(() => result = prop.HasAttribute <TestingAttribute>());
            Assert.False(result);

            Assert.DoesNotThrow(() => result = prop.HasAttribute <DifferentAttribute>());
            Assert.True(result);

            prop = getProperty(typeof(MultiAttributeProperty));
            Assert.DoesNotThrow(() => result = prop.HasAttribute <TestingAttribute>());
            Assert.True(result);

            Assert.DoesNotThrow(() => result = prop.HasAttribute <DifferentAttribute>());
            Assert.True(result);
        }
コード例 #12
0
        public void ThrowIfInvalid()
        {
            Assert.ThrowsExact <ArgumentNullException>(() => EnumExtensions.ThrowIfInvalid(null));

            EnumSimpleFlags testSimpleFlags1 = EnumSimpleFlags.BitOne;

            Assert.DoesNotThrow(() => testSimpleFlags1.ThrowIfInvalid());

            EnumSimpleFlags testSimpleFlags2 = ~EnumSimpleFlags.BitOne;

            Assert.ThrowsExact <ArgumentException>(() => testSimpleFlags2.ThrowIfInvalid());

            EnumSimpleFlags testSimpleFlags3 = EnumSimpleFlags.None;

            Assert.DoesNotThrow(() => testSimpleFlags3.ThrowIfInvalid());

            EnumSimpleDuplicateFlags testSimpleDuplicateFlags1 = EnumSimpleDuplicateFlags.BitThree;

            Assert.DoesNotThrow(() => testSimpleDuplicateFlags1.ThrowIfInvalid());

            EnumSimpleDuplicateFlags testSimpleDuplicateFlags2 = ~EnumSimpleDuplicateFlags.BitAlsoThree;

            Assert.ThrowsExact <ArgumentException>(() => testSimpleDuplicateFlags2.ThrowIfInvalid());

            EnumSimpleDuplicateFlags testSimpleDuplicateFlags3 = EnumSimpleDuplicateFlags.None;

            Assert.DoesNotThrow(() => testSimpleDuplicateFlags3.ThrowIfInvalid());

            EnumVanilla testVanilla1 = EnumVanilla.Three;

            Assert.DoesNotThrow(() => testVanilla1.ThrowIfInvalid());

            EnumVanilla testVanilla2 = (EnumVanilla)(-1);

            Assert.ThrowsExact <ArgumentException>(() => testVanilla2.ThrowIfInvalid());

            EnumVanilla testVanilla3 = EnumVanilla.None;

            Assert.DoesNotThrow(() => testVanilla3.ThrowIfInvalid());

            EnumVanillaDuplicate testVanillaDuplicate1 = EnumVanillaDuplicate.One;

            Assert.DoesNotThrow(() => testVanillaDuplicate1.ThrowIfInvalid());

            EnumVanillaDuplicate testVanillaDuplicate2 = EnumVanillaDuplicate.AlsoOne;

            Assert.DoesNotThrow(() => testVanillaDuplicate2.ThrowIfInvalid());

            EnumVanillaDuplicate testVanillaDuplicate3 = (EnumVanillaDuplicate)(-1);

            Assert.ThrowsExact <ArgumentException>(() => testVanillaDuplicate3.ThrowIfInvalid());

            EnumComboFlags testComboFlags1 = EnumComboFlags.BitsOneThree;

            Assert.DoesNotThrow(() => testComboFlags1.ThrowIfInvalid());

            EnumComboFlags testComboFlags2 = EnumComboFlags.BitOne | (EnumComboFlags)(1 << 4);

            Assert.ThrowsExact <ArgumentException>(() => testComboFlags2.ThrowIfInvalid());

            EnumComboFlags testComboFlags3 = EnumComboFlags.BitsOneTwoThree;

            Assert.DoesNotThrow(() => testComboFlags3.ThrowIfInvalid());

            EnumComboFlags testComboFlags4 = EnumComboFlags.BitsOneTwoThree | (EnumComboFlags)(1 << 4);

            Assert.ThrowsExact <ArgumentException>(() => testComboFlags4.ThrowIfInvalid());

            EnumComboFlags testComboFlags5 = 0;

            Assert.ThrowsExact <ArgumentException>(() => testComboFlags5.ThrowIfInvalid());

            EnumComboOnlyFlags testComboOnlyFlags1 = EnumComboOnlyFlags.BitsOneFour;

            Assert.DoesNotThrow(() => testComboOnlyFlags1.ThrowIfInvalid());

            EnumComboOnlyFlags testComboOnlyFlags2 = EnumComboOnlyFlags.BitOne | (EnumComboOnlyFlags)(1 << 5);

            Assert.ThrowsExact <ArgumentException>(() => testComboOnlyFlags2.ThrowIfInvalid());

            EnumComboOnlyFlags testComboOnlyFlags3 = EnumComboOnlyFlags.BitsOneTwoFour;

            Assert.DoesNotThrow(() => testComboOnlyFlags3.ThrowIfInvalid());

            EnumComboOnlyFlags testComboOnlyFlags4 = EnumComboOnlyFlags.BitsOneTwoFour | (EnumComboOnlyFlags)(1 << 5);

            Assert.ThrowsExact <ArgumentException>(() => testComboOnlyFlags4.ThrowIfInvalid());

            EnumComboOnlyFlags testComboOnlyFlags5 = (EnumComboOnlyFlags)(1 << 3);

            Assert.ThrowsExact <ArgumentException>(() => testComboOnlyFlags5.ThrowIfInvalid());

            EnumNoValues testNoValues = default(EnumNoValues);

            Assert.ThrowsExact <ArgumentException>(() => testNoValues.ThrowIfInvalid());
        }
コード例 #13
0
 public void Constructor()
 {
     Assert.ThrowsExact <ArgumentNullException>(() => new PackedBitReader(null));
     Assert.ThrowsExact <ArgumentException>(() => new PackedBitReader(new byte[0]));
     Assert.DoesNotThrow(() => new PackedBitReader(new byte[] { 0x22 }));
 }
コード例 #14
0
 public void Constructor()
 {
     Assert.ThrowsExact <ArgumentNullException>(() => new EqualityComparerStateful <int>(null));
     Assert.DoesNotThrow(() => new EqualityComparerStateful <int>((lhs, rhs) => lhs == rhs));
 }
コード例 #15
0
 public void Constructor()
 {
     Assert.ThrowsExact <ArgumentNullException>(() => new EqualityComparerStateless <Testing, int>(null));
     Assert.DoesNotThrow(() => new EqualityComparerStateless <Testing, int>(obj => obj.A));
 }