feyris-tan 36969eede2
All checks were successful
🚀 Pack skyscraper8 / make-zip (push) Successful in 2m4s
Refactored Tests.
2025-11-17 22:13:31 +01:00

153 lines
4.6 KiB
C#

using skyscraper5;
using skyscraper5.Docsis;
using skyscraper5.Docsis.AnnexC;
using skyscraper5.Docsis.MacManagement;
using skyscraper5.Mpeg2;
using skyscraper5.Skyscraper.Plugins;
using skyscraper5.Skyscraper.Scraper;
using skyscraper5.Skyscraper.Scraper.Storage;
using skyscraper5.Skyscraper.Scraper.Storage.Filesystem;
using skyscraper5.Skyscraper.Scraper.Storage.InMemory;
using skyscraper8.Skyscraper.IO;
using skyscraper8.Tests.ClassDependencies.DocsisTests;
using skyscraper8.Tests.Properties;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net.NetworkInformation;
using System.Text;
using System.Threading.Tasks;
using Allure.Xunit.Attributes;
using Xunit.Sdk;
namespace skyscraper8.Tests.ResourceTests
{
public class DocsisTests
{
[Fact]
[AllureSuite("Resources")]
[AllureFeature("DOCSIS")]
public void ModemCapabilitiesEncoding()
{
byte[] buffer = Resources.ModemCapabilitiesEncodingTest;
ModemCapabilitiesEncoding modemCapabilitiesEncoding = new ModemCapabilitiesEncoding(buffer);
Assert.True(modemCapabilitiesEncoding.Valid);
}
[Fact]
[AllureSuite("Resources")]
[AllureFeature("DOCSIS")]
public void MultipartRegistrationResponse()
{
Random rng = new Random();
byte[] sourceBuffer = new byte[6];
rng.NextBytes(sourceBuffer);
PhysicalAddress source = new PhysicalAddress(sourceBuffer);
byte[] targetBuffer = new byte[6];
rng.NextBytes(targetBuffer);
PhysicalAddress target = new PhysicalAddress(targetBuffer);
byte[] buffer = Properties.Resources.MultipartRegistrationResponseTest;
T45_V4_MultipartRegistrationResponse test = new T45_V4_MultipartRegistrationResponse(source, target, buffer);
Assert.True(test.Valid);
}
[Fact]
[AllureSuite("Resources")]
[AllureFeature("DOCSIS")]
public void MacManagement_4_45()
{
DocsisEventHandlerImpl docsisEventHandler = new DocsisEventHandlerImpl();
DocsisEnvironment environment = new DocsisEnvironment(docsisEventHandler);
byte[] testPayload = Resources.PushMacManagementMessage_Version4_Type45;
Random rng = new Random();
byte[] sourceBuffer = new byte[6];
rng.NextBytes(sourceBuffer);
PhysicalAddress source = new PhysicalAddress(sourceBuffer);
byte[] targetBuffer = new byte[6];
rng.NextBytes(targetBuffer);
PhysicalAddress target = new PhysicalAddress(targetBuffer);
environment.PushMacManagementMessage(testPayload, 4, 45, source, target, testPayload);
}
[Fact]
[AllureSuite("Resources")]
[AllureFeature("DOCSIS")]
public void InvalidUpstreamChannelDescriptorTest()
{
byte[] testPayload = Resources.UpstreamChannelDescriptorTest;
Random rng = new Random();
byte[] sourceBuffer = new byte[6];
rng.NextBytes(sourceBuffer);
PhysicalAddress source = new PhysicalAddress(sourceBuffer);
byte[] targetBuffer = new byte[6];
rng.NextBytes(targetBuffer);
PhysicalAddress target = new PhysicalAddress(targetBuffer);
UpstreamChannelDescriptor ucd = new UpstreamChannelDescriptor(source, target, testPayload);
Assert.False(ucd.Valid);
}
[Fact]
[AllureSuite("Resources")]
[AllureFeature("DOCSIS")]
public void TransmitChannelConfigurationObjectTest()
{
byte[] testPayload = Resources.TransmitChannelConfigurationObject;
CommonTlvEncodingObject.TransmitChannelConfigurationObject child = new CommonTlvEncodingObject.TransmitChannelConfigurationObject(testPayload);
Assert.True(child.Valid);
}
[Fact]
[AllureSuite("Resources")]
[AllureFeature("DOCSIS")]
public void MultipartRegistrationResponse2()
{
Random rng = new Random();
byte[] sourceBuffer = new byte[6];
rng.NextBytes(sourceBuffer);
PhysicalAddress source = new PhysicalAddress(sourceBuffer);
byte[] targetBuffer = new byte[6];
rng.NextBytes(targetBuffer);
PhysicalAddress target = new PhysicalAddress(targetBuffer);
byte[] buffer = Properties.Resources.MultipartRegistrationResponseTest2;
T45_V4_MultipartRegistrationResponse test = new T45_V4_MultipartRegistrationResponse(source, target, buffer);
Assert.True(test.Valid);
}
[Fact]
[AllureSuite("Resources")]
[AllureFeature("DOCSIS")]
public void OffsetBreakerTest()
{
byte[] blob = Resources.ranging_response_test;
Random rng = new Random();
byte[] sourceMacBuffer = new byte[6];
rng.NextBytes(sourceMacBuffer);
PhysicalAddress sourceAddress = new PhysicalAddress(sourceMacBuffer);
byte[] targetMacBuffer = new byte[6];
rng.NextBytes(targetMacBuffer);
PhysicalAddress targetAddress = new PhysicalAddress(targetMacBuffer);
RangingResponse rangingResponse = new RangingResponse(sourceAddress, targetAddress, blob);
Assert.True(rangingResponse.Valid);
}
}
}