skyscraper8/skyscraper8.Tests/UselessCodeCoverageTests.cs
feyris-tan fc8053451a
Some checks failed
🚀 Pack skyscraper8 / make-zip (push) Failing after 3m0s
Added some code coverage Tests for Docsis Annex C.
2025-11-07 13:21:38 +01:00

242 lines
8.8 KiB
C#

using skyscraper5.Docsis;
using skyscraper5.Docsis.AnnexC;
using skyscraper5.Mpeg2;
namespace skyscraper8.Tests;
public class UselessCodeCoverageTests
{
[Fact]
void PsiSectionTest()
{
PsiSection section = new PsiSection();
section.Append(new byte[] { 3 });
}
[Fact]
void MacManagementMessageTypeAttributeTest()
{
MacManagementMessageTypeAttribute mmmta = new MacManagementMessageTypeAttribute(1, 2);
Console.WriteLine(mmmta.ToString());
}
[Fact]
void RcpIdEncodingTest()
{
RcpIdEncoding rie = new RcpIdEncoding(new byte[] { 7, 1, 0 });
SimplifiedReceiveChannelAssignmentEncoding simplifiedReceiveChannelAssignmentEncoding = rie.SimplifiedReceiveChannelConfiguration;
Assert.NotNull(simplifiedReceiveChannelAssignmentEncoding);
Assert.Throws<NotImplementedException>(() => new RcpIdEncoding(new byte[] { 255, 1, 0 }));
}
[Fact]
void EthernetLlcPacketClassificationEncodingTest()
{
EthernetLlcPacketClassificationEncoding epce = new EthernetLlcPacketClassificationEncoding(new byte[] { 3, 3, 1, 0, 1 });
ushort epceEProt = epce.EProt;
Assert.Equal(1, epce.EProt);
Assert.Equal(1, epce.Type);
Assert.Throws<NotImplementedException>(() => new EthernetLlcPacketClassificationEncoding(new byte[] { 255, 1, 0 }));
}
[Fact]
void SimplifiedReceiveChannelAssignmentEncodingTest()
{
SimplifiedReceiveChannelAssignmentEncoding srcae =
new SimplifiedReceiveChannelAssignmentEncoding(new byte[] { 1, 1, 0, 2, 1, 0, 3, 1, 0 });
Assert.Equal(0,srcae.DownstreamChannelAssignment[0]);
Assert.Equal(0, srcae.DownstreamProfileAssignment[0]);
Assert.Equal(0, srcae.PrimaryDownstreamChannelAssignment[0]);
Assert.Throws<NotImplementedException>(() => new SimplifiedReceiveChannelAssignmentEncoding(new byte[] { 254,0,1 }));
}
[Fact]
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.Equal(0, tcco.TccReferenceId.Value);
Assert.Equal(CommonTlvEncodingObject.TransmitChannelConfigurationObject.UpstreamChannelActionEnum.NoAction, tcco.UpstreamChannelAction.Value);
Assert.Equal(0, tcco.UpstreamChannelId.Value);
Assert.NotNull(tcco.UpstreamChannelDescriptor);
Assert.Equal(0, tcco.RangingSid.Value);
Assert.Equal(InitalizationTechniqueEnum.BroadcastInitialRanging, tcco.InitializationTechnique.Value);
Assert.Equal(0, tcco.DynamicRangeWindow);
Assert.Equal(0, tcco.P16Hi);
Assert.Equal(0, tcco.ListOfIucs[0]);
Assert.Throws<NotImplementedException>(() =>
new CommonTlvEncodingObject.TransmitChannelConfigurationObject(new byte[] { 254, 1, 0 }));
}
[Fact]
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.NotNull(commonTlv.ModemCapabilitiesEncoding);
Assert.NotNull(commonTlv.ServiceFlowSidClusterAssignment);
Assert.NotNull(commonTlv.RcpId);
Assert.Equal(0, commonTlv.KeySequenceNumber);
Assert.Equal(0, commonTlv.HmacDigest[0]);
Assert.NotNull(commonTlv.AuthorizationHint);
Assert.Equal(new TimeSpan(0, 0, 1), commonTlv.InitializingChannelTimeout);
ms = new MemoryStream(new byte[] { 254, 1, 0 });
Assert.Throws<NotImplementedException>(() => new CommonTlvEncodingObject(ms));
}
[Fact]
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.True(gpce.ClassifierActivationState.Value);
Assert.Equal(0, gpce.RulePriority.Value);
Assert.NotNull(gpce.Ipv4PacketClassification);
Assert.Equal(1, gpce.ServiceFlowReference.Value);
Assert.Equal(0, gpce.ClassifierReference.Value);
Assert.Equal(1, gpce.ClassifierIdentifier.Value);
Assert.Equal((uint)1, gpce.ServiceFlowIdentifier.Value);
Assert.Equal(GeneralPacketClassifierEncoding.DynamicServiceChangeActionEnum.Add, gpce.DynamicServiceChangeAction.Value);
Assert.NotNull(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
}));
}
[Fact]
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.NotNull(ipce.Ipv4SourceAddress);
Assert.NotNull(ipce.Ipv4DestinationAddress);
Assert.Equal(1, ipce.IpProtocol.Value);
Assert.NotNull(ipce.Ipv4SourceMask);
Assert.NotNull(ipce.Ipv4DestinationMask);
Assert.Equal(1, ipce.DestinationPortStart.Value);
Assert.Equal(1, ipce.DestinationPortEnd.Value);
Assert.Equal(1, ipce.SourcePortStart.Value);
Assert.Equal(1, ipce.SourcePortEnd.Value);
Assert.Throws<NotImplementedException>(() =>
new GeneralPacketClassifierEncoding.Ipv4PacketClassificationEncodings(new byte[]
{
255, 1, 0
}));
}
[Fact]
public void ServiceFlowSidClusterAssignmentObjectTest()
{
ServiceFlowSidClusterAssignmentObject sfscao = new ServiceFlowSidClusterAssignmentObject(new byte[]
{
1, 4, 0, 0, 0, 1,
2, 1, 0,
3, 1, 0,
});
Assert.Equal(1u, sfscao.SFID.Value);
Assert.NotNull(sfscao.SidClusterEncoding);
Assert.NotNull(sfscao.SidClusterSwitchoverCriteria);
Assert.Throws<NotImplementedException>(() => new ServiceFlowSidClusterAssignmentObject(new byte[]
{
255, 1, 0
}));
}
[Fact]
public void SidClusterEncodingObjectTest()
{
ServiceFlowSidClusterAssignmentObject.SidClusterEncodingObject sceo =
new ServiceFlowSidClusterAssignmentObject.SidClusterEncodingObject(new byte[]
{
1, 1, 1,
2, 1, 0
});
Assert.Equal(1, sceo.SidClusterId.Value);
Assert.NotNull(sceo.SidToChannelMapping);
Assert.Throws<NotImplementedException>(() => new ServiceFlowSidClusterAssignmentObject.SidClusterEncodingObject(new byte[]
{
255, 1, 0
}));
}
[Fact]
public void SidToChannelMappingObjectTest()
{
ServiceFlowSidClusterAssignmentObject.SidClusterEncodingObject.SidToChannelMappingObject stcmo =
new ServiceFlowSidClusterAssignmentObject.SidClusterEncodingObject.SidToChannelMappingObject(new byte[]
{
1,1,1,
2,2,0,1,
3,1,1
});
Assert.Equal(1, stcmo.UpstreamChannelId.Value);
Assert.Equal(1, stcmo.SID.Value);
Assert.Equal(ServiceFlowSidClusterAssignmentObject.SidClusterEncodingObject.SidToChannelMappingObject.ActionEnum.Add,stcmo.Action.Value);
Assert.Throws<NotImplementedException>(() =>
new ServiceFlowSidClusterAssignmentObject.SidClusterEncodingObject.SidToChannelMappingObject(new byte[]
{
255, 1, 0
}));
}
}