コード例 #1
0
        public void FrameletTypes_AreAsSpecified()
        {
            var expectedFramelets = new []
            {
                new { EnumMember = FrameletType.EpoxyConfig, ExpectedValue = 0x4743 },
                new { EnumMember = FrameletType.EpoxyHeaders, ExpectedValue = 0x5248 },
                new { EnumMember = FrameletType.LayerData, ExpectedValue = 0x594C },
                new { EnumMember = FrameletType.PayloadData, ExpectedValue = 0x5444 },
                new { EnumMember = FrameletType.ProtocolError, ExpectedValue = 0x5245 },
            };

            foreach (var ft in expectedFramelets)
            {
                Assert.AreEqual(
                    ft.ExpectedValue,
                    (int)ft.EnumMember,
                    "FrameletType {0} did not have the speced value",
                    Enum.GetName(typeof(FrameletType), ft.EnumMember));

                Assert.IsTrue(
                    Framelet.IsKnownType((UInt16)ft.EnumMember),
                    "FrameletType {0} is not known to Framelet",
                    ft.EnumMember);
            }

            var expectedEnumMembers = from ft in expectedFramelets select ft.EnumMember;
            var enumMembers         = Enum.GetValues(typeof(FrameletType)).Cast <FrameletType>();

            CollectionAssert.AreEquivalent(expectedEnumMembers, enumMembers);
        }
コード例 #2
0
 public void Framelet_ctor_UnknownFrameletType_Throws()
 {
     Assert.IsFalse(Enum.IsDefined(typeof(FrameletType), UnknownFramelet));
     Assert.Throws <ArgumentException>(() => new Framelet((FrameletType)UnknownFramelet, AnyContents));
     Assert.IsFalse(Framelet.IsKnownType((unchecked ((UInt16)UnknownFramelet))));
 }