using System; using Microsoft.VisualStudio.TestTools.UnitTesting; using boo; using System.Linq; namespace UnitTestProject1 { [TestClass] public class UnitTest1 { BookStoreContext _context = new BookStoreContext(); [TestMethod] public void TestMethod1() { var page = new MainWindow(); string name, price, category, author; int exp, res; //1 name = "Обещание"; author = "Юрайан Кониецко"; price = "550"; category = "Комикс"; exp = _context.Books.Where(b => b.Name == name && b.Price == 550 && b.Author == author && b.Category == category).Count() + 1; Assert.IsTrue(page.InsertBook(name, price, author, category)); res = _context.Books.Where(b => b.Name == name && b.Price == 550 && b.Author == author && b.Category == category).Count(); Assert.AreEqual(exp, res); Books book = _context.Books.Where(b => b.Name == name && b.Price == 550 && b.Author == author && b.Category == category).FirstOrDefault(); _context.Books.Remove(book); _context.SaveChanges(); //2 name = ""; author = ""; price = ""; category = ""; exp = _context.Books.Count(); Assert.IsFalse(page.InsertBook(name, price, author, category)); res = _context.Books.Count(); Assert.AreEqual(exp, res); } } }