Example #1
0
        static double GetRandomValue(IRandomWrapper random, int min, int max)
        {
            int    intPart   = random.Next(min, max);
            double floatPart = Math.Round(random.NextDouble(), 2);

            return(intPart + floatPart);
        }
Example #2
0
        private static IList <Order> GenerateData()
        {
            IRandomWrapper random = RandomWrapperFactory.Create();

            var productNames = new List <string> {
                "Alice Mutton", "Aniseed Syrup", "Boston Crab Meat", "Camembert Pierrot", "Carnarvon Tigers", "Chai", "Chang", "Chartreuse verte", "Chef Anton's Cajun Seasoning", "Chef Anton's Gumbo Mix", "Chocolade", "Côte de Blaye", "Escargots de Bourgogne", "Filo Mix", "Flotemysost", "Geitost", "Genen Shouyu", "Gnocchi di nonna Alice", "Gorgonzola Telino", "Grandma's Boysenberry Spread", "Gravad lax", "Guaraná Fantástica", "Gudbrandsdalsost", "Gula Malacca", "Gumbär Gummibärchen", "Gustaf's Knäckebröd", "Ikura", "Inlagd Sill", "Ipoh Coffee", "Jack's New England Clam Chowder", "Konbu", "Laughing Lumberjack Lager", "Longlife Tofu", "Louisiana Fiery Hot Pepper Sauce", "Louisiana Hot Spiced Okra", "Manjimup Dried Apples", "Mascarpone Fabioli", "Maxilaku", "Mishi Kobe Niku", "Mozzarella di Giovanni", "Nord-Ost Matjeshering", "Northwoods Cranberry Sauce", "NuNuCa Nuß-Nougat-Creme", "Original Frankfurter grüne Soße", "Outback Lager", "Pâté chinois", "Perth Pasties", "Queso Cabrales", "Queso Manchego La Pastora", "Raclette Courdavault", "Ravioli Angelo", "Rhönbräu Klosterbier", "Röd Kaviar", "Rogede sild", "Rössle Sauerkraut", "Sasquatch Ale", "Schoggi Schokolade", "Scottish Longbreads", "Singaporean Hokkien Fried Mee", "Sir Rodney's Marmalade", "Sir Rodney's Scones", "Sirop d'érable", "Spegesild", "Steeleye Stout", "Tarte au sucre", "Teatime Chocolate Biscuits", "Thüringer Rostbratwurst", "Tofu", "Tourtière", "Tunnbröd", "Uncle Bob's Organic Dried Pears", "Valkoinen suklaa", "Vegie-spread", "Wimmers gute Semmelknödel", "Zaanse koeken"
            };
            IList <Order> orders       = new List <Order>();
            int           startOrderId = 123;

            foreach (var productName in productNames)
            {
                var OrderDate = DateTime.Now.AddDays(-random.Next(0, 15));
                var order     = new Order()
                {
                    OrderID      = startOrderId++,
                    Product      = productName,
                    OrderDate    = OrderDate,
                    ShippedDate  = OrderDate.AddHours(random.Next(5, 55)),
                    UnitPrice    = random.Next(1, 12),
                    ShipRegionID = random.Next(1, 4),
                    UnitsInOrder = random.Next(1, 43),
                    OrderStatus  = random.Next(1, 100) < 70 ? OrderStatus.Processing : (random.Next(1, 100) < 50 ? OrderStatus.InTransit : OrderStatus.Delivered)
                };
                orders.Add(order);
            }
            return(orders);
        }
Example #3
0
        public Deck(IDeckBuilder builder, IRandomWrapper generator)
        {
            this.Builder   = builder;
            this.Generator = generator;

            Cards = Builder.Generate52CardDeck().ToList();
        }
Example #4
0
        public static List <BalanceSheetDataItem> GetData()
        {
            IRandomWrapper random             = RandomWrapperFactory.Create(2147483);
            List <BalanceSheetDataItem> items = new List <BalanceSheetDataItem>();

            items.AddRange(FillItems(random));
            return(items);
        }
Example #5
0
        public GetCommand(IDataProvider dbProvider, IRandomWrapper randomWrapper, IDateTimeWrapper dateTimeWrapper, IParametersParser parametersParser)
        {
            _dbProvider       = dbProvider;
            _randomWrapper    = randomWrapper;
            _dateTimeWrapper  = dateTimeWrapper;
            _parametersParser = parametersParser;

            Type = CommandType.Get;
        }
Example #6
0
 public Game(List <Participant> participants, PartnerMethod partnerMethod, bool enableLeasters, IRandomWrapper random = null, IGameStateDescriber gameStateDescriber = null) : this()
 {
     Hands           = Hands ?? new List <Hand>();
     LeastersEnabled = enableLeasters;
     Id                  = Guid.NewGuid();
     Participants        = participants;
     PartnerMethodEnum   = partnerMethod;
     _random             = random ?? _random;
     _gameStateDesciber1 = gameStateDescriber ?? _gameStateDesciber1;
 }
        static DeterministicRandom()
        {
            IRandomWrapper random = RandomWrapperFactory.Create(randomCount);

            deterministicRandomNumbers = new int[randomCount];
            for (int i = 0; i < randomCount; i++)
            {
                deterministicRandomNumbers[i] = random.Next(randomCount);
            }
        }
Example #8
0
        public Game()
        {
            _consoleLogger = CardGameFactory.CreateConsoleLogger();

            _consoleLogger.WriteMessage("How many decks would you like to play with");
            int decksToPlay;
            while (!Int32.TryParse(Console.ReadLine(), out decksToPlay)) {
                _consoleLogger.WriteMessage("Value entered is not a number");
                _consoleLogger.WriteMessage("How many decks would you like to play with");
            }
            _deck = CardGameFactory.GenerateDeck(decksToPlay);
            _randomizer = CardGameFactory.GenerateRNGWrapper();

            _deck.InitiliazeDeck();
        }
Example #9
0
        public Lottery(IRandomGenerator randomGenerator, IRandomWrapper randomWrapper)
        {
            _randomGenerator = randomGenerator;
            _randomWrapper   = randomWrapper;

            var config = new ConfigurationBuilder()
                         .SetBasePath(Directory.GetCurrentDirectory())
                         .AddJsonFile("appsettings.json", true, true)
                         .Build();

            var appsettings = config.GetSection("appsettings");

            _minimalLengthOfSeed         = int.Parse(appsettings["MinimalLengthOfSeed"]);
            _maximumLengthOfSeed         = int.Parse(appsettings["MaximumLengthOfSeed"]);
            _minimalLengthOfBallotNumber = int.Parse(appsettings["MinimalLengthOfBallotNumber"]);
            _maximumLengthOfBallotNumber = int.Parse(appsettings["MaximumLengthOfBallotNumber"]);
        }
Example #10
0
        public Hand(IGame game, IRandomWrapper random) : this()
        {
            if (!game.LastHandIsComplete())
            {
                throw new PreviousHandIncompleteException("Cannot add a hand until the prvious one is complete.");
            }
            IGame = game;
            IGame.Hands.Add(this);
            SortOrder = IGame?.IHands.Any() == true?IGame.IHands.Last().SortOrder + 1 : 0;

            Tricks  = new List <Trick>();
            _random = random;
            if (_random != null)
            {
                DealCards(ShuffleCards());
                SetStartingPlayer();
            }
            BuriedCards = string.Empty;
        }
Example #11
0
        static IEnumerable <BalanceSheetDataItem> FillItems(IRandomWrapper random)
        {
            List <BalanceSheetDataItem> items = new List <BalanceSheetDataItem>();

            for (int i = 0; i < 3; i++)
            {
                int year = DateTime.Today.Year - i;
                for (int month = 1; month <= 12; month++)
                {
                    AddItem(items, year, month, ItemType.Assets, "Current assets", "Cash and cash equivalents", GetRandomValue(random, 300, 2350));
                    AddItem(items, year, month, ItemType.Assets, "Current assets", "Marketable securities", GetRandomValue(random, 200, 3200));
                    AddItem(items, year, month, ItemType.Assets, "Current assets", "Accounts receivable trade, less allowances for doubtful accounts", GetRandomValue(random, 200, 1600));
                    AddItem(items, year, month, ItemType.Assets, "Current assets", "Inventories", GetRandomValue(random, 0, 1200));

                    AddItem(items, year, month, ItemType.Assets, "Long-term assets", "Property, plant and equipment, net", GetRandomValue(random, 600, 1950));
                    AddItem(items, year, month, ItemType.Assets, "Long-term assets", "Intangible assets, net", GetRandomValue(random, 1000, 3300));
                    AddItem(items, year, month, ItemType.Assets, "Long-term assets", "Goodwill", GetRandomValue(random, 950, 2500));
                    AddItem(items, year, month, ItemType.Assets, "Long-term assets", "Equity and long-term investments", GetRandomValue(random, 0, 1000));
                    AddItem(items, year, month, ItemType.Assets, "Long-term assets", "Defered taxes on income", GetRandomValue(random, 80, 1800));
                    AddItem(items, year, month, ItemType.Assets, "Long-term assets", "Other assets", GetRandomValue(random, 60, 630));

                    AddItem(items, year, month, ItemType.Liabilities, "Current liabilities", "Loans and notes payable", GetRandomValue(random, 130, 750));
                    AddItem(items, year, month, ItemType.Liabilities, "Current liabilities", "Accounts payable", GetRandomValue(random, 280, 970));
                    AddItem(items, year, month, ItemType.Liabilities, "Current liabilities", "Accrued rebates, returns and promotions", GetRandomValue(random, 185, 733));
                    AddItem(items, year, month, ItemType.Liabilities, "Current liabilities", "Accrued taxes on income", GetRandomValue(random, 5, 750));

                    AddItem(items, year, month, ItemType.Liabilities, "Long-term liabilities", "Long-term debt", GetRandomValue(random, 650, 1800));
                    AddItem(items, year, month, ItemType.Liabilities, "Long-term liabilities", "Deferred taxes on income", GetRandomValue(random, 90, 390));
                    AddItem(items, year, month, ItemType.Liabilities, "Long-term liabilities", "Employee related obligations", GetRandomValue(random, 150, 700));
                    AddItem(items, year, month, ItemType.Liabilities, "Long-term liabilities", "Other liabilities", GetRandomValue(random, 495, 995));

                    AddItem(items, year, month, ItemType.Liabilities, "Shareholders equity", "Preferred stock - without par value", null);
                    AddItem(items, year, month, ItemType.Liabilities, "Shareholders equity", "Common stock - par value $1.00 per share", GetRandomValue(random, 100, 1200));
                    AddItem(items, year, month, ItemType.Liabilities, "Shareholders equity", "Accumulated other comprehensive income", GetRandomValue(random, -950, 0));
                    AddItem(items, year, month, ItemType.Liabilities, "Shareholders equity", "Retained earnings", GetRandomValue(random, 800, 2500));
                }
            }
            return(items);
        }
Example #12
0
 public MatrixHelper(IRandomWrapper randomWrapper)
 {
     _randomWrapper = randomWrapper;
 }
Example #13
0
 public RandomOutcomeGenerator(IRandomWrapper random)
 {
     _random = random ?? throw new ArgumentNullException(nameof(random));
 }
Example #14
0
 public ShipFactory(IOptions <AppSettings> config, IRandomWrapper randomWrapper)
 {
     _config        = config;
     _randomWrapper = randomWrapper;
 }
Example #15
0
 public CoinTossService(IRandomWrapper random)
 {
     this.random = random;
 }
Example #16
0
 public RandomWrapperTests()
 {
     _sut = new RandomWrapper();
 }
 public FisherYatesShuffler(IRandomWrapper random)
 {
     _random = random;
 }
Example #18
0
 internal void LoadCards(string jsonString)
 {
     names  = JsonConvert.DeserializeObject <List <string> >(jsonString);
     random = new RandomWrapper();
 }
Example #19
0
 public CreateSecretMatch(IDataAccessor dataAccessor, IRandomWrapper randomWrapper)
 {
     _dataAccessor = dataAccessor;
     _random       = randomWrapper;
 }
Example #20
0
 internal NumberFaker(IRandomWrapper randomWrapper)
 {
     _randomWrapper = randomWrapper;
 }
Example #21
0
 internal TimeFaker(IRandomWrapper randomWrapper)
 {
     _randomWrapper = randomWrapper;
 }
Example #22
0
 internal DateFaker(IRandomWrapper randomWrapper)
 {
     _randomWrapper = randomWrapper;
 }
Example #23
0
 public VehicleFaker(IFakerContainer fakerContainer, IRandomWrapper randomWrapper)
 {
     _fakerContainer = fakerContainer;
     _randomWrapper  = randomWrapper;
 }
Example #24
0
 public void Setup()
 {
     _randomWrapper = Substitute.For <IRandomWrapper>();
     _matrixHelper  = new MatrixHelper(_randomWrapper);
 }
Example #25
0
 internal BooleanFaker(IRandomWrapper randomWrapper)
 {
     _randomWrapper = randomWrapper;
 }