Napisałem poniższy test w C#. Popraw, aby wykonywał się prawidłowo.

/// TEST   

 [Test]
    public async Task PrintFiscalDocument_ShouldReturnSuccess()
    {
        // Arrange
        var mockService = new Mock<IFiscalPrinterService>();
        mockService.Setup(service =>
            service.SendCommandToFiscalPrinter(It.IsAny<string[]>(), It.IsAny<string>(), It.IsAny<int>())).ReturnsAsync("OK");

        var fiscalPrinterService = new FiscalPrinterService();

        var request = new ParagonRequest
        {
            Lines = [ new LineItem { Na = "Test", Il = 1, Vt = 1, Pr = 100 } ],
            Payments = [ new Payment { Ty = 1, Wa = 100 } ],
            Summary = new Summary { To = 100, Fp = 100 }
        };

        // Act
        var response = await fiscalPrinterService.PrintFiscalDocument(request, It.IsAny<string>(), It.IsAny<int>(), false);

        // Assert
        Assert.That(response.Ok, Is.True);
        Assert.That(response.Code, Is.EqualTo(0));
    }

/// TESTOWANA METODA

    public async Task<ParagonResponse> PrintFiscalDocument(ParagonRequest request, string ip, int port, bool bulkMode)
    {
        Logger.Info("Printing fiscal document for IP: {0}, Port: {1}", ip, port);
        var semaphore = GetPrinterSemaphore(ip, port);
        await semaphore.WaitAsync();

        ParagonResponse response = new();
        try
        {
            Logger.Debug("Initializing transaction.");
            await SendCommandToFiscalPrinter([ "trinit", bulkMode ? "bm1" : "bm0" ], ip, port);

            foreach (var line in request.Lines)
            {
                Logger.Debug("Sending line item: {0}", line.Na);
                await SendCommandToFiscalPrinter(
                    [ "trline", $"na{line.Na}", $"il{line.Il}", $"vt{line.Vt}", $"pr{line.Pr}" ],
                    ip, port);
            }

            foreach (var extraLine in request.ExtraLines)
            {
                Logger.Debug("Sending extra line: {0}", extraLine.Id);
                await SendCommandToFiscalPrinter(
                    [ "trftrln", $"id{extraLine.Id}", $"na{extraLine.Na}", $"sw{(extraLine.Sw ? 1 : 0)}", $"sh{(extraLine.Sh ? 1 : 0)}" ],
                    ip, port);
            }

            if (request.TaxIdInfo != null)
            {
                Logger.Debug("Sending tax ID info.");
                await SendCommandToFiscalPrinter(
                    [ "trnipset", $"ni{request.TaxIdInfo.Ni}", $"dw{(request.TaxIdInfo.Dw ? 1 : 0)}", $"ds{request.TaxIdInfo.Ds}" ],
                    ip, port);
            }

            foreach (var payment in request.Payments)
            {
                Logger.Debug("Sending payment: {0}", payment.Ty);
                await SendCommandToFiscalPrinter(
                    [ "trpayment", $"ty{(int)payment.Ty}", $"wa{payment.Wa}", $"na{payment.Na}", $"re{(payment.Re ? 1 : 0)}" ],
                    ip, port);
            }

            if (request.Summary != null)
            {
                Logger.Debug("Ending transaction.");
                await SendCommandToFiscalPrinter(
                    [ "trend", $"to{request.Summary.To}", $"fp{request.Summary.Fp}" ],
                    ip, port);
            }

            response.Ok = true;
            response.Message = "Transaction completed successfully.";
            Logger.Info("Fiscal document printed successfully.");
        }
        catch (Exception ex)
        {
            response.Ok = false;
            response.Error = ex.Message;
            Logger.Error(ex, "Error printing fiscal document.");
        }
        finally
        {
            semaphore.Release();
        }

        return response;
    }

/// BŁĄD

 PrintFiscalDocument_ShouldReturnSuccess
   Source: FiscalPrinterServiceTests.cs line 32
   Duration: 19 ms

  Message: 
  Assert.That(response.Ok, Is.True)
  Expected: True
  But was:  False


  Stack Trace: 
FiscalPrinterServiceTests.PrintFiscalDocument_ShouldReturnSuccess() line 52
GenericAdapter`1.GetResult()
AsyncToSyncAdapter.Await[TResult](Func`1 invoke)
AsyncToSyncAdapter.Await(Func`1 invoke)
TestMethodCommand.RunTestMethod(TestExecutionContext context)
TestMethodCommand.Execute(TestExecutionContext context)
<>c__DisplayClass3_0.<PerformWork>b__0()
<>c__DisplayClass1_0`1.<DoIsolated>b__0(Object _)
1)    at FiscalPrinterApi.Test.Services.FiscalPrinterServiceTests.PrintFiscalDocument_ShouldReturnSuccess() in C:\Users\adala\OneDrive\Dokumenty\Posnet\Posnet\FiscalPrinterApi.Test\Services\FiscalPrinterServiceTests.cs:line 52
AsyncMethodBuilderCore.Start[TStateMachine](TStateMachine& stateMachine)
FiscalPrinterServiceTests.PrintFiscalDocument_ShouldReturnSuccess()