12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- using Microsoft.VisualStudio.TestTools.UnitTesting;
- using BookStore;
- namespace BookStoreTest
- {
- public class BST
- {
- public static MainWindow w = new MainWindow();
- public static string[] tb = { "Name", "0", "Author", "Category" };
- public static void Text(string i)
- {
- w.TbName.Text = tb[0] + i;
- w.TbPrice.Text = tb[1];
- w.TbAuthor.Text = tb[2] + i;
- w.TbCategory.Text = tb[3] + i;
- }
- }
- [TestClass]
- public class BookStoreTest
- {
- [TestMethod]
- public void Test1_Insert()
- {
- int c = BST.w.BooksGrid.Items.Count;
- BST.Text(""); BST.w.BIC(); // Добавление строки
- Assert.AreEqual(c + 1, BST.w.BooksGrid.Items.Count); // Проверка добавления строки
- BST.w.TbClear(); BST.w.BooksGrid.SelectedIndex = BST.w.BooksGrid.Items.Count - 1; // Выбор добавленной строки
- Assert.AreEqual(BST.tb[0], BST.w.TbName.Text); // Проверки корректности добавления
- Assert.AreEqual(BST.tb[1], BST.w.TbPrice.Text);
- Assert.AreEqual(BST.tb[2], BST.w.TbAuthor.Text);
- Assert.AreEqual(BST.tb[3], BST.w.TbCategory.Text);
- }
- [TestMethod]
- public void Test2_Update()
- {
- int c = BST.w.BooksGrid.Items.Count;
- BST.w.BooksGrid.SelectedIndex = BST.w.BooksGrid.Items.Count - 1;
- BST.Text("2");
- BST.w.BUC(); BST.w.TbClear(); BST.w.BGSC();
- Assert.AreEqual(c, BST.w.BooksGrid.Items.Count); // Проверка отсутствия новых строк
- Assert.AreEqual(BST.tb[0] + "2", BST.w.TbName.Text); // Проверки корректности обновления
- Assert.AreEqual(BST.tb[1], BST.w.TbPrice.Text);
- Assert.AreEqual(BST.tb[2] + "2", BST.w.TbAuthor.Text);
- Assert.AreEqual(BST.tb[3] + "2", BST.w.TbCategory.Text);
- }
- [TestMethod]
- public void Test3_Delete()
- {
- int c = BST.w.BooksGrid.Items.Count;
- BST.w.BooksGrid.SelectedIndex = BST.w.BooksGrid.Items.Count - 1; BST.w.BDC();
- Assert.AreEqual(c - 1, BST.w.BooksGrid.Items.Count); // Проверка удаления строки
- }
- }
- }
|