Exemplo 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()
    def testValidOrder(self):
        tc = TradingCenter()
        account = Account(1000, 10)
        accountId = tc.accountManager.addAccount(account)

        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)

        self.assertEquals(False, tc.validateOrder(order2) ) # invalid account id
        self.assertEquals(True, tc.validateOrder(order1) ) # True
    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()