feyris-tan 30026b2b02
All checks were successful
🚀 Pack skyscraper8 / make-zip (push) Successful in 3m38s
Added functionality necessary to extract the MPEG-DASH segments on the Arsat stream.
2025-11-23 00:27:00 +01:00

601 lines
22 KiB
C#

using System;
using System.IO;
using System.Net.NetworkInformation;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using skyscraper5.Docsis;
using skyscraper5.Docsis.AnnexC;
namespace skyscraper8.Tests.RootTests;
[TestClass]
public class DocsisTests : Feyllure
{
[TestMethod]
public void MacManagementMessageTypeAttributeTest()
{
MacManagementMessageTypeAttribute mmmta = new MacManagementMessageTypeAttribute(1, 2);
Print(mmmta.ToString());
}
[TestMethod]
public void RcpIdEncodingTest()
{
RcpIdEncoding rie = new RcpIdEncoding(new byte[] { 7, 1, 0 });
SimplifiedReceiveChannelAssignmentEncoding simplifiedReceiveChannelAssignmentEncoding = rie.SimplifiedReceiveChannelConfiguration;
Assert.IsNotNull(simplifiedReceiveChannelAssignmentEncoding);
Assert.Throws<NotImplementedException>(() => new RcpIdEncoding(new byte[] { 255, 1, 0 }));
}
[TestMethod]
public void EthernetLlcPacketClassificationEncodingTest()
{
EthernetLlcPacketClassificationEncoding epce = new EthernetLlcPacketClassificationEncoding(new byte[] { 3, 3, 1, 0, 1 });
ushort epceEProt = epce.EProt;
Assert.AreEqual(1, epce.EProt);
Assert.AreEqual(1, epce.Type);
Assert.Throws<NotImplementedException>(() => new EthernetLlcPacketClassificationEncoding(new byte[] { 255, 1, 0 }));
}
[TestMethod]
public void SimplifiedReceiveChannelAssignmentEncodingTest()
{
SimplifiedReceiveChannelAssignmentEncoding srcae =
new SimplifiedReceiveChannelAssignmentEncoding(new byte[] { 1, 1, 0, 2, 1, 0, 3, 1, 0 });
Assert.AreEqual(0,srcae.DownstreamChannelAssignment[0]);
Assert.AreEqual(0, srcae.DownstreamProfileAssignment[0]);
Assert.AreEqual(0, srcae.PrimaryDownstreamChannelAssignment[0]);
Assert.Throws<NotImplementedException>(() => new SimplifiedReceiveChannelAssignmentEncoding(new byte[] { 254,0,1 }));
}
[TestMethod]
public void TransmitChannelConfigurationObjectTest()
{
CommonTlvEncodingObject.TransmitChannelConfigurationObject tcco =
new CommonTlvEncodingObject.TransmitChannelConfigurationObject(
new byte[]
{
1, 1, 0,
2, 1, 0,
3, 1, 0,
5, 4, 0, 0, 0, 0,
6, 2, 0, 0,
7, 1, 1,
9, 1, 0,
10, 1, 0,
11, 1, 0
});
Assert.AreEqual(0, tcco.TccReferenceId.Value);
Assert.AreEqual(CommonTlvEncodingObject.TransmitChannelConfigurationObject.UpstreamChannelActionEnum.NoAction, tcco.UpstreamChannelAction.Value);
Assert.AreEqual(0, tcco.UpstreamChannelId.Value);
Assert.IsNotNull(tcco.UpstreamChannelDescriptor);
Assert.AreEqual(0, tcco.RangingSid.Value);
Assert.AreEqual(InitalizationTechniqueEnum.BroadcastInitialRanging, tcco.InitializationTechnique.Value);
Assert.AreEqual(0, tcco.DynamicRangeWindow);
Assert.AreEqual(0, tcco.P16Hi);
Assert.AreEqual(0, tcco.ListOfIucs[0]);
Assert.Throws<NotImplementedException>(() =>
new CommonTlvEncodingObject.TransmitChannelConfigurationObject(new byte[] { 254, 1, 0 }));
}
[TestMethod]
public void CommonTlvEncodingObjectTest()
{
MemoryStream ms = new MemoryStream(new byte[]
{
5, 1, 0,
47, 1, 0,
49, 1, 0,
31, 1, 0,
27, 1, 0,
30, 1, 0,
52, 2, 0, 1
});
CommonTlvEncodingObject commonTlv = new CommonTlvEncodingObject(ms);
Assert.IsNotNull(commonTlv.ModemCapabilitiesEncoding);
Assert.IsNotNull(commonTlv.ServiceFlowSidClusterAssignment);
Assert.IsNotNull(commonTlv.RcpId);
Assert.AreEqual(0, commonTlv.KeySequenceNumber);
Assert.AreEqual(0, commonTlv.HmacDigest[0]);
Assert.IsNotNull(commonTlv.AuthorizationHint);
Assert.AreEqual(new TimeSpan(0, 0, 1), commonTlv.InitializingChannelTimeout);
ms = new MemoryStream(new byte[] { 254, 1, 0 });
Assert.Throws<NotImplementedException>(() => new CommonTlvEncodingObject(ms));
}
[TestMethod]
public void GeneralPacketClassifierEncodingTest()
{
GeneralPacketClassifierEncoding gpce = new GeneralPacketClassifierEncoding(new byte[]
{
6, 1, 1,
5, 1, 0,
9, 1, 0,
3, 2, 0, 1,
1, 1, 0,
2, 2, 0, 1,
4, 4, 0, 0, 0, 1,
7, 1, 0,
10, 1, 0,
12, 16,
//IPv6 Packet Classification Encoding
3, 2, 0, 1,
4, 4, 127, 0, 0, 1,
6, 4, 127, 0, 0, 1
});
Assert.IsTrue(gpce.ClassifierActivationState.Value);
Assert.AreEqual(0, gpce.RulePriority.Value);
Assert.IsNotNull(gpce.Ipv4PacketClassification);
Assert.AreEqual(1, gpce.ServiceFlowReference.Value);
Assert.AreEqual(0, gpce.ClassifierReference.Value);
Assert.AreEqual(1, gpce.ClassifierIdentifier.Value);
Assert.AreEqual((uint)1, gpce.ServiceFlowIdentifier.Value);
Assert.AreEqual(GeneralPacketClassifierEncoding.DynamicServiceChangeActionEnum.Add, gpce.DynamicServiceChangeAction.Value);
Assert.IsNotNull(gpce.EthernetLlcPacketClassificationEncodings);
Assert.Throws<NotImplementedException>(() => new GeneralPacketClassifierEncoding(new byte[]
{
12, 4,
255, 1, 0, 0
}));
Assert.Throws<NotImplementedException>(() => new GeneralPacketClassifierEncoding(new byte[]
{
254, 1, 0
}));
}
[TestMethod]
public void Ipv4PacketClassificationEncodingTest()
{
GeneralPacketClassifierEncoding.Ipv4PacketClassificationEncodings ipce =
new GeneralPacketClassifierEncoding.Ipv4PacketClassificationEncodings(new byte[]
{
3, 4, 127, 0, 0, 1,
5, 4, 127, 0, 0, 1,
2, 2, 0, 1,
4, 4, 255, 255, 255, 0,
6, 4, 255, 255, 255, 0,
9, 2, 0, 1,
10, 2, 0, 1,
7, 2, 0, 1,
8, 2, 0, 1
});
Assert.IsNotNull(ipce.Ipv4SourceAddress);
Assert.IsNotNull(ipce.Ipv4DestinationAddress);
Assert.AreEqual(1, ipce.IpProtocol.Value);
Assert.IsNotNull(ipce.Ipv4SourceMask);
Assert.IsNotNull(ipce.Ipv4DestinationMask);
Assert.AreEqual(1, ipce.DestinationPortStart.Value);
Assert.AreEqual(1, ipce.DestinationPortEnd.Value);
Assert.AreEqual(1, ipce.SourcePortStart.Value);
Assert.AreEqual(1, ipce.SourcePortEnd.Value);
Assert.Throws<NotImplementedException>(() =>
new GeneralPacketClassifierEncoding.Ipv4PacketClassificationEncodings(new byte[]
{
255, 1, 0
}));
}
[TestMethod]
public void ServiceFlowSidClusterAssignmentObjectTest()
{
ServiceFlowSidClusterAssignmentObject sfscao = new ServiceFlowSidClusterAssignmentObject(new byte[]
{
1, 4, 0, 0, 0, 1,
2, 1, 0,
3, 1, 0,
});
Assert.AreEqual(1u, sfscao.SFID.Value);
Assert.IsNotNull(sfscao.SidClusterEncoding);
Assert.IsNotNull(sfscao.SidClusterSwitchoverCriteria);
Assert.Throws<NotImplementedException>(() => new ServiceFlowSidClusterAssignmentObject(new byte[]
{
255, 1, 0
}));
}
[TestMethod]
public void SidClusterEncodingObjectTest()
{
ServiceFlowSidClusterAssignmentObject.SidClusterEncodingObject sceo =
new ServiceFlowSidClusterAssignmentObject.SidClusterEncodingObject(new byte[]
{
1, 1, 1,
2, 1, 0
});
Assert.AreEqual(1, sceo.SidClusterId.Value);
Assert.IsNotNull(sceo.SidToChannelMapping);
Assert.Throws<NotImplementedException>(() => new ServiceFlowSidClusterAssignmentObject.SidClusterEncodingObject(new byte[]
{
255, 1, 0
}));
}
[TestMethod]
public void SidToChannelMappingObjectTest()
{
ServiceFlowSidClusterAssignmentObject.SidClusterEncodingObject.SidToChannelMappingObject stcmo =
new ServiceFlowSidClusterAssignmentObject.SidClusterEncodingObject.SidToChannelMappingObject(new byte[]
{
1,1,1,
2,2,0,1,
3,1,1
});
Assert.AreEqual(1, stcmo.UpstreamChannelId.Value);
Assert.AreEqual(1, stcmo.SID.Value);
Assert.AreEqual(ServiceFlowSidClusterAssignmentObject.SidClusterEncodingObject.SidToChannelMappingObject.ActionEnum.Add,stcmo.Action.Value);
Assert.Throws<NotImplementedException>(() =>
new ServiceFlowSidClusterAssignmentObject.SidClusterEncodingObject.SidToChannelMappingObject(new byte[]
{
255, 1, 0
}));
}
[TestMethod]
public void Ipv6PacketClassificationEncodingTest()
{
byte[] buffer = new byte[]
{
12, //Type Ipv6 Packet Classification Encoding
40, //Length of IPv6 Packet Classification Encoding
3,2, 0x08,0x00, //Next Header Type
4,16, 0xfd,0x58,0x2f,0x40,0xec,0xe9,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,
6,16, 0xfd,0x73,0x14,0x63,0x41,0x65,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01
};
GeneralPacketClassifierEncoding gpce = new GeneralPacketClassifierEncoding(buffer);
Ipv6PacketClassificationEncoding ipce = gpce.Ipv6PacketClassification;
Assert.IsNotNull(ipce);
Assert.IsNotNull(ipce.Ipv6DestinationAddress);
Assert.IsNotNull(ipce.Ipv6SourceAddress);
Assert.AreEqual(0x0800, ipce.NextHeaderType);
}
[TestMethod]
public void SidClusterSwitchoverCriteriaObjectTest()
{
byte[] buffer = new byte[]
{
1, 1, 1,
2, 4, 0, 0, 0, 1,
3, 4, 0, 0, 0, 1,
4, 2, 0, 1
};
ServiceFlowSidClusterAssignmentObject.SidClusterSwitchoverCriteriaObject scsco =
new ServiceFlowSidClusterAssignmentObject.SidClusterSwitchoverCriteriaObject(buffer);
Assert.AreEqual((byte)1,scsco.MaximumRequestPerSidCluster);
Assert.AreEqual((uint)1, scsco.MaximumOutstandingBytesPerSidCluster);
Assert.AreEqual((uint)1, scsco.MaximumTotalBytesRequestedPerSidCluster);
Assert.AreEqual((ushort)1, scsco.MaximumTimeInTheSidCluster);
buffer = new byte[] { 254, 1, 0 };
Assert.Throws<NotImplementedException>(() =>
new ServiceFlowSidClusterAssignmentObject.SidClusterSwitchoverCriteriaObject(buffer));
}
[TestMethod]
public void ModemCapabilitiesEncodingTest()
{
byte[] buffer = new byte[]
{
1, 1, 1,
2, 1, 0,
3, 1, 1,
4, 1, 1,
6, 1, 1,
7, 1, 1,
8, 1, 1,
10, 1, 1,
11, 1, 1,
12, 1, 1,
15, 1, 1,
16, 4, 1, 2, 3, 4,
17, 1, 1,
18, 7, 1, 0, 0, 0, 0, 0, 0,
19, 1, 1,
20, 1, 2,
21, 1, 255,
22, 1, 1,
23, 1, 1,
24, 1, 2,
25, 1, 2,
26, 1, 2,
27, 1, 2,
28, 1, 2,
29, 1, 2,
30, 1, 3,
31, 1, 3,
32, 1, 3,
33, 1, 2,
34, 1, 1,
35, 1, 255,
36, 1, 3,
37, 1, 0,
38, 2, 0, 3,
39, 1, 1,
40, 1, 4,
44, 0,
46, 1, 1,
47, 4, 0, 0, 0, 255,
48, 2, 0, 4,
49, 1, 4,
50, 1, 5,
51, 1, 5,
52, 2, 1, 2,
53, 2, 1, 2,
54, 1, 1,
55, 1, 1,
56, 1, 0,
57, 1, 3,
58, 1, 5,
59, 2, 0, 5,
60, 1, 3,
76, 1, 7,
};
ModemCapabilitiesEncoding mcs = new ModemCapabilitiesEncoding(buffer);
Assert.IsTrue(mcs.ConcatenationSupport);
Assert.AreEqual(new Version(1, 0), mcs.DocsisVersion);
Assert.IsTrue(mcs.FragmentationSupport);
Assert.IsTrue(mcs.PayloadHeaderSuppressionSupport);
Assert.AreEqual(ModemCapabilitiesEncoding.PrivacySupportValue.BpiPlusSupport,mcs.PrivacySupport.Value);
Assert.AreEqual(1, mcs.DownstreamSaidSupport.Value);
Assert.AreEqual(1, mcs.UpstreamServiceFlowSupport.Value);
Assert.AreEqual(1, mcs.TransmitPreEqualizerTapsPerModulationInterval.Value);
Assert.AreEqual(1, mcs.NumberOfTransmitEqualizerTaps.Value);
Assert.IsTrue(mcs.DccSupport);
Assert.IsNotNull(mcs.RangingHoldOffSupport);
Assert.IsTrue(mcs.L2VPN);
Assert.IsNotNull(mcs.ESafeHostCapability);
Assert.IsTrue(mcs.DownstreamUnencryptedTrafficFiltering);
Assert.AreEqual(ModemCapabilitiesEncoding.UpstreamFrequencyRangeSupportEnum.Extended, mcs.UpstreamFrequencyRangeSupport);
Assert.IsTrue(mcs._160kspsSymbolRateSupport);
Assert.IsTrue(mcs._320kspsSymbolRateSupport);
Assert.IsTrue(mcs._640kspsSymbolRateSupport);
Assert.IsTrue(mcs._1280kspsSymbolRateSupport);
Assert.IsTrue(mcs._2560kspsSymbolRateSupport);
Assert.IsTrue(mcs._5120kspsSymbolRateSupport);
Assert.IsTrue(mcs.SelectableActiveCodeMode2Support);
Assert.IsTrue(mcs.CodeHoppingMode2Support);
Assert.AreEqual(2,mcs.ScQamMultipleTransmitChannelSupport.Value);
Assert.AreEqual(2, mcs.TotalSidClusterSupport.Value);
Assert.AreEqual(2, mcs.SidClustersPerServiceFlowSupport.Value);
Assert.AreEqual(2, mcs.ScQamMultipleReceiveChannelSupport.Value);
Assert.AreEqual(3, mcs.TotalDsidSupport.Value);
Assert.AreEqual(3, mcs.ResequencingDsidSupport.Value);
Assert.AreEqual(3, mcs.MulticastDsidSupport.Value);
Assert.AreEqual(ModemCapabilitiesEncoding.MulticastDsidForwardingEnum.SupportPromiscious, mcs.MulticastDsidForwarding.Value);
Assert.IsTrue(mcs.FrameControlTypeForwardingCapability);
Assert.IsTrue(mcs.DpvPerPathSuppported);
Assert.IsTrue(mcs.DpvPerPacketSuppported);
Assert.AreEqual(3, mcs.UnsolicitedGrantServiceFlowSupport.Value);
Assert.IsTrue(mcs.MapAndUcdReceiptSupport);
Assert.AreEqual(3, mcs.UpstreamDropClassifierSupport);
Assert.IsTrue(mcs.Ipv6Support.Value);
Assert.AreEqual(4, mcs.ExtendedUpstreamTransmitPowerCapability.Value);
Assert.IsTrue(mcs.CmStatusAck);
Assert.IsTrue(mcs.EnergyManagement1x1Feature);
Assert.IsTrue(mcs.DocsisLightSleepMode);
Assert.AreEqual(4, mcs.ExtendedPacketLengthSupportCapability);
Assert.AreEqual(4, mcs.OfdmMultipleReceiveChannelSupport.Value);
Assert.AreEqual(5, mcs.OfdmaMultipleTransmitChannelSupport.Value);
Assert.AreEqual(5, mcs.DownstreamOfdmProfileSupport.Value);
Assert.IsNotNull(mcs.DownstreamOfdmChannelSubcarrierQamModulationSupport);
Assert.IsNotNull(mcs.UpstreamOfdmaChannelSubcarrierQamModulationSupport);
Assert.AreEqual(108, mcs.DownstreamFrequencyRangeStarting);
Assert.AreEqual(1218, mcs.DownstreamFrequencyRangeUpTo);
Assert.AreEqual(42, mcs.UpstreamFrequencyRangeUpTo);
Assert.AreEqual(ModemCapabilitiesEncoding.DtpMode.MasterOrSlave, mcs.DocsisTimeProtocolMode.Value);
Assert.AreEqual(ModemCapabilitiesEncoding.DtpPerformanceSupport.Level5, mcs.DocsisTimeProtocolPerformanceSupport.Value);
Assert.AreEqual(5, mcs.Pmax);
Assert.IsTrue(mcs.DownstreamFullDuplex);
Assert.AreEqual(7, mcs.LowLatencySupport.Value);
buffer = new byte[]
{
2, 1, 1,
54, 1, 2,
55, 1, 2,
56, 1, 1,
};
mcs = new ModemCapabilitiesEncoding(buffer);
Assert.IsTrue(mcs._160kspsSymbolRateSupport);
Assert.IsTrue(mcs._320kspsSymbolRateSupport);
Assert.IsTrue(mcs._640kspsSymbolRateSupport);
Assert.IsTrue(mcs._1280kspsSymbolRateSupport);
Assert.IsTrue(mcs._2560kspsSymbolRateSupport);
Assert.IsTrue(mcs._5120kspsSymbolRateSupport);
buffer = new byte[]
{
2, 1, 2,
55, 1, 4,
56, 1, 2,
60, 1, 1,
};
mcs = new ModemCapabilitiesEncoding(buffer);
buffer = new byte[]
{
2, 1, 3,
56, 1, 3,
60, 1, 2,
61, 1, 1
};
mcs = new ModemCapabilitiesEncoding(buffer);
buffer = new byte[]
{
2, 1, 4,
56, 1, 4,
61, 1, 2
};
mcs = new ModemCapabilitiesEncoding(buffer);
Assert.IsNull(mcs.DpvPerPathSuppported);
Assert.IsNull(mcs.DpvPerPacketSuppported);
Assert.IsNull(mcs.EnergyManagement1x1Feature);
Assert.IsNull(mcs.DocsisLightSleepMode);
buffer = new byte[]
{
2, 1, 5,
61, 1, 4,
62, 1, 0
};
mcs = new ModemCapabilitiesEncoding(buffer);
buffer = new byte[]
{
2, 1, 6,
62, 1, 1
};
mcs = new ModemCapabilitiesEncoding(buffer);
buffer = new byte[]
{
62, 1, 2
};
mcs = new ModemCapabilitiesEncoding(buffer);
buffer = new byte[]
{
62, 1, 3
};
mcs = new ModemCapabilitiesEncoding(buffer);
buffer = new byte[]
{
62, 1, 4
};
mcs = new ModemCapabilitiesEncoding(buffer);
buffer = new byte[]
{
255, 1, 1
};
Assert.Throws<NotImplementedException>(() => new ModemCapabilitiesEncoding(buffer));
}
[TestMethod]
public void GeneralServiceFlowEncodingTest()
{
byte[] buffer = new byte[]
{
1, 2, 0, 1,
2, 2, 0, 1,
6, 1, 255,
7, 1, 1,
8, 4, 0, 0, 0, 1,
9, 4, 0, 0, 0, 1,
10, 4, 0, 0, 0, 1,
11, 2, 0, 1,
12, 2, 0, 1,
14, 2, 0, 1,
15, 1, 7,
17, 1, 1,
19, 2, 0, 1,
20, 4, 0, 0, 0, 2,
21, 4, 0, 0, 0, 2,
22, 1, 2,
23, 1, 2,
24, 4, 0, 0, 0, 2,
26, 1, 2,
32, 4, 0, 0, 0, 3,
16, 4, 0, 0, 255, 255,
};
GeneralServiceFlowEncoding gsfe = new GeneralServiceFlowEncoding(buffer);
Assert.AreEqual((ushort)1, gsfe.ServiceFlowReference);
Assert.AreEqual((ushort)1, gsfe.ServiceFlowIdentifier);
Assert.IsTrue(gsfe.ProvisionedSet);
Assert.IsTrue(gsfe.AdmittedSet);
Assert.IsTrue(gsfe.ActiveSet);
Assert.AreEqual((byte)1, gsfe.TrafficPriority);
Assert.AreEqual((uint)1, gsfe.UpstreamMaximumSustainedTrafficRate);
Assert.AreEqual((uint)1, gsfe.MaximumTrafficBurst);
Assert.AreEqual((uint)1, gsfe.MinimumReservedTrafficRate);
Assert.AreEqual((ushort)1, gsfe.AssumedMinimumReservedRatePacketSize);
Assert.AreEqual((ushort)1, gsfe.TimeoutForActiveQosParameters);
Assert.AreEqual(1, gsfe.MaximumConcatenatedBurst);
Assert.AreEqual(GeneralServiceFlowEncoding.ServiceFlowSchedulingTypeEnum.ProactiveGrantService, gsfe.ServiceFlowSchedulingType);
Assert.AreEqual(1, gsfe.DownstreamResequencing.Value);
Assert.AreEqual(1, gsfe.UnsolicitedGrantSize.Value);
Assert.AreEqual((uint)2, gsfe.NominalGrantInterval.Value);
Assert.AreEqual((uint)2, gsfe.ToleratedGrantJitter.Value);
Assert.AreEqual(2, gsfe.GrantsPerInterval.Value);
Assert.IsNotNull(gsfe.IpTypeOfServiceOverwrite);
Assert.AreEqual((uint)2, gsfe.CmtsTimestamp.Value);
Assert.AreEqual(2, gsfe.MultiplierToNumberOfBytesRequested);
Assert.AreEqual((uint)3, gsfe.ServiceFlowForbiddenAttributeMask);
Assert.IsTrue(gsfe.DoNotUseContentionRegions);
Assert.IsTrue(gsfe.DoNotUseSegmentHeaders);
Assert.IsTrue(gsfe.DropPacketsTooBigForUnsolicitedGrant);
Assert.IsTrue(gsfe.DoNotSupressPayloadHeaders);
Assert.IsTrue(gsfe.DoNotFragmentData);
Assert.IsTrue(gsfe.DoNotConcatenateData);
Assert.IsTrue(gsfe.DoNotPiggybackRequests);
Assert.IsTrue(gsfe.DoNotUseRequest2ForData);
Assert.IsTrue(gsfe.DoNotUseRequest2ForRequests);
Assert.IsTrue(gsfe.DoNotUsePriorityRequest);
Assert.IsTrue(gsfe.DoNotUseAllCms);
this.Print(gsfe.ToString());
buffer = new byte[]
{
17, 4, 0, 0, 0, 1
};
gsfe = new GeneralServiceFlowEncoding(buffer);
Assert.AreEqual((uint)1, gsfe.NominalPollingInterval.Value);
buffer = new byte[]
{
254, 1, 1
};
Assert.Throws<NotImplementedException>(() => new GeneralServiceFlowEncoding(buffer));
}
[MacManagementMessageType(0x90,0x01)]
class TestableMacManagementMessage : MacManagementMessage
{
public TestableMacManagementMessage(PhysicalAddress source, PhysicalAddress destination, byte[] buffer) : base(source, destination, buffer)
{
}
}
class UntestableMacManagementMessage : MacManagementMessage
{
public UntestableMacManagementMessage(PhysicalAddress source, PhysicalAddress destination, byte[] buffer) : base(source, destination, buffer)
{
}
}
[TestMethod]
public void MacManagementMessageTest()
{
Random rng = new Random();
byte[] srcBuffer = new byte[6];
byte[] dstBuffer = new byte[6];
PhysicalAddress srcAddr = new PhysicalAddress(srcBuffer);
PhysicalAddress dstAddr = new PhysicalAddress(dstBuffer);
byte[] dataBuffer = new byte[0];
MacManagementMessageTypeAttribute expected = new MacManagementMessageTypeAttribute(0x90, 0x01);
TestableMacManagementMessage tmmm = new TestableMacManagementMessage(srcAddr, dstAddr, dataBuffer);
Assert.AreEqual(expected, tmmm.MessageType);
Assert.AreEqual(srcAddr, tmmm.Source);
Assert.AreEqual(dstAddr, tmmm.Destination);
Assert.Throws<ArgumentNullException>(() => new TestableMacManagementMessage(srcAddr, dstAddr, null));
UntestableMacManagementMessage ummm = new UntestableMacManagementMessage(srcAddr, dstAddr, dataBuffer);
Assert.IsNull(ummm.MessageType);
}
}