Ejemplo n.º 1
0
    def testValidOrder(self):
        tc = TradingCenter()

        accountId = 'accountId'
        order1 = Order(accountId=accountId,
                       side=Side.BUY,
                       symbol='symbol',
                       price=13.25,
                       share=10)
        order2 = Order(accountId='unknowAccount',
                       side=Side.BUY,
                       symbol='symbol',
                       price=13.25,
                       share=10)
        account = self.mock.CreateMock(Account)
        account.validate(order1).AndReturn(True)
        account.validate(order1).AndReturn(False)
        tc._TradingCenter__accounts = {accountId: account}

        self.mock.ReplayAll()
        self.assertEquals(False,
                          tc.validateOrder(order2))  # invalid account id
        self.assertEquals(True, tc.validateOrder(order1))  # True
        self.assertEquals(False, tc.validateOrder(order1))  # False
        self.mock.VerifyAll()
Ejemplo n.º 2
0
    def testPlaceOrder_failed(self):
        tc = TradingCenter()

        accountId = 'accountId'
        order1 = Order(accountId = accountId, side = Side.BUY, symbol = 'symbol', price = 13.25, share = 10)
        account = self.mock.CreateMock(Account)
        account.validate(order1).AndReturn(False)
        tc._TradingCenter__accounts = {accountId: account}

        self.mock.ReplayAll()
        self.assertEquals(None, tc.placeOrder(order1) ) # True
        self.mock.VerifyAll()
Ejemplo n.º 3
0
    def testPlaceOrder_failed(self):
        tc = TradingCenter()

        accountId = 'accountId'
        order1 = Order(accountId=accountId,
                       side=Side.BUY,
                       symbol='symbol',
                       price=13.25,
                       share=10)
        account = self.mock.CreateMock(Account)
        account.validate(order1).AndReturn(False)
        tc._TradingCenter__accounts = {accountId: account}

        self.mock.ReplayAll()
        self.assertEquals(None, tc.placeOrder(order1))  # True
        self.mock.VerifyAll()
Ejemplo n.º 4
0
    def testValidOrder(self):
        tc = TradingCenter()

        accountId = 'accountId'
        order1 = Order(accountId = accountId, side = Side.BUY, symbol = 'symbol', price = 13.25, share = 10)
        order2 = Order(accountId = 'unknowAccount', side = Side.BUY, symbol = 'symbol', price = 13.25, share = 10)
        account = self.mock.CreateMock(Account)
        account.validate(order1).AndReturn(True)
        account.validate(order1).AndReturn(False)
        tc._TradingCenter__accounts = {accountId: account}

        self.mock.ReplayAll()
        self.assertEquals(False, tc.validateOrder(order2) ) # invalid account id
        self.assertEquals(True, tc.validateOrder(order1) ) # True
        self.assertEquals(False, tc.validateOrder(order1) ) # False
        self.mock.VerifyAll()