示例#1
0
        public void Init()
        {
            var optionsBuilder = new DbContextOptionsBuilder <ApplicationDbContext>();

            optionsBuilder.UseInMemoryDatabase("databaseManagerValidator");
            context = new ApplicationDbContext(optionsBuilder.Options);

            applicationUser = new ApplicationUser
            {
                Id        = Guid.NewGuid(),
                IsEnabled = true,
                Type      = UserType.Manager,
                Wallets   = new List <Wallets> {
                    new Wallets {
                        Amount = 10000, Currency = Currency.GVT
                    }
                },
            };
            broker = new BrokersAccounts
            {
                Id               = Guid.NewGuid(),
                UserId           = applicationUser.Id,
                Description      = string.Empty,
                IsEnabled        = true,
                Name             = "Broker #1",
                RegistrationDate = DateTime.UtcNow
            };
            brokerTradeServer = new BrokerTradeServers
            {
                Id               = Guid.NewGuid(),
                Name             = "Server #1",
                IsEnabled        = true,
                Host             = string.Empty,
                RegistrationDate = DateTime.UtcNow,
                Type             = BrokerTradeServerType.MetaTrader4,
                BrokerId         = broker.Id
            };
            managerAccount = new ManagerAccounts
            {
                Id = Guid.NewGuid(),
                BrokerTradeServerId = brokerTradeServer.Id,
                Currency            = Currency.USD,
                Login            = "******",
                RegistrationDate = DateTime.UtcNow,
                UserId           = applicationUser.Id,
                IsConfirmed      = true
            };

            context.Add(applicationUser);
            context.Add(broker);
            context.Add(brokerTradeServer);
            context.Add(managerAccount);
            context.SaveChanges();

            managerValidator = new ManagerValidator(context);
        }
示例#2
0
 public static Broker ToBroker(this BrokersAccounts broker)
 {
     return(new Broker
     {
         Id = broker.Id,
         Description = broker.Description,
         Name = broker.Name,
         Logo = broker.Logo,
         RegistrationDate = broker.RegistrationDate
     });
 }
示例#3
0
        public void Init()
        {
            var optionsBuilder = new DbContextOptionsBuilder <ApplicationDbContext>();

            optionsBuilder.UseInMemoryDatabase("databaseBrokerValidator");
            context = new ApplicationDbContext(optionsBuilder.Options);

            user = new ApplicationUser
            {
                Id        = Guid.NewGuid(),
                IsEnabled = true,
                Type      = UserType.Broker
            };
            broker = new BrokersAccounts
            {
                Id               = Guid.NewGuid(),
                UserId           = user.Id,
                Description      = string.Empty,
                IsEnabled        = true,
                Name             = "Broker #1",
                Logo             = "logo.png",
                RegistrationDate = DateTime.UtcNow
            };
            brokerTradeServer = new BrokerTradeServers
            {
                Id               = Guid.NewGuid(),
                Name             = "Server #1",
                IsEnabled        = true,
                Host             = string.Empty,
                RegistrationDate = DateTime.UtcNow,
                Type             = BrokerTradeServerType.MetaTrader4,
                BrokerId         = broker.Id
            };
            context.Add(broker);
            context.Add(brokerTradeServer);
            context.SaveChanges();


            brokerValidator = new BrokerValidator(context);
        }
示例#4
0
        public void Init()
        {
            var optionsBuilder = new DbContextOptionsBuilder <ApplicationDbContext>();

            optionsBuilder.UseInMemoryDatabase("databaseTrustManagementService");
            context = new ApplicationDbContext(optionsBuilder.Options);

            user = new ApplicationUser
            {
                Id        = Guid.NewGuid(),
                IsEnabled = true,
                Wallets   = new List <Wallets> {
                    new Wallets {
                        Amount = 100000, Currency = Currency.GVT
                    }
                },
            };
            managerAccount = new ManagerAccounts
            {
                Id          = Guid.NewGuid(),
                IsConfirmed = true,
                UserId      = user.Id
            };
            investmentProgram = new InvestmentPrograms
            {
                Id               = Guid.NewGuid(),
                DateFrom         = DateTime.UtcNow.AddYears(-1),
                FeeEntrance      = 100m,
                FeeSuccess       = 120m,
                FeeManagement    = 10m,
                Description      = "Test inv",
                IsEnabled        = true,
                Period           = 10,
                InvestMinAmount  = 500,
                InvestMaxAmount  = 1500,
                ManagerAccountId = managerAccount.Id,
                Token            = new ManagerTokens
                {
                    TokenName   = "Token",
                    TokenSymbol = "TST"
                }
            };
            broker = new BrokersAccounts
            {
                Id               = Guid.NewGuid(),
                UserId           = user.Id,
                Description      = string.Empty,
                IsEnabled        = true,
                Name             = "Broker #1",
                RegistrationDate = DateTime.UtcNow
            };
            brokerTradeServer = new BrokerTradeServers
            {
                Id               = Guid.NewGuid(),
                Name             = "Server #1",
                IsEnabled        = true,
                Host             = string.Empty,
                RegistrationDate = DateTime.UtcNow,
                Type             = BrokerTradeServerType.MetaTrader4,
                BrokerId         = broker.Id
            };
            context.Add(user);
            context.Add(managerAccount);
            context.Add(investmentProgram);
            context.Add(broker);
            context.Add(brokerTradeServer);
            context.SaveChanges();

            smartContractService = new Mock <ISmartContractService>();
            ipfsService          = new Mock <IIpfsService>();
            statisticService     = new Mock <IStatisticService>();
            rateService          = new Mock <IRateService>();

            trustManagementService = new TrustManagementService(context,
                                                                ipfsService.Object,
                                                                smartContractService.Object,
                                                                statisticService.Object,
                                                                rateService.Object,
                                                                Substitute.For <ILogger <ITrustManagementService> >());
        }