using System; using Xunit; 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; } } public class BookStoreTest { [StaFact] public void Test1_Insert() { int c = BST.w.BooksGrid.Items.Count; BST.Text(""); BST.w.BIC(); // Добавление строки Assert.Equal(c + 1, BST.w.BooksGrid.Items.Count); // Проверка добавления строки BST.w.TbClear(); BST.w.BooksGrid.SelectedIndex = BST.w.BooksGrid.Items.Count - 1; // Выбор добавленной строки Assert.Equal(BST.tb[0], BST.w.TbName.Text); // Проверки корректности добавления Assert.Equal(BST.tb[1], BST.w.TbPrice.Text); Assert.Equal(BST.tb[2], BST.w.TbAuthor.Text); Assert.Equal(BST.tb[3], BST.w.TbCategory.Text); } [StaFact] 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.Equal(c, BST.w.BooksGrid.Items.Count); // Проверка отсутствия новых строк Assert.Equal(BST.tb[0] + "2", BST.w.TbName.Text); // Проверки корректности обновления Assert.Equal(BST.tb[1], BST.w.TbPrice.Text); Assert.Equal(BST.tb[2] + "2", BST.w.TbAuthor.Text); Assert.Equal(BST.tb[3] + "2", BST.w.TbCategory.Text); } [StaFact] 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.Equal(c - 1, BST.w.BooksGrid.Items.Count); // Проверка удаления строки } } }