Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
655
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.54 KB | None | 0 0
  1. using NUnit.Framework;
  2.  
  3. namespace Tests
  4. {
  5.     using FightingArena;
  6.     using System;
  7.     using System.Collections.Generic;
  8.  
  9.     public class ArenaTests
  10.     {
  11.         private Warrior gosho;
  12.         private Warrior pesho;
  13.  
  14.         [SetUp]
  15.         public void Setup()
  16.         {
  17.             gosho = new Warrior("Gosho", 25, 35);
  18.             pesho = new Warrior("Pesho", 20, 60);
  19.         }
  20.  
  21.         [Test]
  22.         public void Arena_Constr()
  23.         {
  24.             Arena arena = new Arena();
  25.             var list = new List<Warrior>();
  26.             CollectionAssert.AreEqual(list, arena.Warriors);
  27.         }
  28.  
  29.         [Test]
  30.         public void Arena_Enroll_InvalidOperationException_WarriorAlreadyEnrolled()
  31.         {
  32.             Arena arena = new Arena();
  33.             arena.Enroll(gosho);
  34.             Assert.Throws<InvalidOperationException>
  35.                 (() => arena.Enroll(gosho));
  36.         }
  37.  
  38.         [Test]
  39.         public void Arena_Enroll_CorrectList()
  40.         {
  41.             Arena arena = new Arena();
  42.             arena.Enroll(gosho);
  43.             arena.Enroll(pesho);
  44.  
  45.             var expected = new List<Warrior> { gosho, pesho };
  46.  
  47.             CollectionAssert.AreEqual(expected, arena.Warriors);
  48.         }
  49.  
  50.         [Test]
  51.         public void Arena_Enroll_CorrectList_Count()
  52.         {
  53.             Arena arena = new Arena();
  54.             arena.Enroll(gosho);
  55.             arena.Enroll(pesho);
  56.  
  57.             var expected = new List<Warrior> { gosho, pesho }.Count;
  58.             var actual = arena.Count;
  59.             Assert.AreEqual(expected, actual);
  60.         }
  61.  
  62.         [Test]
  63.         public void Arena_Fight_InvalidOperationException_DefenderNotEnrolled()
  64.         {
  65.             Arena arena = new Arena();
  66.             arena.Enroll(gosho);
  67.             Assert.Throws<InvalidOperationException>
  68.                 (() => arena.Fight("Gosho", "Pesho"));
  69.         }
  70.  
  71.         [Test]
  72.         public void Arena_Fight_InvalidOperationException_AttackerNotEnrolled()
  73.         {
  74.             Arena arena = new Arena();
  75.             arena.Enroll(pesho);
  76.             Assert.Throws<InvalidOperationException>
  77.                 (() => arena.Fight("Gosho", "Pesho"));
  78.         }
  79.  
  80.         [Test]
  81.         public void Fight_Correctly()
  82.         {
  83.             Arena arena = new Arena();
  84.             arena.Enroll(gosho);
  85.             arena.Enroll(pesho);
  86.  
  87.             arena.Fight("Gosho", "Pesho");
  88.  
  89.             var expectedPeshoHp = 35;
  90.             var actual = pesho.HP;
  91.             Assert.AreEqual(expectedPeshoHp, actual);
  92.         }
  93.     }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement