Exemplo n.º 1
0
 public ClientsController(ClientsService clientsService, BalancesService balancesService, SalesService salesService, ReportsService reportsService)
 {
     this.clientsService  = clientsService;
     this.balancesService = balancesService;
     this.salesService    = salesService;
     this.reportsService  = reportsService;
 }
Exemplo n.º 2
0
 public Trade(BalancesService balancesService, StocksService stocksService, TransactionService transactionService, UsersService usersService, ValidationOfTransactionService validationOfTransactionService)
 {
     this.balancesService                = balancesService;
     this.stocksService                  = stocksService;
     this.transactionService             = transactionService;
     this.usersService                   = usersService;
     this.validationOfTransactionService = validationOfTransactionService;
 }
Exemplo n.º 3
0
        public void Balances()
        {
            var service = new BalancesService(_Client);

            var balance = service.GetBalance(_Client.Credentials.PrivateToken);

            Assert.IsNotNull(balance);
        }
Exemplo n.º 4
0
 public StockExchange(Container traidingRegistryContainer)
 {
     this.traidingRegistryContainer = traidingRegistryContainer;
     this.balancesService           = traidingRegistryContainer.GetInstance <BalancesService>();
     this.clientsService            = traidingRegistryContainer.GetInstance <ClientsService>();
     this.reportsService            = traidingRegistryContainer.GetInstance <ReportsService>();
     this.salesService      = traidingRegistryContainer.GetInstance <SalesService>();
     this.sharesService     = traidingRegistryContainer.GetInstance <SharesService>();
     this.shareTypesService = traidingRegistryContainer.GetInstance <ShareTypesService>();
 }
Exemplo n.º 5
0
        public void BalanceIsNotSet_ItsEnought()
        {
            var balancesService = new BalancesService();

            var order = Order.CreateLimit(ClientId1, TradeType.Sell, Pair, 100, 100);

            bool enoughtFundsForOrder = balancesService.UserHasEnoughBalanceForOrder(order);

            Assert.True(enoughtFundsForOrder);
        }
        public void ShouldGetExceptionIfBalanceNotExists()
        {
            //Arrange
            var balanceTableRepository = Substitute.For <IBalanceTableRepository>();

            balanceTableRepository.Contains(Arg.Is("1102")).Returns(false);
            BalancesService balanceService = new BalancesService(balanceTableRepository);

            // Act
            balanceService.Get("1102");
        }
Exemplo n.º 7
0
        public void BuyOrder_QuoteBalanceIsSetLow_ItsNotEnought()
        {
            var balancesService = new BalancesService();

            balancesService.SetBalance(ClientId1, QuoteAsset, 1000);

            var order = Order.CreateLimit(ClientId1, TradeType.Buy, Pair, 100, 100);

            bool enoughtFundsForOrder = balancesService.UserHasEnoughBalanceForOrder(order);

            Assert.False(enoughtFundsForOrder);
        }
        public void ShouldGetBalanceInfo()
        {
            //Arrange
            var balanceTableRepository = Substitute.For <IBalanceTableRepository>();

            balanceTableRepository.Contains(Arg.Is("2201")).Returns(true);
            BalancesService balanceService = new BalancesService(balanceTableRepository);

            // Act
            balanceService.Get("2201");

            //Assert
            balanceTableRepository.Received(1).Get("2201");
        }
        public void ShouldThrowExceptionIfCantFindBalance()
        {
            // Arrange
            this.balanceTableRepository = Substitute.For <IBalanceTableRepository>();
            int testId = 55;

            this.balanceTableRepository.ContainsById(Arg.Is(testId)).Returns(false); // Now Contains returns false (table don't contains share type with this Id)
            BalancesService balancesService = new BalancesService(this.balanceTableRepository);

            // Act
            balancesService.ContainsById(testId); // Try to get share type and get exception

            // Assert
        }
Exemplo n.º 10
0
        public void ShouldGetBalanceInfo()
        {
            // Arrange
            this.balanceTableRepository = Substitute.For <IBalanceTableRepository>();
            int testId = 55;

            this.balanceTableRepository.ContainsById(Arg.Is(testId)).Returns(true);
            BalancesService balancesService = new BalancesService(this.balanceTableRepository);

            // Act
            var balanceInfo = balancesService.GetBalance(testId);

            // Assert
            this.balanceTableRepository.Received(1).Get(testId);
        }
Exemplo n.º 11
0
        public void ShouldChangeAmount()
        {
            // Arrange
            this.balanceTableRepository = Substitute.For <IBalanceTableRepository>();
            int testId = 55;

            this.balanceTableRepository.ContainsById(Arg.Is(testId)).Returns(true);
            BalancesService balancesService = new BalancesService(this.balanceTableRepository);
            decimal         newAmount       = 5000.00M;

            // Act
            balancesService.ChangeBalance(testId, newAmount);

            // Assert
            this.balanceTableRepository.Received(1).ChangeAmount(testId, newAmount);
            this.balanceTableRepository.Received(1).SaveChanges();
        }
Exemplo n.º 12
0
        public void ShouldNotCreateNewBalanceIfItExists()
        {
            //Arrange
            var             balanceTableRepository = Substitute.For <IBalanceTableRepository>();
            BalancesService balanceService         = new BalancesService(balanceTableRepository);
            BalanceInfo     args = new BalanceInfo();

            args.UserID      = 22;
            args.Balance     = 1000;
            args.StockID     = 1;
            args.StockAmount = 1;

            //Act
            balanceService.CreateBalance(args);

            balanceTableRepository.Contains(Arg.Is <BalanceEntity>(w => w.UserID == args.UserID &&
                                                                   w.Balance == args.Balance &&
                                                                   w.StockID == args.StockID &&
                                                                   w.StockAmount == args.StockAmount)).Returns(true);
            balanceService.CreateBalance(args);
        }
Exemplo n.º 13
0
        public void ShouldCreateBalance()
        {
            //Arrange
            var             balanceTableRepository = Substitute.For <IBalanceTableRepository>();
            BalancesService balanceService         = new BalancesService(balanceTableRepository);
            BalanceInfo     args = new BalanceInfo();

            args.UserID      = 22;
            args.Balance     = 1000;
            args.StockID     = 1;
            args.StockAmount = 1;

            //Act
            balanceService.CreateBalance(args);
            //Assert
            balanceTableRepository.Received(1).Add(Arg.Is <BalanceEntity>(w => w.UserID == args.UserID &&
                                                                          w.Balance == args.Balance &&
                                                                          w.StockID == args.StockID &&
                                                                          w.StockAmount == args.StockAmount));
            balanceTableRepository.Received(1).SaveChanges();
        }
Exemplo n.º 14
0
        public void ShouldNotRegisterNewBalanceIfItExists()
        {
            // Arrange
            this.balanceTableRepository = Substitute.For <IBalanceTableRepository>();
            BalancesService         balancesService = new BalancesService(this.balanceTableRepository);
            BalanceRegistrationInfo args            = new BalanceRegistrationInfo();

            args.Client = this.newClient;
            args.Amount = 5000.00M;
            args.Status = true;

            // Act
            balancesService.RegisterNewBalance(args);

            this.balanceTableRepository.Contains(Arg.Is <BalanceEntity>( // Now Contains returns true (table contains this balance of client)
                                                     b => b.Client == args.Client)).Returns(true);

            balancesService.RegisterNewBalance(args); // Try to reg. same twice and get exception

            // Assert
        }
Exemplo n.º 15
0
        public void ShouldRegisterNewBalance()
        {
            // Arrange
            this.balanceTableRepository = Substitute.For <IBalanceTableRepository>();
            BalancesService         balancesService = new BalancesService(this.balanceTableRepository);
            BalanceRegistrationInfo args            = new BalanceRegistrationInfo();

            args.Client = this.newClient;
            args.Amount = 5000.00M;
            args.Status = true;

            // Act
            var shareId = balancesService.RegisterNewBalance(args);

            // Assert
            this.balanceTableRepository.Received(1).Add(Arg.Is <BalanceEntity>(
                                                            b => b.Client == args.Client &&
                                                            b.Amount == args.Amount &&
                                                            b.Status == args.Status));
            this.balanceTableRepository.Received(1).SaveChanges();
        }
Exemplo n.º 16
0
        public void Configuration(IAppBuilder app)
        {
            ConfigureAuth(app);
            GlobalConfiguration.Configuration.UseSqlServerStorage("DefaultConnection");
            app.UseHangfireDashboard("/hg", new DashboardOptions
            {
                Authorization = Enumerable.Empty <IDashboardAuthorizationFilter>()
            });
            app.UseHangfireDashboard();
            app.UseHangfireServer();
            //createRolesandUsers();

            RecurringJob.AddOrUpdate(() => BalancesService.BatchArchivosBalances(), Cron.Daily);

            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
                CloudConfigurationManager.GetSetting("diujstorage_AzureStorageConnectionString"));

            CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

            CloudBlobContainer container = blobClient.GetContainerReference("contenedor");

            container.CreateIfNotExists();
        }
Exemplo n.º 17
0
 public BalancesController()
 {
     db             = TpIntegradorDbContext.GetInstance();
     balanceService = new BalancesService(db);
     empService     = new EmpresasService(db);
 }