public void TestExecuteShouldPrintInvoiceNumber()
        {
            _command.Execute(InvoiceId);

            _mockPrinter
            .Verify(p => p.WriteLine("Invoice ID: 1"),
                    Times.Once);
        }
 public void Exception_thrown_if_not_admin()
 {
     _mocker.GetMock <ISecurity>()
     .Setup(p => p.IsAdmin())
     .Returns(false);
     Assert.That(() => _command.Execute(_invoiceId),
                 Throws.InstanceOf <UserNotAuthorizedException>());
 }
 public void Execute_gets_invoice()
 {
     _mocker.GetMock <ISecurity>()
     .Setup(p => p.IsAdmin())
     .Returns(true);
     _command.Execute(_invoiceId);
     _mocker.GetMock <IDatabase>()
     .Verify(p => p.GetInvoice(_invoiceId), Times.Once);
 }
        public void TestExecuteShouldPrintLine(string line)
        {
            _command.Execute(InvoiceId);

            _mocker.GetMock <IPrinter>()
            .Verify(p => p.WriteLine(line),
                    Times.Once);
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            var invoiceId = int.Parse(args[0]);

            var command = new PrintInvoiceCommand(
                new Database(),
                new InvoiceWriter(
                    new Printer(),
                    new PageLayout()));

            command.Execute(invoiceId);
        }