예제 #1
0
        protected override void Seed(ToDoDotNet.Data.ToDoDbContext context)
        {
            var lorem = new Bogus.DataSets.Lorem();
            var dates = new Bogus.DataSets.Date();

            context.ToDos.AddOrUpdate(x => x.Id,
                                      new ToDo()
            {
                Title = lorem.Word(), Body = lorem.Sentences(), CreationDate = dates.Soon()
            },
                                      new ToDo()
            {
                Title = lorem.Word(), Body = lorem.Sentences(), CreationDate = dates.Soon()
            },
                                      new ToDo()
            {
                Title = lorem.Word(), Body = lorem.Sentences(), CreationDate = dates.Soon()
            },
                                      new ToDo()
            {
                Title = lorem.Word(), Body = lorem.Sentences(), CreationDate = dates.Soon()
            },
                                      new ToDo()
            {
                Title = lorem.Word(), Body = lorem.Sentences(), CreationDate = dates.Soon()
            }
                                      );
        }
        private void RefreshEventStream()
        {
            var patients = Enumerable.Range(1, 10).Select(_ => Guid.NewGuid()).ToList();

            _events = Enumerable.Range(1, 100).Select(i =>
            {
                var patientId = patients.RandomElementUsing(_random);
                var status    = IEnumerableExtensions.RandomEnumValue <CheckInStatus>(_random);
                var date      = new Bogus.DataSets.Date().Between(DateTime.Today.AddYears(-1), DateTime.Today);
                return(CheckInEventFactory.Create(patientId, status, date));
            }).ToList();
        }
예제 #3
0
        private static Transaction CreateTransaction()
        {
            var timestamp = new Bogus.DataSets.Date();
            var rand      = new Randomizer();

            int accIdFrom = rand.Number(1, 12);
            int accIdTo   = rand.Number(1, 12); //Contraint that check accIdFrom and accIdTo added in SSMS

            return(new Transaction()
            {
                TimeStamp = timestamp.Recent(100).ToString(),
                AccIdFrom = accIdFrom,
                AccIdTo = accIdTo,
                Amount = rand.Number(1, 999999),
                Description = string.Format("From {0} to {1}", accIdFrom, accIdTo)
            });
        }
예제 #4
0
        public Employee()
        {
            var person = new Person();

            UserName    = person.UserName;
            FirstName   = person.FirstName;
            LastName    = person.LastName;
            Email       = person.Email;
            Phone       = person.Phone;
            DateOfBirth = person.DateOfBirth;

            var bogusRandom = new Bogus.Randomizer();
            var bogusDate   = new Bogus.DataSets.Date();

            DateHired       = bogusDate.Between(DateTime.Today.AddYears(-5), DateTime.Today);
            DateContractEnd = bogusDate.Between(DateTime.Today, DateTime.Today.AddYears(-5));
            ChildrenCount   = bogusRandom.Int(0, 6);
            ShoeSize        = bogusRandom.Double(7, 12);
            ChangeInPocket  = bogusRandom.Double(0, 5);
            CarValue        = bogusRandom.Double(500, 40000);
        }
예제 #5
0
        static void Main(string[] args)
        {
            try
            {
                string apiUrlKey = "apiUrl";
                string input;
                var    random     = new Randomizer();
                var    randomDate = new Bogus.DataSets.Date();

                var apiUrl     = ConfigurationManager.AppSettings[apiUrlKey];
                var restClient = new RestClient(apiUrl);

                Console.WriteLine("Press ENTER without specifying value to exit...\n\n");
                Console.WriteLine("How many request models you want to send? Type in number: ");

                while (!string.IsNullOrEmpty(input = Console.ReadLine()))
                {
                    var result = 0;
                    var parsed = int.TryParse(input, out result);

                    if (!parsed)
                    {
                        Console.WriteLine("Value you've entered is not valid INT");
                    }
                    else
                    {
                        for (var i = 0; i < result; i++)
                        {
                            Console.WriteLine($"Sending request no. {i}...");

                            var request = new RestSharp.RestRequest("data", Method.POST);
                            request.JsonSerializer = new NewtonsoftJsonSerializer();

                            request.AddJsonBody(new RequestModel[] { new RequestModel
                                                                     {
                                                                         Index  = random.Int(0, int.MaxValue),
                                                                         Date   = randomDate.Future(),
                                                                         Name   = random.String2(20),
                                                                         Visits = random.Int(0, int.MaxValue),
                                                                     } });

                            var response = restClient.Execute(request);

                            if (response.StatusCode == System.Net.HttpStatusCode.Created)
                            {
                                Console.WriteLine($"Request no. {i} sent succesfully.");
                            }
                            else
                            {
                                throw new Exception($"Got status code <{response.StatusCode}> instead of <{System.Net.HttpStatusCode.Created}>.");
                            }
                        }

                        Console.WriteLine("Finished sending requests to API!");
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine($"Exception occured: {e}");
                Console.WriteLine("Press any key to exit...");
                Console.ReadKey();
            }
        }