public void When_Pass_Command_With_Right_Parameters_Shoudl_Return_Correct_Printout()
        {
            //Arrange
            var crChar           = (char)ThermalFiscalPrinterSimulatorLibraries.Constants.ASCICodeCR;
            var cashierLogin     = "******";
            var printerCode      = "993A";
            var passedParameters = $"{cashierLogin}{crChar}{printerCode}{crChar}";
            var state            = new FiscalPrinterState()
            {
                TimeDiffrenceInMinutes = 0,
                FiscalPrinterHeader    = "HEADER TEST".PadCenter(ThermalFiscalPrinterSimulatorLibraries.Constants.ReciptWidth)
            };
            var command = new ThermalFiscalPrinterCommand(null, "#p", passedParameters, string.Empty, string.Empty);
            var handler = new CashierLoginCommandHandler(command);
            //Act

            var result       = handler.Handle(state);
            var dateToString = DateTime.Now.ToString("yyyy-MM-dd");
            var timeToString = DateTime.Now.ToString("HH-mm-ss");
            //Assert
            StringBuilder expectedPrintout = new StringBuilder();

            expectedPrintout.AppendLine("              HEADER TEST               ");
            expectedPrintout.AppendLine($"{dateToString}                             1");
            expectedPrintout.AppendLine("         N I E F I S K A L N Y          ");
            expectedPrintout.AppendLine("Rozpoczęcie pracy kasjera");
            expectedPrintout.AppendLine($"Kasjer                            {cashierLogin}");
            expectedPrintout.AppendLine($"Numer kasy                          {printerCode}");
            expectedPrintout.AppendLine();
            expectedPrintout.AppendLine("         N I E F I S K A L N Y          ");
            expectedPrintout.AppendLine($"    #{printerCode}     {cashierLogin}            {timeToString}");
            expectedPrintout.AppendLine("                12345678                ");
            expectedPrintout.AppendLine();
            Assert.AreEqual(expectedPrintout.ToString(), result.OutputReciptBuffer);
        }
        public void When_RTC_Clock_Not_Initialize_Should_Throw_Error()
        {
            //Arrange
            var state   = new FiscalPrinterState();
            var command = new ThermalFiscalPrinterCommand(null, "#p", null, string.Empty, string.Empty);
            var handler = new CashierLoginCommandHandler(command);

            //Act
            //Assert
            Assert.Throws <FP_IllegalOperationException>(() =>
            {
                handler.Handle(state);
            });
        }
        public void When_Pass_Command_Without_Parameters_Should_Throw_Error()
        {
            //Arrange
            var state = new FiscalPrinterState()
            {
                TimeDiffrenceInMinutes = 0
            };
            var command = new ThermalFiscalPrinterCommand(null, "#p", string.Empty, string.Empty, string.Empty);
            var handler = new CashierLoginCommandHandler(command);

            //Act
            //Assert
            Assert.Throws <FP_WrongNumberOfArgumentsException>(() =>
            {
                handler.Handle(state);
            });
        }
        public void When_Is_In_Transaction_State_Should_Throw_Error()
        {
            //Arrange
            var state = new FiscalPrinterState()
            {
                TimeDiffrenceInMinutes = 0, IsInTransactionState = true
            };
            var command = new ThermalFiscalPrinterCommand(null, "#p", null, string.Empty, string.Empty);
            var handler = new CashierLoginCommandHandler(command);

            //Act
            //Assert
            Assert.Throws <FP_IllegalOperationException>(() =>
            {
                handler.Handle(state);
            });
        }
        public void When_Pass_Printer_Code_With_More_Then_8_Characters_Should_Throw_Error()
        {
            //Arrange
            var crChar           = (char)ThermalFiscalPrinterSimulatorLibraries.Constants.ASCICodeCR;
            var cashierLogin     = "******";
            var printerCode      = "as3".PadRight(9);
            var passedParameters = $"{cashierLogin}{crChar}{printerCode}{crChar}";
            var state            = new FiscalPrinterState()
            {
                TimeDiffrenceInMinutes = 0
            };
            var command = new ThermalFiscalPrinterCommand(null, "#p", passedParameters, string.Empty, string.Empty);
            var handler = new CashierLoginCommandHandler(command);

            //Act
            //Assert
            Assert.Throws <FP_BadFormatOfArgumentException>(() =>
            {
                handler.Handle(state);
            });
        }