themkss

Untitled

Apr 13th, 2023
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.50 KB | None | 0 0
  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using OP2_LB2;
  3.  
  4. namespace LinkedListTests
  5. {
  6.     [TestClass]
  7.     public class UnitTest1
  8.     {
  9.         [TestMethod]
  10.         public void ConstructorTest()
  11.         {
  12.             string a = "Pirmas";
  13.             (double, double) b = (10, 25);
  14.             (double, double) c = (15, 25);
  15.  
  16.             Rectangle rectangle = new Rectangle(a, b, c);
  17.  
  18.             Assert.IsNotNull(rectangle);
  19.             Assert.AreEqual(a, rectangle.name);
  20.             Assert.AreEqual(b, rectangle.topLeftCoord);
  21.             Assert.AreEqual(c, rectangle.bottomRightCoord);
  22.         }
  23.  
  24.         [TestMethod]
  25.         public void AddTest()
  26.         {
  27.             LinkedList<Rectangle> RectangleList = new LinkedList<Rectangle>();
  28.  
  29.             Rectangle rectangle1 = new Rectangle("Pirmas", (10, 25), (15, 25));
  30.             Rectangle rectangle2 = new Rectangle("Antras", (10, 25), (15, 25));
  31.  
  32.             RectangleList.Add(rectangle1);
  33.             RectangleList.Add(rectangle2);
  34.  
  35.             RectangleList.Begin();
  36.             Assert.AreEqual(rectangle1, RectangleList.Get());
  37.         }
  38.  
  39.         [TestMethod()]
  40.         public void SortTest()
  41.         {
  42.             LinkedList<Rectangle> RectangleList = new LinkedList<Rectangle>();
  43.             Rectangle rectangle1 = new Rectangle("B    Pirmas", (10, 25), (15, 25));
  44.             Rectangle rectangle2 = new Rectangle("A    Antras", (10, 25), (15, 25));
  45.             Rectangle rectangle3 = new Rectangle("C    Treฤias", (10, 25), (15, 25));
  46.  
  47.             RectangleList.Add(rectangle1);
  48.             RectangleList.Add(rectangle2);
  49.             RectangleList.Add(rectangle3);
  50.  
  51.             RectangleList.Begin();
  52.             RectangleList.Sort();
  53.  
  54.             Assert.AreEqual(rectangle2, RectangleList.Get());
  55.             RectangleList.Next();
  56.             Assert.AreEqual(rectangle1, RectangleList.Get());
  57.             RectangleList.Next();
  58.             Assert.AreEqual(rectangle3, RectangleList.Get());
  59.         }
  60.  
  61.         [TestMethod()]
  62.         public void CountTest()
  63.         {
  64.             LinkedList<Rectangle> RectangleList = new LinkedList<Rectangle>();
  65.  
  66.             Rectangle rectangle1 = new Rectangle("B    Pirmas", (10, 25), (15, 25));
  67.             Rectangle rectangle2 = new Rectangle("A    Antras", (10, 25), (15, 25));
  68.             Rectangle rectangle3 = new Rectangle("C    Treฤias", (10, 25), (15, 25));
  69.  
  70.             RectangleList.Add(rectangle1);
  71.             RectangleList.Add(rectangle2);
  72.             RectangleList.Add(rectangle3);
  73.  
  74.             Assert.AreEqual(RectangleList.Count(), 3);
  75.         }
  76.  
  77.         [TestMethod()]
  78.         public void BeginTest()
  79.         {
  80.             LinkedList<Rectangle> RectangleList = new LinkedList<Rectangle>();
  81.  
  82.             Rectangle rectangle1 = new Rectangle("B    Pirmas", (10, 25), (15, 25));
  83.  
  84.             RectangleList.Add(rectangle1);
  85.             RectangleList.Begin();
  86.  
  87.             Assert.AreEqual(rectangle1, RectangleList.Get());
  88.         }
  89.  
  90.         [TestMethod()]
  91.         public void NextTest()
  92.         {
  93.             LinkedList<Rectangle> RectangleList = new LinkedList<Rectangle>();
  94.  
  95.             Rectangle rectangle1 = new Rectangle("B    Pirmas", (10, 25), (15, 25));
  96.             Rectangle rectangle2 = new Rectangle("A    Antras", (10, 25), (15, 25));
  97.  
  98.             RectangleList.Add(rectangle1);
  99.             RectangleList.Add(rectangle2);
  100.  
  101.             RectangleList.Begin();
  102.             RectangleList.Next();
  103.  
  104.             Assert.AreEqual(rectangle2, RectangleList.Get());
  105.         }
  106.  
  107.         [TestMethod()]
  108.         public void ExistsTest()
  109.         {
  110.             LinkedList<Rectangle> RectangleList = new LinkedList<Rectangle>();
  111.  
  112.             Rectangle rectangle1 = new Rectangle("B    Pirmas", (10, 25), (15, 25));
  113.             Rectangle rectangle2 = new Rectangle("A    Antras", (10, 25), (15, 25));
  114.  
  115.             RectangleList.Add(rectangle1);
  116.             RectangleList.Add(rectangle2);
  117.  
  118.             RectangleList.Begin();
  119.  
  120.             Assert.AreEqual(RectangleList.Exists(), true);
  121.         }
  122.  
  123.         [TestMethod()]
  124.         public void GetTest()
  125.         {
  126.             LinkedList<Rectangle> RectangleList = new LinkedList<Rectangle>();
  127.  
  128.             Rectangle rectangle1 = new Rectangle("B    Pirmas", (10, 25), (15, 25));
  129.             Rectangle rectangle2 = new Rectangle("A    Antras", (10, 25), (15, 25));
  130.  
  131.             RectangleList.Add(rectangle1);
  132.             RectangleList.Add(rectangle2);
  133.  
  134.             RectangleList.Begin();
  135.             RectangleList.Next();
  136.  
  137.             Assert.AreEqual(rectangle2, RectangleList.Get());
  138.         }
  139.  
  140.         [TestMethod()]
  141.         public void IsEmptyTest()
  142.         {
  143.             LinkedList<Rectangle> RectangleList = new LinkedList<Rectangle>();
  144.  
  145.             RectangleList.Begin();
  146.  
  147.             Assert.AreEqual(RectangleList.IsEmpty(), true);
  148.         }
  149.  
  150.         [TestMethod()]
  151.         public void GetEnumeratorTest()
  152.         {
  153.  
  154.             LinkedList<Rectangle> RectangleList = new LinkedList<Rectangle>();
  155.             Rectangle rectangle1 = new Rectangle("B    Pirmas", (10, 25), (15, 25));
  156.             Rectangle rectangle2 = new Rectangle("A    Antras", (10, 25), (15, 25));
  157.  
  158.             RectangleList.Add(rectangle1);
  159.             RectangleList.Add(rectangle2);
  160.  
  161.             RectangleList.Begin();
  162.             foreach (Rectangle rectangle in RectangleList)
  163.             {
  164.                 Assert.AreEqual(rectangle, RectangleList.Get());
  165.                 RectangleList.Next();
  166.             }
  167.         }
  168.     }
  169. }
  170.  
Add Comment
Please, Sign In to add comment