Beispiel #1
0
        public async Task WeTakeAllItemsExceptTheHighestOne()
        {
            var rakeService = new RakeService();

            var bets = new List <DatabaseModel.Bet>
            {
                new DatabaseModel.Bet(1, 0, 1, DateTime.Today, 11),
                new DatabaseModel.Bet(2, 0, 1, DateTime.Now, 22),
            };

            var itemBets = new List <DatabaseModel.ItemBetted>
            {
                new DatabaseModel.ItemBetted(11, 0, "assetId1", 100),
                new DatabaseModel.ItemBetted(22, 0, "assetId2", 50),
                new DatabaseModel.ItemBetted(22, 0, "assetId3", 3),
                new DatabaseModel.ItemBetted(22, 0, "assetId4", 3),
                new DatabaseModel.ItemBetted(22, 0, "assetId5", 3),
            };


            var res = rakeService.GetItemsThatWeShouldTake(50, bets, itemBets, _winningUser);

            Assert.Equal(3, res.ItemIdsToUs.Count);
            Assert.Equal(1, res.ItemIdsToWinner.Count);
        }
Beispiel #2
0
        public async Task WeTakeRakeBeacuseOfBadName(string name)
        {
            var rakeService = new RakeService();

            var bets = new List <DatabaseModel.Bet>
            {
                new DatabaseModel.Bet(1, 0, 1, DateTime.Today, 11),
                new DatabaseModel.Bet(2, 0, 1, DateTime.Now, 22),
            };

            var itemBets = new List <DatabaseModel.ItemBetted>
            {
                new DatabaseModel.ItemBetted(11, 0, "assetId1", 73),
                new DatabaseModel.ItemBetted(22, 0, "assetId2", 11),
                new DatabaseModel.ItemBetted(22, 0, "assetId3", 10),
                new DatabaseModel.ItemBetted(22, 0, "assetId4", 3),
                new DatabaseModel.ItemBetted(22, 0, "assetId5", 3),
            };

            var user = new DatabaseModel.User("winnerSteamId", name, "", "", DateTime.Now, DateTime.Now, false, null, 1);


            var res = rakeService.GetItemsThatWeShouldTake(10, bets, itemBets, user);

            Assert.Equal(1, res.ItemIdsToUs.Count);
            Assert.Equal(4, res.ItemIdsToUs.Count + res.ItemIdsToWinner.Count);
            Assert.Equal(3, res.ItemIdsToWinner.Count);
        }
Beispiel #3
0
        public async Task WeTakeRakeNormalSuccess3()
        {
            var rakeService = new RakeService();

            var bets = new List <DatabaseModel.Bet>
            {
                new DatabaseModel.Bet(1, 0, 1, DateTime.Today, 11),
                new DatabaseModel.Bet(2, 0, 1, DateTime.Today, 22),
                new DatabaseModel.Bet(3, 0, 1, DateTime.Today, 33),
                new DatabaseModel.Bet(4, 0, 1, DateTime.Today, 44),
                new DatabaseModel.Bet(5, 0, 1, DateTime.Today, 55),
                new DatabaseModel.Bet(6, 0, 1, DateTime.Today, 66),
            };

            var itemBets = new List <DatabaseModel.ItemBetted>
            {
                new DatabaseModel.ItemBetted(11, 0, "assetId1", 100),
                new DatabaseModel.ItemBetted(22, 0, "assetId2", 50),
                new DatabaseModel.ItemBetted(22, 0, "assetId3", 3),
                new DatabaseModel.ItemBetted(22, 0, "assetId4", 3),
                new DatabaseModel.ItemBetted(22, 0, "assetId5", new decimal(0.5)),
                new DatabaseModel.ItemBetted(33, 0, "assetId6", new decimal(10.5)),
                new DatabaseModel.ItemBetted(33, 0, "assetId7", new decimal(45.47)),
                new DatabaseModel.ItemBetted(33, 0, "assetId8", new decimal(4.87)),
                new DatabaseModel.ItemBetted(44, 0, "assetId9", new decimal(78.0)),
                new DatabaseModel.ItemBetted(55, 0, "assetId10", new decimal(54.0)),
                new DatabaseModel.ItemBetted(44, 0, "assetId12", new decimal(5.0)),
                new DatabaseModel.ItemBetted(55, 0, "assetId13", new decimal(4.0)),
                new DatabaseModel.ItemBetted(66, 0, "assetId14", new decimal(8.0)),
                new DatabaseModel.ItemBetted(33, 0, "assetId15", new decimal(8.54)),
            };

            var sum = itemBets.Sum(i => i.Value);
            var x   = itemBets.OrderBy(i => i.Value).ToList();
            //374.88
            //37.488
            //14 items - 1


            var res = rakeService.GetItemsThatWeShouldTake(10, bets, itemBets, _winningUser);

            Assert.Equal(6, res.ItemIdsToUs.Count);
            Assert.Equal(7, res.ItemIdsToWinner.Count);
        }
Beispiel #4
0
        public async Task WeTakeRakeButThereAreNoItemsThatWeCanTakeDueToWinnerNeedsToReceveAtleastOneItemSuccess()
        {
            var rakeService = new RakeService();

            var bets = new List <DatabaseModel.Bet>
            {
                new DatabaseModel.Bet(1, 0, 1, DateTime.Today, 11),
                new DatabaseModel.Bet(2, 0, 1, DateTime.Now, 22),
            };

            var itemBets = new List <DatabaseModel.ItemBetted>
            {
                new DatabaseModel.ItemBetted(11, 0, "assetId1", 100),
                new DatabaseModel.ItemBetted(22, 0, "assetId2", 3),
            };


            var res = rakeService.GetItemsThatWeShouldTake(5, bets, itemBets, _winningUser);

            Assert.Equal(0, res.ItemIdsToUs.Count);
            Assert.Equal(1, res.ItemIdsToWinner.Count);
        }
Beispiel #5
0
        private static void GetRakeDetailedExample()
        {
            var rakeService = new RakeService(_merchantAuthInfo);

            try
            {
                var response = rakeService.GetRakeDetailed(new GetRakeDetailedRequest());

                if (response.StatusCode == StatusCodes.Success)
                {
                    var rakeData = response.Data.RakeData;

                    foreach (var i in rakeData)
                    {
                        Console.WriteLine(JsonConvert.SerializeObject(i));
                    }
                }
            }
            catch (CantConnectToServerException ex)
            {
                Console.WriteLine(ex);
            }
        }
Beispiel #6
0
        /////////////////////////////////////////////////////////////////////////////
        // Overridden Package Implementation

        #region Package Members

        /// <summary>
        /// Initialization of the package; this method is called right after the package is sited, so this is the place
        /// where you can put all the initialization code that rely on services provided by VisualStudio.
        /// </summary>
        protected override void Initialize()
        {
            Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
            base.Initialize();

            rakeService = new RakeService();

            //get the path of rake from options.
            string rakePath   = "";
            var    optionPage = GetDialogPage(typeof(OptionPage)) as OptionPage;

            if (optionPage != null)
            {
                //set it in the service
                rakeService.RakeDefaultPath = rakePath = optionPage.RakePath;
                //setup property changed event
                optionPage.PropertyChanged += optionPage_PropertyChanged;
            }
            //if the path is empty or null, see if we can find it in the Environment PATH
            if (string.IsNullOrEmpty(rakePath))
            {
                rakePath = rakeService.GetRakePathFromEnvironment();
                //if found, we set it in the options and the service
                rakeService.RakeDefaultPath = rakePath;
                if (optionPage != null)
                {
                    optionPage.RakePath = rakePath;
                }
            }

            this._dte = (DTE)this.GetService(typeof(DTE));

            IVsMonitorSelection ms = this.GetService(typeof(SVsShellMonitorSelection)) as IVsMonitorSelection;

            if (ms != null)
            {
                ms.AdviseSelectionEvents(this, out _vsMonitorCookie);
            }

            var solution = this.GetService(typeof(SVsSolution)) as IVsSolution;

            if (solution != null)
            {
                solution.AdviseSolutionEvents(this, out _vsSolutionEventsCookie);
            }

            // Add our command handlers for menu (commands must exist in the .vsct file)
            OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;

            if (null != mcs)
            {
                //the main menu
                CommandID command = new CommandID(GuidList.guidRakeRunnerCmdSet, (int)PkgCmdIDList.icmdCommandRakeMenu);
                var       cmd     = new OleMenuCommand(null, command);
                cmd.BeforeQueryStatus += cmd_BeforeQueryStatus;
                mcs.AddCommand(cmd);

                //the main menu
                command = new CommandID(GuidList.guidRakeRunnerCmdSet, (int)PkgCmdIDList.icmdRefresh);
                cmd     = new OleMenuCommand(RefreshCommand, command);
                mcs.AddCommand(cmd);
            }
        }