Exemple #1
0
        public async Task Should_Throw_NotEnoughColorException_When_Not_Enough_Black()
        {
            var printColor = new PrintColorCommand(_content,
                                                   paperLevelIndicator: new EnoughPaperLevelStub(),
                                                   blackLevelIndicator: new EnoughBlackLevelStub(),
                                                   colorLevelIndicator: new NotEnoughColorLevelStub());

            await printColor.Execute();
        }
Exemple #2
0
        public async Task Should_Throw_NoContentToPrintException_When_Content_Is_Empty_Byte_Array()
        {
            var printColor = new PrintColorCommand(
                content: new byte[0],
                paperLevelIndicator: new EnoughPaperLevelStub(),
                blackLevelIndicator: new EnoughBlackLevelStub(),
                colorLevelIndicator: new EnoughColorLevelStub());

            await printColor.Execute();
        }
Exemple #3
0
        public async Task Should_Notify_On_Finish_When_Subscribed_To_Channel_PrinterDotPrintedDotCommandId_Only_When_CommandId_Is_Correct()
        {
            Guid incorrectId = Guid.Empty;
            bool areEqual    = false;

            var fn = new FakePrinterNotifier();

            var printColor = new PrintColorCommand(_content,
                                                   paperLevelIndicator: new EnoughPaperLevelStub(),
                                                   blackLevelIndicator: new EnoughBlackLevelStub(),
                                                   colorLevelIndicator: new EnoughColorLevelStub(),
                                                   notifier: fn);

            await fn.Subscribe((message) => areEqual = true, PrinterNotificationTypes.Printed);

            await printColor.Execute();

            Assert.IsFalse(areEqual);
        }
Exemple #4
0
        public async Task Should_Notify_On_Finish_When_Subscribed_To_Channel_PrinterDotPrintedDotCommandId()
        {
            bool areEqual = false;

            var fn = new FakePrinterNotifier();

            var printColor = new PrintColorCommand(_content,
                                                   paperLevelIndicator: new EnoughPaperLevelStub(),
                                                   blackLevelIndicator: new EnoughBlackLevelStub(),
                                                   colorLevelIndicator: new EnoughColorLevelStub(),
                                                   notifier: fn);

            await fn.Subscribe((message) => areEqual = message.Equals($"Document {printColor.Id} printed"),
                               PrinterNotificationTypes.Printed,
                               correlationId : printColor.Id);

            await printColor.Execute();

            Assert.IsTrue(areEqual);
        }
Exemple #5
0
        public async Task Should_Execute_PrintBlackCommand_Without_Errors_When_Configured_Correctly_And_All_Level_Indicators_Are_Sufficient()
        {
            bool isSuccess = true;

            var printColor = new PrintColorCommand(_content,
                                                   paperLevelIndicator: new EnoughPaperLevelStub(),
                                                   blackLevelIndicator: new EnoughBlackLevelStub(),
                                                   colorLevelIndicator: new EnoughColorLevelStub());

            try
            {
                await printColor.Execute();
            }
            catch (Exception)
            {
                isSuccess = false;
            }
            finally
            {
                Assert.IsTrue(isSuccess);
            }
        }
Exemple #6
0
 public async Task PrintColor(byte[] content)
 {
     var command = new PrintColorCommand(content, _pli, _bli, _cli, _n);
     await command.Execute();
 }