public void Bfs_WhenDirectedGraphAndMultipleRoots_ThenAllVertices()
        {
            // given
            var strategy = new TestingStrategy <int>();
            // when
            IEnumerable <Vertex <int> > result =
                directedGraph.Bfs(strategy, new[] { directedGraph[8], directedGraph[6] });

            // then
            result.Should().BeEquivalentTo(directedGraph.Vertices);
            strategy.entries.Should().BeEquivalentTo(undirectedGraph.Vertices);
            strategy.exits.Should().BeEquivalentTo(undirectedGraph.Vertices);
        }
        public void DfsRecursive_WhenUndirectedGraphAndManyRoots_ThenAllVertices()
        {
            // given
            var strategy = new TestingStrategy <int>();
            // when
            IEnumerable <Vertex <int> > result =
                undirectedGraph.DfsRecursive(strategy, new[] { undirectedGraph[0], undirectedGraph[6] });

            // then
            result.Should().BeEquivalentTo(undirectedGraph.Vertices);
            strategy.entries.Should().BeEquivalentTo(undirectedGraph.Vertices);
            strategy.exits.Should().BeEquivalentTo(undirectedGraph.Vertices);
        }
Exemple #3
0
        public GeneratorTask(int virtualUsers, int timeout, int requestDuration,
                             int duration, TestingStrategy strategy, List <string> URLs, uint taskGroup, string owner, Client client)
        {
            _URLs = URLs;// ?? throw new NullReferenceException("URLs is null");

            if (_URLs.Count == 0)
            {
                throw new ArgumentException("URLs is empty");
            }

            VirtualUsers    = virtualUsers;
            Timeout         = timeout;
            RequestDuration = requestDuration;
            Duration        = duration;
            Strategy        = strategy;
            TaskGroup       = taskGroup;
            Owner           = owner;  // ?? throw new NullReferenceException("owner is null");
            _client         = client; // ?? throw new NullReferenceException("client is null");
        }
Exemple #4
0
        private async void beginTestingButton_Click(object sender, RoutedEventArgs e)
        {
            DisableButtons();

            try
            {
                List <string>   URLs            = new List <string>();
                int             virtualUsers    = int.Parse(virtualUsersControl.Text);
                int             timeout         = int.Parse(timeoutControl.Text);
                int             requestDuration = int.Parse(betweenControl.Text);
                int             duration        = int.Parse(durationControl.Text);;
                TestingStrategy strategy        = (TestingStrategy)strategyControl.SelectedIndex;

                foreach (var item in urlListControl.Items)
                {
                    URLs.Add((string)item);
                }

                if (URLs.Count == 0)
                {
                    MessageBox.Show("Список URL-адресов пустой.", "Ошибка");
                    EnableButtons();
                    return;
                }

                if (virtualUsers < 1 || timeout < 1 || requestDuration < 1 || duration < 1)
                {
                    throw new FormatException();
                }

                TaskData data = new TaskData()
                {
                    _URLs           = URLs,
                    VirtualUsers    = virtualUsers,
                    Timeout         = timeout,
                    RequestDuration = requestDuration,
                    Duration        = duration,
                    Strategy        = strategy
                };

                await DataStorage.RequestData(data);

                TaskCreationResult result = DataStorage.GetData <TaskCreationResult>();

                if (result != null && result.GroupNumber != 0)
                {
                    MonitoringWindow window = new MonitoringWindow();
                    window.ShowDialog();
                }
                else
                {
                    MessageBox.Show("Сервер отказал в выполнении задания.", "Ошибка");
                }

                EnableButtons();
            }
            catch (FormatException)
            {
                MessageBox.Show("Данные введены не верно.", "Ошибка");
                EnableButtons();
            }
            catch (TimeoutException)
            {
                MessageBox.Show("Сервер не ответил вовремя.", "Ошибка");
                Close();
                return;
            }
            catch (SocketException)
            {
                MessageBox.Show("Сервер не ответил вовремя.", "Ошибка");
                Close();
                return;
            }
        }
Exemple #5
0
        private async void saveProfileButton_Click(object sender, RoutedEventArgs e)
        {
            DisableButtons();

            try
            {
                List <string>   URLs            = new List <string>();
                int             virtualUsers    = int.Parse(virtualUsersControl.Text);
                int             timeout         = int.Parse(timeoutControl.Text);
                int             requestDuration = int.Parse(betweenControl.Text);
                int             duration        = int.Parse(durationControl.Text);;
                TestingStrategy strategy        = (TestingStrategy)strategyControl.SelectedIndex;
                string          name            = profileNameControl.Text;

                foreach (var item in urlListControl.Items)
                {
                    URLs.Add((string)item);
                }

                if (URLs.Count == 0)
                {
                    MessageBox.Show("Список URL-адресов пустой.", "Ошибка");
                    EnableButtons();
                    return;
                }

                if (virtualUsers < 1 || timeout < 1 || requestDuration < 1 || duration < 1 || name.Length < 1)
                {
                    throw new FormatException();
                }

                TaskData data = new TaskData()
                {
                    _URLs           = URLs,
                    VirtualUsers    = virtualUsers,
                    Timeout         = timeout,
                    RequestDuration = requestDuration,
                    Duration        = duration,
                    Strategy        = strategy
                };

                SaveProfileRequest request = new SaveProfileRequest()
                {
                    Name = name,
                    Data = data
                };

                await DataStorage.RequestData(request);

                var response = DataStorage.GetData <SaveProfileResponse>();

                if (response != null && response.Result == SaveProfileResult.NAME_EXISTS)
                {
                    MessageBox.Show("Введенное имя профиля уже существует.", "Ошибка");
                }
            }
            catch (FormatException)
            {
                MessageBox.Show("Данные введены не верно.", "Ошибка");
            }
            catch (TimeoutException)
            {
                MessageBox.Show("Сервер не ответил вовремя.", "Ошибка");
                Close();
                return;
            }
            catch (SocketException)
            {
                MessageBox.Show("Сервер не ответил вовремя.", "Ошибка");
                Close();
                return;
            }

            EnableButtons();
        }