Beispiel #1
0
        static void Main(string[] args)
        {
            var commands = new[]
            {
                "cleanDatabase",
                "createTestData"
            };

            if (args.Length == 0)
            {
                Console.WriteLine($"Using {AppDomain.CurrentDomain.FriendlyName} {{{commands.ConcatArrayItems('|')}}}");

                return;
            }

            var db = new DataBaseMicrosoft(SolutionConfiguration.DatabaseType, SolutionConfiguration.DatabaseArguments);

            var @switch = new Dictionary<string, Action>
            {
                {
                    commands[0], () =>
                    {
                        db.CleanDataBase();
                    }
                },
                {
                    commands[1], () =>
                    {
                        var types = AppDomain.CurrentDomain.GetAssemblies()
                            .SelectMany(s => s.GetTypes())
                            .Where(p => typeof(ICommandInsert).IsAssignableFrom(p))
                            .ToArray()
                            .Sort();

                        foreach (var type in types)
                        {
                            type.GetMethod(nameof(ICommandInsert.Execute)).Invoke(Activator.CreateInstance(type), new object[] { db });
                        }
                    }
                }
            };

            Action action;

            if (@switch.TryGetValue(args[0], out action))
            {
                action();
            }
            else
            {
                Console.WriteLine("Incorrect command");
            }
        }
Beispiel #2
0
        public void Execute(Dictionary<string, List<string[]>> dictionary)
        {
            const string nameTest = nameof(GroupTest);

            dictionary[nameTest].Add(new[] { "Group count", "People count" });

            var goupCounts = new[]
            {
                5,
                10,
                50
            };
            var peopleCounts = new[]
            {
                5,
                50,
                100
            };

            foreach (var goupCount in goupCounts)
            {
                foreach (var peopleCount in peopleCounts)
                {
                    var db = new DataBaseMicrosoft(DataBasesTypes.MicrosoftAccess, TestHelper.CreateTempFile());
                    var watch = new Stopwatch();
                    var position = Guid.NewGuid().ToString();
                    var groups = GenerateGroupsWithPeoples(goupCount, peopleCount, position);

                    db.CleanDataBase();
                    db.InsertPosition(position);

                    watch.Start();

                    foreach (var group in groups)
                    {
                        db.ExecuteCommand(Parameters.Insert, group);
                    }

                    watch.Stop();

                    dictionary[nameTest].Add(new[] { $"{goupCount}", $"{peopleCount}", $"{watch.Elapsed.TotalMilliseconds}" });
                }
            }
        }