diff --git a/skyscraper8.Tests/AllureConfig.json b/skyscraper8.Tests/AllureConfig.json new file mode 100644 index 0000000..e2e4820 --- /dev/null +++ b/skyscraper8.Tests/AllureConfig.json @@ -0,0 +1,5 @@ +{ + "allure": { + "directory": "allure-results" + } +} diff --git a/skyscraper8.Tests/AllureLog.cs b/skyscraper8.Tests/AllureLog.cs deleted file mode 100644 index b7eb358..0000000 --- a/skyscraper8.Tests/AllureLog.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Allure.Commons; -using Allure.Xunit.Attributes.Steps; - -namespace skyscraper8.Tests; - -public class AllureLog -{ - [AllureStep("{0}")] - public static void Log(string msg) - { - - } -} diff --git a/skyscraper8.Tests/AssemblySettings.cs b/skyscraper8.Tests/AssemblySettings.cs deleted file mode 100644 index 7f777c3..0000000 --- a/skyscraper8.Tests/AssemblySettings.cs +++ /dev/null @@ -1 +0,0 @@ -[assembly: CollectionBehavior(DisableTestParallelization = true)] \ No newline at end of file diff --git a/skyscraper8.Tests/ClassDependencies/DocsisTests/DocsisEventHandlerImpl.cs b/skyscraper8.Tests/ClassDependencies/DocsisTests/DocsisEventHandlerImpl.cs deleted file mode 100644 index d517961..0000000 --- a/skyscraper8.Tests/ClassDependencies/DocsisTests/DocsisEventHandlerImpl.cs +++ /dev/null @@ -1,40 +0,0 @@ -using skyscraper5.Docsis; -using skyscraper5.Docsis.MacManagement; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net; -using System.Net.NetworkInformation; -using System.Text; -using System.Threading.Tasks; - -namespace skyscraper8.Tests.ClassDependencies.DocsisTests -{ - internal class DocsisEventHandlerImpl : IDocsisEventHandler - { - public void OnCmtsTimestamp(PhysicalAddress source, uint timing) - { - throw new NotImplementedException(); - } - - public void OnDownstreamChannel(PhysicalAddress physicalAddress, MacDomainDescriptor.DownstreamActiveChannel downstreamActiveChannel) - { - throw new NotImplementedException(); - } - - public void OnLearnedIpFromMac(PhysicalAddress arpHeaderSenderHardwareAddress, IPAddress arpHeaderSenderProtocolAddress) - { - throw new NotImplementedException(); - } - - public void OnParticipantDetected(PhysicalAddress pa) - { - throw new NotImplementedException(); - } - - public void OnUpstreamChannel(UpstreamChannelDescriptor mmm) - { - throw new NotImplementedException(); - } - } -} diff --git a/skyscraper8.Tests/DocsisTests.cs b/skyscraper8.Tests/DocsisTests.cs deleted file mode 100644 index 6532ea9..0000000 --- a/skyscraper8.Tests/DocsisTests.cs +++ /dev/null @@ -1,118 +0,0 @@ -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 Xunit.Sdk; - -namespace skyscraper8.Tests -{ - public class DocsisTests - { - [Fact] - public void ModemCapabilitiesEncoding() - { - byte[] buffer = Resources.ModemCapabilitiesEncodingTest; - ModemCapabilitiesEncoding modemCapabilitiesEncoding = new ModemCapabilitiesEncoding(buffer); - Assert.True(modemCapabilitiesEncoding.Valid); - } - - [Fact] - 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] - 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] - 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] - public void TransmitChannelConfigurationObjectTest() - { - byte[] testPayload = Resources.TransmitChannelConfigurationObject; - - CommonTlvEncodingObject.TransmitChannelConfigurationObject child = new CommonTlvEncodingObject.TransmitChannelConfigurationObject(testPayload); - Assert.True(child.Valid); - } - - [Fact] - 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); - } - } -} diff --git a/skyscraper8.Tests/Feyllure.cs b/skyscraper8.Tests/Feyllure.cs new file mode 100644 index 0000000..8a030e1 --- /dev/null +++ b/skyscraper8.Tests/Feyllure.cs @@ -0,0 +1,122 @@ +using System.Runtime.InteropServices; +using Allure.Net.Commons; +using TestResult = Allure.Net.Commons.TestResult; + +namespace skyscraper8.Tests; + +[TestClass] +public class Feyllure +{ + public TestContext TestContext { get; set; } + + protected static readonly AllureLifecycle Allure = AllureLifecycle.Instance; + + private bool assemblyWasInited; + private void AssemblyInit(TestContext context) + { + // Ensure allure-results exists + var resultsDir = Allure.ResultsDirectory; + Directory.CreateDirectory(resultsDir); + + var envFile = Path.Combine(resultsDir, "environment.properties"); + + using (var writer = new StreamWriter(envFile)) + { + writer.WriteLine($"SkyscraperRelease={VersionInfo.GetPublicReleaseNumber()}"); + writer.WriteLine($"SkyscraperCodeVersion={VersionInfo.GetCurrentAssemblyDisplayVersion()}"); + writer.WriteLine($"OS={RuntimeInformation.OSDescription}"); + writer.WriteLine($".NET={Environment.Version}"); + writer.WriteLine($"Machine={Environment.MachineName}"); + writer.WriteLine($"User={Environment.UserName}"); + writer.WriteLine($"Framework={context.Properties["TargetFramework"] ?? "net8.0"}"); + writer.WriteLine($"BuildDate={DateTime.UtcNow:yyyy-MM-dd HH:mm:ss}"); + } + + var executorFile = Path.Combine(resultsDir, "executor.json"); + var executorInfo = new + { + name = Environment.MachineName, + buildName = "My build name", + buildUrl = "http://127.0.0.2", + }; + var executorJson = Newtonsoft.Json.JsonConvert.SerializeObject(executorInfo); + File.WriteAllText(executorFile, executorJson); + } + + [TestInitialize] + public void Setup() + { + if (!assemblyWasInited){ + AssemblyInit(TestContext); + assemblyWasInited = true; + } + var testName = TestContext.TestName; + var fqClass = TestContext.FullyQualifiedTestClassName; + + // Extract namespace and class name + var lastDot = fqClass.LastIndexOf('.'); + var ns = lastDot > 0 ? fqClass.Substring(0, lastDot) : ""; + var cls = lastDot > 0 ? fqClass.Substring(lastDot + 1) : fqClass; + + TestResult testResult = new TestResult(); + testResult.uuid = Guid.NewGuid().ToString(); + testResult.name = testName; + testResult.fullName = String.Format("{0}.{1}", TestContext.FullyQualifiedTestClassName, testName); + testResult.labels = new List