public PrintInvoiceCommandTests() { _invoice = new Invoice() { Id = InvoiceId, Total = Total }; _mockDatabase = new Mock <IDatabase>(); _mockPrinter = new Mock <IPrinter>(); _mockDateTime = new Mock <IDateTimeWrapper>(); _mockDatabase .Setup(p => p.GetInvoice(InvoiceId)) .Returns(_invoice); _mockDateTime .Setup(p => p.GetNow()) .Returns(Date); _command = new PrintInvoiceCommand( _mockDatabase.Object, _mockPrinter.Object, _mockDateTime.Object); }
public PrintInvoiceCommand Create() { var command = new PrintInvoiceCommand( new Database(), new InvoiceWriter( new Printer(), new PageLayout())); return(command); }
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); }
public void Setup() { _invoiceId = 6; _invoice = new Invoice(); _mocker = new AutoMoqer(); _mocker.GetMock <IDatabase>() .Setup(p => p.GetInvoice(_invoiceId)) .Returns(_invoice); _mocker.GetMock <ISecurity>() .Setup(p => p.IsAdmin()) .Returns(true); _mocker.GetMock <IInvoiceWriter>() .Setup(p => p.Print(_invoice)); _command = _mocker.Create <PrintInvoiceCommand>(); }
public PrintInvoiceCommandTestsWithAutoMoqer() { _invoice = new Invoice() { Id = InvoiceId, Total = Total }; _mocker = new AutoMocker(); _mocker.GetMock <IDatabase>() .Setup(p => p.GetInvoice(InvoiceId)) .Returns(_invoice); _mocker.GetMock <IDateTimeWrapper>() .Setup(p => p.GetNow()) .Returns(Date); _command = _mocker.CreateInstance <PrintInvoiceCommand>(); }