示例#1
0
        public void ZebraZC3_CheckPrinterStatus_AlarmInfoAndErrorInfoHaveDifferentErrorsReturnFalse()
        {
            using (ShimsContext.Create())
            {
                var errorDesc7008 = Substitute.For <IDeviceErrorDescriptor>();
                errorDesc7008.Code.Returns(7008);
                errorDesc7008.Description.Returns("Printer door open");
                errorDesc7008.HelpfulHint.Returns("Ensure the door is closed.");

                var errorDesc7028 = Substitute.For <IDeviceErrorDescriptor>();
                errorDesc7028.Code.Returns(7028);
                errorDesc7028.Description.Returns("Printer thingo is open");
                errorDesc7028.HelpfulHint.Returns("Ensure the thingo is closed.");

                var errorFactory = Substitute.For <Error.IZebraErrorFactory>();
                errorFactory.GetErrorDescription(7008).Returns(errorDesc7008);
                errorFactory.GetErrorDescription(7028).Returns(errorDesc7028);

                // Arrange
                var alarm7008 = new ZebraSdk.Card.Containers.Fakes.ShimAlarmInfo
                {
                    ValueGet = () => { return(7008); }
                };
                var alarm7028 = new ZebraSdk.Card.Containers.Fakes.ShimAlarmInfo
                {
                    ValueGet = () => { return(7028); }
                };


                var printerStatus = new ZebraSdk.Card.Containers.Fakes.ShimPrinterStatusInfo
                {
                    AlarmInfoGet = () => { return(alarm7008); },
                    ErrorInfoGet = () => { return(alarm7028); }
                };

                var conn         = Substitute.For <ZebraSdk.Comm.Connection>();
                var zebraPrinter = Substitute.For <ZebraSdk.Card.Printer.ZebraCardPrinter>();
                zebraPrinter.GetPrinterStatus().Returns(printerStatus);

                ZebraZC3 zebraZC3 = new ZebraZC3(conn, zebraPrinter, errorFactory);

                // Act
                string status;
                List <IDeviceErrorDescriptor> errorList;
                var boolStatus = zebraZC3.CheckPrinterStatus(out status, out errorList);

                // Assert
                zebraPrinter.Received(1).GetPrinterStatus();
                errorFactory.Received(1).GetErrorDescription(7008);
                errorFactory.Received(1).GetErrorDescription(7028);
                boolStatus.Should().BeFalse(because: "Both ErrorInfo and AlarmInfo have issues. Should trigger false on either having an issue or both having an issue.");
                errorList.Should().HaveCount(2, because: "Two different errors received from alarm and errorinfo.");
                errorList[0].Should().BeEquivalentTo(errorDesc7008);
                errorList[1].Should().BeEquivalentTo(errorDesc7028);
            }
        }
示例#2
0
        public void ZebraZC3_CheckPrinterStatus_ErrorInfoHasErrorReturnFalse()
        {
            using (ShimsContext.Create())
            {
                // Arrange
                var errorDesc = Substitute.For <IDeviceErrorDescriptor>();
                errorDesc.Code.Returns(7028);
                errorDesc.Description.Returns("Printer thingo is open");
                errorDesc.HelpfulHint.Returns("Ensure the thingo is closed.");

                var errorFactory = Substitute.For <Error.IZebraErrorFactory>();
                errorFactory.GetErrorDescription(7028).Returns(errorDesc);

                var alarmGood = new ZebraSdk.Card.Containers.Fakes.ShimAlarmInfo
                {
                    ValueGet = () => { return(0); }
                };

                var alarmBad = new ZebraSdk.Card.Containers.Fakes.ShimAlarmInfo
                {
                    ValueGet = () => { return(7028); }
                };

                var printerStatus = new ZebraSdk.Card.Containers.Fakes.ShimPrinterStatusInfo
                {
                    AlarmInfoGet = () => { return(alarmGood); },
                    ErrorInfoGet = () => { return(alarmBad); }
                };

                var conn         = Substitute.For <ZebraSdk.Comm.Connection>();
                var zebraPrinter = Substitute.For <ZebraSdk.Card.Printer.ZebraCardPrinter>();
                zebraPrinter.GetPrinterStatus().Returns(printerStatus);

                ZebraZC3 zebraZC3 = new ZebraZC3(conn, zebraPrinter, errorFactory);

                // Act
                string status;
                List <IDeviceErrorDescriptor> errorList;
                var boolStatus = zebraZC3.CheckPrinterStatus(out status, out errorList);

                // Assert
                zebraPrinter.Received(1).GetPrinterStatus();
                errorFactory.Received(1).GetErrorDescription(7028);
                boolStatus.Should().BeFalse(because: "ErrorInfo is returning a problem even though AlarmInfo doesn't. Should trigger false on either having an issue or both having an issue.");
                errorList.Should().HaveCount(1, because: "Only one item should be in the error list.");
                errorList[0].Should().BeEquivalentTo(errorDesc);
            }
        }
示例#3
0
        public void ZebraZC3_CheckPrinterStatus_StatusOkayReturnTrue()
        {
            using (ShimsContext.Create())
            {
                // Arrange
                var errorDesc = Substitute.For <IDeviceErrorDescriptor>();
                errorDesc.Code.Returns(0);
                errorDesc.Description.Returns("The description");
                errorDesc.HelpfulHint.Returns("A helpful hint for the problem");

                var errorFactory = Substitute.For <Error.IZebraErrorFactory>();
                errorFactory.GetErrorDescription(0).Returns(errorDesc);

                var alarm = new ZebraSdk.Card.Containers.Fakes.ShimAlarmInfo
                {
                    ValueGet = () => { return(0); }
                };

                var printerStatus = new ZebraSdk.Card.Containers.Fakes.ShimPrinterStatusInfo
                {
                    AlarmInfoGet = () => { return(alarm); },
                    ErrorInfoGet = () => { return(alarm); }
                };

                var conn         = Substitute.For <ZebraSdk.Comm.Connection>();
                var zebraPrinter = Substitute.For <ZebraSdk.Card.Printer.ZebraCardPrinter>();
                zebraPrinter.GetPrinterStatus().Returns(printerStatus);

                ZebraZC3 zebraZC3 = new ZebraZC3(conn, zebraPrinter, errorFactory);

                // Act
                string status;
                List <IDeviceErrorDescriptor> errorList;
                var boolStatus = zebraZC3.CheckPrinterStatus(out status, out errorList);

                // Assert
                zebraPrinter.Received(1).GetPrinterStatus();
                errorFactory.Received(1).GetErrorDescription(0);
                boolStatus.Should().BeTrue(because: "All status checks have passed successfully");
                errorList.Should().HaveCount(1, because: "Only one item should be in the error list.");
                errorList[0].Should().BeEquivalentTo(errorDesc);
            }
        }