UnitTest1.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using System;
  3. using NET;
  4. using System.Linq;
  5. namespace UnitTestProject1
  6. {
  7. [TestClass]
  8. public class InsertTest
  9. {
  10. BookStoreContext _context = new BookStoreContext();
  11. MainWindow page = new MainWindow();
  12. [TestMethod]
  13. public void Insert()
  14. {
  15. string name, price, author, category;
  16. name = "Токийские легенды";
  17. price = "566";
  18. author = "Харуки Мураками";
  19. category = "Сборник рассказов";
  20. Assert.IsTrue(page.Insert(name, price, author, category));
  21. Books book = _context.Books.Where(x => x.Name == name).FirstOrDefault();
  22. _context.Books.Remove(book);
  23. _context.SaveChanges();
  24. name = "Токийские легенды";
  25. price = "mems";
  26. author = "Харуки Мураками";
  27. category = "Сборник рассказов";
  28. Assert.IsFalse(page.Insert(name, price, author, category));
  29. }
  30. }
  31. }