Добавил тесты на 100 создания и удаления

This commit is contained in:
Леонид Малафеев 2024-05-02 17:55:35 +04:00
parent 21ca8bae11
commit 5f3fdedbf6
15 changed files with 68 additions and 1 deletions

Binary file not shown.

View File

@ -34,6 +34,8 @@
мемберToolStripMenuItem = new ToolStripMenuItem();
рекордыToolStripMenuItem = new ToolStripMenuItem();
результатыToolStripMenuItem = new ToolStripMenuItem();
buttonTest1 = new Button();
button1 = new Button();
menuStrip1.SuspendLayout();
SuspendLayout();
//
@ -81,11 +83,33 @@
результатыToolStripMenuItem.Text = "Результаты";
результатыToolStripMenuItem.Click += ResultsToolStripMenuItem_Click;
//
// buttonTest1
//
buttonTest1.Location = new Point(12, 52);
buttonTest1.Name = "buttonTest1";
buttonTest1.Size = new Size(133, 39);
buttonTest1.TabIndex = 2;
buttonTest1.Text = "Создать 100 соревнований";
buttonTest1.UseVisualStyleBackColor = true;
buttonTest1.Click += buttonTest1_Click;
//
// button1
//
button1.Location = new Point(12, 117);
button1.Name = "button1";
button1.Size = new Size(133, 39);
button1.TabIndex = 3;
button1.Text = "Удалить 100 соревнований";
button1.UseVisualStyleBackColor = true;
button1.Click += buttonTest2_Click;
//
// FormMain
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 334);
Controls.Add(button1);
Controls.Add(buttonTest1);
Controls.Add(menuStrip1);
MainMenuStrip = menuStrip1;
Name = "FormMain";
@ -103,5 +127,7 @@
private ToolStripMenuItem мемберToolStripMenuItem;
private ToolStripMenuItem рекордыToolStripMenuItem;
private ToolStripMenuItem результатыToolStripMenuItem;
private Button buttonTest1;
private Button button1;
}
}

View File

@ -1,3 +1,5 @@
using SportCompetitionsContracts.BindingModels;
using SportCompetitionsContracts.BusinessLogicsContracts;
using System;
using System.Collections.Generic;
using System.ComponentModel;
@ -12,9 +14,13 @@ namespace SportCompetitionsView
{
public partial class FormMain : Form
{
public FormMain()
private ICompetitionLogic _logicC;
private ITeamLogic _logicT;
public FormMain(ITeamLogic logicT, ICompetitionLogic logicC)
{
InitializeComponent();
_logicT = logicT;
_logicC = logicC;
}
private void CompetitionToolStripMenuItem_Click(object sender, EventArgs e)
@ -60,5 +66,40 @@ namespace SportCompetitionsView
form.ShowDialog();
}
}
private void buttonTest1_Click(object sender, EventArgs e)
{
DateTime startCreation = DateTime.Now;
for (int i = 1; i <= 100; i++)
{
CompetitionBindingModel model = new CompetitionBindingModel()
{
Id = i + 100,
CompetitionName = "Ñîðåâíîâàíèå " + i,
CompetitionDateHolding = DateTime.Now,
CompetitionCity = "Ãîðîä " + i
};
_logicC.Create(model);
}
DateTime stopCreation = DateTime.Now;
TimeSpan creationTime = stopCreation - startCreation;
MessageBox.Show($"Âðåìÿ ñîçäàíèÿ: {creationTime}", "Test", MessageBoxButtons.OK);
}
private void buttonTest2_Click(object sender, EventArgs e)
{
DateTime startDeletion = DateTime.Now;
for (int i = 1; i <= 100; i++)
{
_logicC.Delete(new CompetitionBindingModel { Id = i + 100 });
}
DateTime stopDeletion = DateTime.Now;
TimeSpan deletionTime = stopDeletion - startDeletion;
MessageBox.Show($"Âðåìÿ óäàëåíèÿ: {deletionTime}", "Test", MessageBoxButtons.OK);
}
}
}

Binary file not shown.