Example #1
0
    public async Task RunAsync(RandomOptions opts, IConfiguration configuration)
    {
        var totalNumbers = await _api.GetTotalGalleryCountAsync();

        while (true)
        {
            var randomCode = new Random().Next(1, totalNumbers);
            var response   = await _api.FetchSingleAsync(randomCode.ToString());

            _console.WriteLine(response.ToReadable());

            var prompt = Prompt.Confirm("Are you sure to download this one?", true);
            if (!prompt)
            {
                await Task.Delay(1000).ConfigureAwait(false);

                continue;
            }

            var useTachiyomiLayout = opts.UseTachiyomiLayout || bool.Parse(configuration["UseTachiyomiFolderStructure"]);
            await _download.DownloadAsync(response, opts.Output, opts.Pack, useTachiyomiLayout, null);

            break;
        }
    }
Example #2
0
        public double FullyRandomCalculate(double inputValue, IRandomService randomService, int seed)
        {
            var randomOptions = new RandomOptions
            {
                Seed       = seed,
                IsNegative = inputValue <= 0.0
            };

            return(randomService.GetRandomValue(randomOptions));
        }
Example #3
0
        public void GetRandomValueTest(RandomOptions randomOptions, double randomValue, double expectedResult)
        {
            var randomServiceMock = new Mock <RandomService> {
                CallBase = true
            };

            randomServiceMock
            .Setup(randomService => randomService.GetRandomValue(randomOptions.Seed))
            .Returns(randomValue);

            var actualResult = randomServiceMock.Object.GetRandomValue(randomOptions);

            Assert.AreEqual(expectedResult, actualResult);
        }
Example #4
0
 public double GetRandomValue(RandomOptions randomOptions)
 {
     GetRandomValueWithRandomOptionsInvocationCount++;
     return(5.0);
 }
        public double GetRandomValue(RandomOptions randomOptions)
        {
            var result = GetRandomValue(randomOptions.Seed);

            return(randomOptions.IsNegative ? -result : result);
        }
Example #6
0
        public static void EnterRandomString(this IWebElement element, IWebDriver driver, int length, RandomOptions randomoptions)
        {
            Random random = new Random();
            string chars;
            string randomString;

            if (length < 0)
            {
                throw new ArgumentException("length must not be negative", "length");
            }
            if (length > int.MaxValue / 8) // 250 million chars ought to be enough for anybody
            {
                throw new ArgumentException("length is too big", "length");
            }
            if (length == 0)
            {
                throw new ArgumentException("length must be greater than 0", "length");
            }
            if (randomoptions == RandomOptions.Alpha)
            {
                chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
            }

            else
            {
                chars = "0123456789";
            }
            randomString = new string(Enumerable.Repeat(chars, length)
                                      .Select(s => s[random.Next(s.Length)]).ToArray());
            driver.Highlight(element);

            element.Clear();
            element.SendKeys(randomString);
        }