Advertisement
Anonim_999

UnitTest

May 4th, 2024
664
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 6.66 KB | None | 0 0
  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using Ticket13;
  3.  
  4. namespace AbonentPaymentTest
  5. {
  6.     [TestClass]
  7.     public class UnitTest1
  8.     {
  9.         #region EconomTest
  10.  
  11.         [TestMethod]
  12.         public void TestEconomSubscriptionNotPensioner() // Эконом + подписка
  13.         {
  14.             Teleradio.TVPack selectedPack = Teleradio.TVPack.Эконом;
  15.             bool subscription = true;
  16.             bool pensioner = false;
  17.             int expectedPayment = 400; // 300 (subscription) + 100 (Econom) = 400
  18.  
  19.             int actualPayment = Teleradio.AbonentPayment(selectedPack, subscription, pensioner);
  20.            
  21.             Assert.AreEqual(expectedPayment, actualPayment);
  22.         }
  23.  
  24.         [TestMethod]
  25.         public void TestEconomSubscriptionPensioner() // Эконом + подписка + пенсионер
  26.         {
  27.             Teleradio.TVPack selectedPack = Teleradio.TVPack.Эконом;
  28.             bool subscription = true;
  29.             bool pensioner = true;
  30.             int expectedPayment = 360; // 300 (subscription) + 100 (Econom) = 400, 400 * 0.9 = 360
  31.  
  32.             int actualPayment = Teleradio.AbonentPayment(selectedPack, subscription, pensioner);
  33.  
  34.             Assert.AreEqual(expectedPayment, actualPayment);
  35.         }
  36.  
  37.         [TestMethod]
  38.         public void TestEconomNoSubscriptionNotPensioner() // Эконом
  39.         {
  40.             Teleradio.TVPack selectedPack = Teleradio.TVPack.Эконом;
  41.             bool subscription = false;
  42.             bool pensioner = false;
  43.             int expectedPayment = 100; // 0 + 100 (Econom) = 100
  44.  
  45.             int actualPayment = Teleradio.AbonentPayment(selectedPack, subscription, pensioner);
  46.  
  47.             Assert.AreEqual(expectedPayment, actualPayment);
  48.         }
  49.  
  50.         [TestMethod]
  51.         public void TestEconomNoSubscriptionPensioner() // Эконом + пенсионер
  52.         {
  53.             Teleradio.TVPack selectedPack = Teleradio.TVPack.Эконом;
  54.             bool subscription = false;
  55.             bool pensioner = true;
  56.             int expectedPayment = 90; // 0 + 100 (Econom) = 100, 100 * 0.9 = 90
  57.  
  58.             int actualPayment = Teleradio.AbonentPayment(selectedPack, subscription, pensioner);
  59.  
  60.             Assert.AreEqual(expectedPayment, actualPayment);
  61.         }
  62.         #endregion
  63.  
  64.         #region MiniTest
  65.         [TestMethod]
  66.         public void TestMiniSubscriptionPensioner() // мини + подписка + пенсионер
  67.         {
  68.             Teleradio.TVPack selectedPack = Teleradio.TVPack.Мини;
  69.             bool subscription = true;
  70.             bool pensioner = true;
  71.             int expectedPayment = 90; // 300 (subscription) - 200 (Mini) = 100, 100 * 0.9 = 90
  72.  
  73.             int actualPayment = Teleradio.AbonentPayment(selectedPack, subscription, pensioner);
  74.  
  75.             Assert.AreEqual(expectedPayment, actualPayment);
  76.         }
  77.  
  78.         [TestMethod]
  79.         public void TestMiniNoSubscriptionPensioner() // мини + пенсионер
  80.         {
  81.             Teleradio.TVPack selectedPack = Teleradio.TVPack.Мини;
  82.             bool subscription = false;
  83.             bool pensioner = true;
  84.             int expectedPayment = 0; // 0 (subscription) - 200 (Mini) = 0, 0 * 0.9 = 0
  85.  
  86.             int actualPayment = Teleradio.AbonentPayment(selectedPack, subscription, pensioner);
  87.  
  88.             Assert.AreEqual(expectedPayment, actualPayment);
  89.         }
  90.  
  91.         [TestMethod]
  92.         public void TestMiniSubscriptionNotPensioner() // мини + подписка
  93.         {
  94.             Teleradio.TVPack selectedPack = Teleradio.TVPack.Мини;
  95.             bool subscription = true;
  96.             bool pensioner = false;
  97.             int expectedPayment = 100; // 300 (subscription) - 200 (Mini) = 100
  98.  
  99.             int actualPayment = Teleradio.AbonentPayment(selectedPack, subscription, pensioner);
  100.  
  101.             Assert.AreEqual(expectedPayment, actualPayment);
  102.         }
  103.  
  104.         [TestMethod]
  105.         public void TestMiniNoSubscriptionNotPensioner() // мини
  106.         {
  107.             Teleradio.TVPack selectedPack = Teleradio.TVPack.Мини;
  108.             bool subscription = false;
  109.             bool pensioner = false;
  110.             int expectedPayment = 0; // 0 (subscription) - 200 (Mini) = 0
  111.  
  112.             int actualPayment = Teleradio.AbonentPayment(selectedPack, subscription, pensioner);
  113.  
  114.             Assert.AreEqual(expectedPayment, actualPayment);
  115.         }
  116.         #endregion
  117.  
  118.         #region UniversalTest
  119.         [TestMethod]
  120.         public void TestUniversalSubscriptionPensioner() // Универсал + подписка + пенсионер
  121.         {
  122.             Teleradio.TVPack selectedPack = Teleradio.TVPack.Универсал;
  123.             bool subscription = true;
  124.             bool pensioner = true;
  125.             int expectedPayment = 720; // 300 (subscription) + 500 (Universal) = 800, 800 * 0.9 = 720
  126.  
  127.             int actualPayment = Teleradio.AbonentPayment(selectedPack, subscription, pensioner);
  128.  
  129.             Assert.AreEqual(expectedPayment, actualPayment);
  130.         }
  131.  
  132.         [TestMethod]
  133.         public void TestUniversalSubscriptionNotPensioner() // Универсал + подписка
  134.         {
  135.             Teleradio.TVPack selectedPack = Teleradio.TVPack.Универсал;
  136.             bool subscription = true;
  137.             bool pensioner = false;
  138.             int expectedPayment = 800; // 300 (subscription) + 500 (Universal) = 800
  139.  
  140.             int actualPayment = Teleradio.AbonentPayment(selectedPack, subscription, pensioner);
  141.  
  142.             Assert.AreEqual(expectedPayment, actualPayment);
  143.         }
  144.  
  145.         [TestMethod]
  146.         public void TestUniversalNoSubscriptionPensioner() // Универсал + пенсионер
  147.         {
  148.             Teleradio.TVPack selectedPack = Teleradio.TVPack.Универсал;
  149.             bool subscription = false;
  150.             bool pensioner = true;
  151.             int expectedPayment = 450; // 0 + 500 (Universal) = 500, 500 * 0.9 = 450
  152.  
  153.             int actualPayment = Teleradio.AbonentPayment(selectedPack, subscription, pensioner);
  154.  
  155.             Assert.AreEqual(expectedPayment, actualPayment);
  156.         }
  157.  
  158.         [TestMethod]
  159.         public void TestUniversalNoSubscriptionNotPensioner() // Универсал
  160.         {
  161.             Teleradio.TVPack selectedPack = Teleradio.TVPack.Универсал;
  162.             bool subscription = false;
  163.             bool pensioner = false;
  164.             int expectedPayment = 500; // 0 + 500 (Universal) = 500
  165.  
  166.             int actualPayment = Teleradio.AbonentPayment(selectedPack, subscription, pensioner);
  167.  
  168.             Assert.AreEqual(expectedPayment, actualPayment);
  169.         }
  170.  
  171.         #endregion
  172.     }
  173. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement