Advertisement
BSO90

Untitled

Aug 9th, 2021
1,078
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.03 KB | None | 0 0
  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using TaskManegementSystemCore;
  8. using TaskManegementSystemOperations;
  9. using TaskManegementSystemOperations.Commands;
  10.  
  11. namespace Operations_Tests
  12. {
  13.     [TestClass]
  14.     public class Show_All_People_Test
  15.     {
  16.         [TestMethod]
  17.         public void ConstructurShouldCallBaseClass()
  18.         {
  19.             Repository repository = new Repository();
  20.  
  21.             Show_All_People command = new Show_All_People(repository);
  22.  
  23.             Assert.AreEqual(repository, command.Repository);
  24.         }
  25.  
  26.         [TestMethod]
  27.         public void ExecuteShouldCallMethod()
  28.         {
  29.             Repository repository = new Repository();
  30.  
  31.             Show_All_People command = new Show_All_People(repository);
  32.  
  33.             Create_Person person1 = new Create_Person(repository);
  34.  
  35.             person1.Repository.CreatePerson("peshko");
  36.  
  37.             Assert.AreEqual(command.ShowAllPeople(), command.Execute());
  38.  
  39.         }
  40.  
  41.         [TestMethod]
  42.         public void ShowAllPeopleShouldThrowWhenNoPeople()
  43.         {
  44.             Repository repository = new Repository();
  45.  
  46.             Show_All_People command = new Show_All_People(repository);
  47.  
  48.             Assert.ThrowsException<ArgumentException>(() => command.ShowAllPeople());
  49.         }
  50.  
  51.  
  52.         [TestMethod]
  53.         public void ShowAllPeopleShouldReturnAllPeople()
  54.         {
  55.             Repository repository = new Repository();
  56.  
  57.             Show_All_People command = new Show_All_People(repository);
  58.  
  59.             Create_Person person1 = new Create_Person(repository);
  60.  
  61.             person1.Repository.CreatePerson("peshko");
  62.             person1.Repository.CreatePerson("sashko");
  63.            
  64.             string expected = $"1. peshko\r\n2. sashko";  //  \r\n is enviroment new line
  65.             string current = command.ShowAllPeople();
  66.  
  67.             Assert.AreEqual(expected, current);
  68.         }
  69.  
  70.  
  71.  
  72.     }
  73. }
  74.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement