コード例 #1
0
        public void Setup()
        {
            // словари
            TradeSharpDictionary.Initialize(MoqTradeSharpDictionary.Mock);

            // заглушки для диалогов - выбора пользователей
            UserServiceRegistrator.DialogBoxProvider = new TestDialogBoxProvider();

            // серверный (торговый) прокси
            fakeTradeServer = ProxyBuilder.Instance.GetImplementer <ITradeSharpServerTrade>();
            List <Account> accounts;
            var            getUserOwnedAccountsWithActualBalanceMethodName =
                ProxyBuilder.GetMethodName <ITradeSharpServerTrade>(a => a.GetUserOwnedAccountsWithActualBalance("",
                                                                                                                 null, false, out accounts));

            ((IMockableProxy)fakeTradeServer).MockMethods.Add(getUserOwnedAccountsWithActualBalanceMethodName,
                                                              new GetUserOwnedAccountsWithActualBalanceDel((string login, ProtectedOperationContext secCtx, bool realOnly,
                                                                                                            out List <Account> acts) =>
            {
                acts = new List <Account>
                {
                    new Account
                    {
                        Balance  = 12000,
                        Currency = "USD",
                        ID       = 51,
                        Group    = "Real"
                    },
                    new Account
                    {
                        Balance  = 2000,
                        Currency = "USD",
                        ID       = 52,
                        Group    = "Real"
                    }
                };
                return(AuthenticationResponse.OK);
            }));
            MainForm.serverProxyTrade = new TradeSharpServerTrade(fakeTradeServer);

            // кошельковый прокси
            fakeWalletManager = ProxyBuilder.Instance.GetImplementer <IWalletManager>();
            ((IMockableProxy)fakeWalletManager).MockMethods.Add(StronglyName.GetMethodName <IWalletManager>(
                                                                    w => w.GetUserWallet(null, null)),
                                                                new Func <ProtectedOperationContext, string, Wallet>(
                                                                    (context, s) => new Wallet
            {
                Balance  = 1005,
                Currency = "USD",
                User     = 50
            }));
            WalletError walletError;
            var         registerOrUpdateServiceMethodName =
                ProxyBuilder.GetMethodName <IWalletManager>(w => w.RegisterOrUpdateService(
                                                                null, null, out walletError));

            ((IMockableProxy)fakeWalletManager).MockMethods.Add(registerOrUpdateServiceMethodName,
                                                                new RegisterOrUpdateServiceDel(
                                                                    (ProtectedOperationContext ctx, PaidService service,
                                                                     out WalletError error) =>
            {
                error = WalletError.OK;
                return(true);
            }));
            TradeSharpWalletManager.Initialize(fakeWalletManager);
        }
コード例 #2
0
 public void TearDown()
 {
     UserServiceRegistrator.DialogBoxProvider = new DialogBoxProvider();
     TradeSharpWalletManager.Initialize(null);
 }