public BorrowController(IDisplay display, ICardReader reader, IScanner scanner, IPrinter printer, IBookDAO bookDAO, ILoanDAO loanDAO, IMemberDAO memberDAO) { if(display == null) throw new ArgumentException("Display object was not provided to begin the application"); if (reader == null) throw new ArgumentException("Reader object was not provided to begin the application"); if (scanner == null) throw new ArgumentException("Scanner object was not provided to begin the application"); if (printer == null) throw new ArgumentException("Printer object was not provided to begin the application"); if (bookDAO == null) throw new ArgumentException("BookDAO object was not provided to begin the application"); if (loanDAO == null) throw new ArgumentException("LoanDAO object was not provided to begin the application"); if (memberDAO == null) throw new ArgumentException("MemberDAO object was not provided to begin the application"); _display = display; _reader = reader; _scanner = scanner; _printer = printer; _bookDAO = bookDAO; _loanDAO = loanDAO; _memberDAO = memberDAO; _ui = new BorrowControl(this); _reader.Listener = this; _scanner.Listener = this; _bookList = new List<IBook>(); _loanList = new List<ILoan>(); _state = EBorrowState.CREATED; }
public MainWindow() { _reader = new CardReader(); _scanner = new Scanner(); _printer = new Printer(); _bookDAO = new BookDao(new BookHelper()); _loanDAO = new LoanDao(new LoanHelper()); _memberDAO = new MemberDao(new MemberHelper()); InitializeComponent(); _reader.Show(); _scanner.Show(); _printer.Show(); SetUpTestData(); MainMenuController mainController = new MainMenuController(this, _reader, _scanner, _printer, _bookDAO, _loanDAO, _memberDAO); mainController.initialise(); }
public void Dispose() { _display = null; _reader = null; _scanner = null; _printer = null; _bookDao = null; _loanDao = null; _memberDao = null; }
public BorrowControlTests() { _display = Substitute.For<IDisplay>(); _reader = Substitute.For<ICardReader>(); _scanner = Substitute.For<IScanner>(); _printer = Substitute.For<IPrinter>(); _bookDao = Substitute.For<IBookDAO>(); _loanDao = Substitute.For<ILoanDAO>(); _memberDao = Substitute.For<IMemberDAO>(); }
public Scenario04CompleteScans() { _bookDao = new BookDao(new BookHelper()); _loanDao = new LoanDao(new LoanHelper()); _memberDao = new MemberDao(new MemberHelper()); _display = new MainWindow(); _reader = new CardReader(); _scanner = new Scanner(); _printer = new Printer(); }
public BorrowControlIntegration() { _bookDao = new BookDao(new BookHelper()); _loanDao = new LoanDao(new LoanHelper()); _memberDao = new MemberDao(new MemberHelper()); _display = new MainWindow(); _reader = new CardReader(); _scanner = new Scanner(); _printer = new Printer(); }
public Scenario02SwipeBorrowerCard() { _bookDao = new BookDao(new BookHelper()); _loanDao = new LoanDao(new LoanHelper()); _memberDao = new MemberDao(new MemberHelper()); _display = new MainWindow(); _reader = new CardReader(); _scanner = new Scanner(); _printer = new Printer(); }
public BorrowController(IDisplay display, ICardReader reader, IScanner scanner, IPrinter printer, IBookDAO bookDAO, ILoanDAO loanDAO, IMemberDAO memberDAO) { _display = display; _reader = reader; _scanner = scanner; _printer = printer; _ui = new BorrowControl(this); _state = EBorrowState.CREATED; }
public MainMenuController(IDisplay display, ICardReader reader, IScanner scanner, IPrinter printer, IBookDAO bookDAO, ILoanDAO loanDAO, IMemberDAO memberDAO) { _display = display; _reader = reader; _scanner = scanner; _printer = printer; _bookDAO = bookDAO; _loanDAO = loanDAO; _memberDAO = memberDAO; }
public MainMenuController(IDisplay display, ICardReader reader, IScanner scanner, IPrinter printer, IBookDAO bookDao, ILoanDAO loanDao, IMemberDAO memberDao, ICardReaderEvents cardReaderEvents) { CardReaderEvents = cardReaderEvents; _display = display; _reader = reader; _scanner = scanner; _printer = printer; _bookDao = bookDao; _loanDao = loanDao; _memberDao = memberDao; }
public BorrowController(IDisplay display, ICardReader reader, IScanner scanner, IPrinter printer, IBookDAO bookDAO, ILoanDAO loanDAO, IMemberDAO memberDAO) { if (display == null) { throw new ArgumentException("Display object was not provided to begin the application"); } if (reader == null) { throw new ArgumentException("Reader object was not provided to begin the application"); } if (scanner == null) { throw new ArgumentException("Scanner object was not provided to begin the application"); } if (printer == null) { throw new ArgumentException("Printer object was not provided to begin the application"); } if (bookDAO == null) { throw new ArgumentException("BookDAO object was not provided to begin the application"); } if (loanDAO == null) { throw new ArgumentException("LoanDAO object was not provided to begin the application"); } if (memberDAO == null) { throw new ArgumentException("MemberDAO object was not provided to begin the application"); } _display = display; _reader = reader; _scanner = scanner; _printer = printer; _bookDAO = bookDAO; _loanDAO = loanDAO; _memberDAO = memberDAO; _ui = new BorrowControl(this); _reader.Listener = this; _scanner.Listener = this; _bookList = new List <IBook>(); _loanList = new List <ILoan>(); _state = EBorrowState.CREATED; }
public BorrowBookCTL(IBookDAO bookDAO, IMemberDAO memberDAO, ILoanDAO loanDAO, IBorrowUI ui) { if (bookDAO == null || memberDAO == null || loanDAO == null || ui == null) { throw new ArgumentException(String.Format("BorrowCTL : constructor : parameters cannot be null.")); } this.bookDAO = bookDAO; this.memberDAO = memberDAO; this.loanDAO = loanDAO; this.ui = ui; overdue = atLoanLimit = overFineLimit = false; further_borrowing_allowed = true; existingLoanCount = 0; pendingLoanCount = 0; bookList = new List<IBook>(); }
public MainWindow() { _reader = new CardReader(); _scanner = new Scanner(); _printer = new Printer(); InitializeComponent(); _reader.Show(); _scanner.Show(); _printer.Show(); _bookDAO = new BookDAO(new BookHelper()); _loanDAO = new LoanDAO(new LoanHelper()); _memberDAO = new MemberDAO(new MemberHelper()); SetUpTestData(); MainMenuController mainController = new MainMenuController(this, _reader, _scanner, _printer, _bookDAO, _loanDAO, _memberDAO); mainController.initialise(); }
public MemberBLO(IMemberDAO _MemberDAO) { MemberDAO = _MemberDAO; }
public void ScanningABook_ThatsAlreadyScanned_ResultsInAlreadyScannedError(IEventAggregator eventAggregator , IBookDAO bookDao , [Frozen] IBook book , ILoanDAO loanDao , IMemberDAO memberDao , ScanBookModel scanBookModel , IBorrowingModel borrowingModel , ScanBookViewModel viewModel , List<ILoan> loanList , [Frozen] Member borrower) { // Arrange - Setup a book that has already been scanned. // Mock the events. eventAggregator.GetEvent<BorrowingStateEvent>().Returns(new BorrowingStateEvent()); eventAggregator.GetEvent<ScanningRecievedEvent>().Returns(new ScanningRecievedEvent()); eventAggregator.GetEvent<ScanningEvent>().Returns(new ScanningEvent()); // We are currently in the scanning book state. borrowingModel.BorrowingState.Returns(EBorrowState.SCANNING_BOOKS); // Establish the current user identified on borrowing model, and returned from member dao. borrowingModel.ID = borrower.ID; memberDao.GetMemberByID(borrower.ID).Returns(borrower); // Configure mapping. AutoMapperConfig.RegisterMaps(); // One of the loans in the loan list has a status of pending for the current borrower. var existingLoan = loanList.First(); existingLoan.State.Returns(LoanState.PENDING); existingLoan.Borrower.Returns(borrower); // The loan Dao returns this loan list when requested loanDao.LoanList.Returns(loanList); // The book to be scanned is the same book as already scanned. bookDao.GetBookByID(scanBookModel.Barcode).Returns(existingLoan.Book); // The book is available for loan. existingLoan.Book.State.Returns(BookState.AVAILABLE); var controller = new ScanBookController(eventAggregator) { BookDao = bookDao, LoanDao = loanDao, MemberDao = memberDao, ViewModel = viewModel }; // Prepare Scanner controller.ScanBook(borrowingModel); // Act -Scan a book. controller.Scanning(scanBookModel); // Assert - Already scanned error message appears. viewModel.ErrorMessage.Should().Be($"Book {existingLoan.Book.ID} already scanned "); }
public void ScanningABook_ThatCanBeBorrowed_ShouldBeAddedToPendingLoans( IEventAggregator eventAggregator , [Frozen] IBookDAO bookDao , ILoanDAO loanDao , IMemberDAO memberDao , ScanBookModel scanBookModel , ScanBookViewModel viewModel , Book book , IBorrowingModel borrowingModel , Member borrower , List<ILoan> loanList ) { var fixture = new Fixture(); var loan = fixture.Build<Loan>() .FromFactory(() => new Loan(book, borrower, DateTime.Today, DateTime.Today.AddDays(10))) .Create(); eventAggregator.GetEvent<ScanningRecievedEvent>().Returns(new ScanningRecievedEvent()); eventAggregator.GetEvent<BorrowingStateEvent>().Returns(new BorrowingStateEvent()); eventAggregator.GetEvent<ScanningEvent>().Returns(new ScanningEvent()); // Arrange - Setup book on loan. bookDao.GetBookByID(scanBookModel.Barcode).Returns(book); // We are currently in the scanning book state. borrowingModel.BorrowingState.Returns(EBorrowState.SCANNING_BOOKS); // Establish the current user identified on borrowing model, and returned from member dao. borrowingModel.ID = borrower.ID; memberDao.GetMemberByID(borrower.ID).Returns(borrower); // Configure mapping. AutoMapperConfig.RegisterMaps(); loanDao.LoanList.Returns(loanList); var controller = new ScanBookController(eventAggregator) { BookDao = bookDao, LoanDao = loanDao, MemberDao = memberDao, ViewModel = viewModel }; loanDao.CreateLoan(borrower, book, Arg.Any<DateTime>(), Arg.Any<DateTime>()).Returns(loan); controller.ScanBook(borrowingModel); // Act -Scan a book. controller.Scanning(scanBookModel); // Assert - Results in an error message. viewModel.PendingLoans.Should().NotBeNullOrEmpty(); }