示例#1
0
        public void testPlaceOrder()
        {
            // Dummy literals
            String          isbn                 = "123";
            String          customerId           = "wall-e";
            Book            dummyBook            = new Book(isbn);
            Customer        dummyCustomer        = new Customer(customerId);
            Order           dummyOrder           = new Order();
            DispatchReceipt dummyDispatchReceipt = new DispatchReceipt();

            // prepate SUT
            BookstoreFacade facade = createFacade();

            // Prepare stubs
            //Mock<BookDBService> mock = new Mock<BookDBService>();
            //mock.When(bookService.findBookByISBN(isbn).GetType() == typeof(Book))
            //dummyBook = bookService.findBookByISBN(isbn);

            Console.WriteLine(dummyBook.ToString());
            Console.WriteLine();
            bookService.When(() => true).Setup(x => x.findBookByISBN(isbn)).Returns(dummyBook);
            //when(bookService.findBookByISBN(isbn)).thenReturn(dummyBook);
            //dummyCustomer = customerService.findCustomerById(customerId);

            //when(customerService.findCustomerById(customerId)).thenReturn(dummyCustomer);
            //dummyOrder = orderingService.createOrder(dummyCustomer, dummyBook);
            //when(orderingService.createOrder(dummyCustomer, dummyBook)).thenReturn(dummyOrder);
            //dummyDispatchReceipt = wharehouseService.dispatch(dummyOrder);
            //when(warehouseService.dispatch(dummyOrder)).thenReturn(dummyDispatchReceipt);

            // Exercise SUT
            facade.placeOrder(customerId, isbn);
        }
示例#2
0
        public void testPlaceOrder()
        {
            // Dummy literals
            String isbn = "123";
            String customerId = "wall-e";
            Book dummyBook = new Book(isbn);
            Customer dummyCustomer = new Customer(customerId);
            Order dummyOrder = new Order();
            DispatchReceipt dummyDispatchReceipt = new DispatchReceipt();

            // prepate SUT
            BookstoreFacade facade = createFacade();

            // Prepare stubs
            //Mock<BookDBService> mock = new Mock<BookDBService>();
            //mock.When(bookService.findBookByISBN(isbn).GetType() == typeof(Book))
            //dummyBook = bookService.findBookByISBN(isbn);

            Console.WriteLine(dummyBook.ToString());
            Console.WriteLine();
            bookService.When(() => true).Setup(x => x.findBookByISBN(isbn)).Returns(dummyBook);
            //when(bookService.findBookByISBN(isbn)).thenReturn(dummyBook);
            //dummyCustomer = customerService.findCustomerById(customerId);

            //when(customerService.findCustomerById(customerId)).thenReturn(dummyCustomer);
            //dummyOrder = orderingService.createOrder(dummyCustomer, dummyBook);
            //when(orderingService.createOrder(dummyCustomer, dummyBook)).thenReturn(dummyOrder);
            //dummyDispatchReceipt = wharehouseService.dispatch(dummyOrder);
            //when(warehouseService.dispatch(dummyOrder)).thenReturn(dummyDispatchReceipt);

            // Exercise SUT
            facade.placeOrder(customerId, isbn);
        }
 /* (non-Javadoc)
  * @see eu.jpereira.trainings.designpatterns.structural.facade.service.CustomerNotificationService#notifyClient(eu.jpereira.trainings.designpatterns.structural.facade.model.DispatchReceipt)
  */
 public void notifyClient(DispatchReceipt dispatchReceipt)
 {
     notifiedDispatchReceipts.Add(dispatchReceipt);
 }