Ejemplo n.º 1
0
        public void VerifyAmounts(bool orderDescending)
        {
            // Login phase
            logInPage.OpenLoginPage();
            logInPage.VerifyLoginPage();

            logInPage.Login("myUser", "myPassword");
            mainPage.VerifyMainPage();

            // Sort amounts
            var amountElementList = mainPage.GetSortedTransactionsByAmount();

            // Use regex for removing special characters and sort amount in descending order
            var amount       = amountElementList.Select(a => NumbersUtil.FormatNumber(Regex.Replace(a.Text, @"[, USD]", string.Empty))).ToList();
            var amountSorted = amount.OrderBy(a => a).ToList();

            CollectionAssert.AreEqual(amountSorted, amount);

            if (orderDescending)
            {
                amountElementList = mainPage.GetSortedTransactionsByAmount();
                amount            = amountElementList.Select(a => NumbersUtil.FormatNumber(Regex.Replace(a.Text, @"[, USD]", string.Empty))).ToList();
                amountSorted      = amount.OrderByDescending(a => a).ToList();
                CollectionAssert.AreEqual(amountSorted, amount);
            }
        }
Ejemplo n.º 2
0
        public void NumbersUtil_GreatestCommonDivisor_RelativePrimes_ReturnsCorrectValue()
        {
            //Arrange
            int num1 = 2, num2 = 3;
            //Act
            var gcd = NumbersUtil.GreatestCommonDivisor(num1, num2);

            //Assert
            Assert.Equal(1, gcd);
        }
Ejemplo n.º 3
0
        public void NumbersUtil_GreatestCommonDivisor_OneNumberIsZero_ReturnsCorrectValue(int num1, int num2)
        {
            //Arrange

            //Act
            var gcd = NumbersUtil.GreatestCommonDivisor(num1, num2);

            //Assert
            Assert.Equal(1, gcd);
        }
Ejemplo n.º 4
0
        public void NumbersUtil_GreatestCommonDivisor_DifferentSignNumbers_ReturnsCorrectValue()
        {
            //Arrange
            int num1 = -10, num2 = 5;

            //Act
            var gcd = NumbersUtil.GreatestCommonDivisor(num1, num2);

            //Assert
            Assert.Equal(5, gcd);
        }
Ejemplo n.º 5
0
        public void NumbersUtil_GreatestCommonDivisor_Zeros_Returns1()
        {
            //Arrange
            int num1 = 0, num2 = 0;

            //Act
            var gcd = NumbersUtil.GreatestCommonDivisor(num1, num2);

            //Assert
            Assert.Equal(1, gcd);
        }
Ejemplo n.º 6
0
 protected decimal ComputeWinnerGain(byte WinnerNumber, Bet bet)
 {
     if (bet.Bet_Type == (byte)BetTypeEnum.BET_TYPE_COLOR && NumbersUtil.IsPair(bet.Bet_Number) == NumbersUtil.IsPair(WinnerNumber))
     {
         return(bet.Bet_Amount * WinnnerByColorMultiplier);
     }
     else if (bet.Bet_Type == (byte)BetTypeEnum.BET_TYPE_NUMBER && bet.Bet_Number == WinnerNumber)
     {
         return(bet.Bet_Amount * WinnnerByNumberMultiplier);
     }
     return(0);
 }
Ejemplo n.º 7
0
        public async Task <Response> CloseRoulette(string id)
        {
            List <Bet>           betList        = null;
            List <UserBetResult> userBetResults = null;
            Roulette             roulette       = null;
            byte      WinnerNumber = 0;
            Response  response     = new Response();
            BetResult betResult    = null;

            roulette = await Context.GetRoulette(id);

            response = ValidateForCloseRoulette(roulette);
            if (!response.Successfull)
            {
                return(response);
            }
            betList = await Context.GetBetsFromRoulette(id);

            if (betList == null || betList.Count <= 0)
            {
                return(new Response(false, "ERROR: There is not any bet on this roulette!", null));
            }
            WinnerNumber   = NumbersUtil.RandomByte(36);
            userBetResults = ConvertToUserBetResults(WinnerNumber, betList);
            response       = await PerformRouletteClosingOnDB(roulette);

            if (!response.Successfull)
            {
                return(new Response(false, "ERROR: Could not close roulette!", null));
            }
            betResult = new BetResult()
            {
                BetsPerformed        = betList,
                UsersBetResults      = userBetResults,
                WinnerNumberAndColor = $"{BetUtils.GetBetColorFromByte(WinnerNumber)} {WinnerNumber}",
            };

            return(new Response(true, $"Roulette was closed successfully", betResult));
        }
Ejemplo n.º 8
0
        public static List <IHasBits> FilterList_UsingWorkers(this List <IHasBits> sourceList, Func <IHasBits, bool> filter, int numThreads)
        {
            List <IHasBits> rv = new List <IHasBits>();

            var slices  = NumbersUtil.GetSliceBounds(0, sourceList.Count, numThreads > sourceList.Count ? sourceList.Count : numThreads);
            var workers = new HasBitsFilterWorker[slices.Length];

            for (int i = 0; i < slices.Length; i++)
            {
                workers[i] = new HasBitsFilterWorker(slices[i][0], slices[i][1], sourceList, filter);
            }

            foreach (var w in workers)
            {
                w.Thread.Join();
            }

            for (int i = 0; i < workers.Length; i++)
            {
                rv.AddRange(workers[i].Accumulator);
            }

            return(rv);
        }