summaryrefslogtreecommitdiff
path: root/dsa/NUnitTestProject1/Auxiliary/DiceTests.cs
blob: 6b37492188174a6e11c59ef283955e39f363f65f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using DSALib.Auxiliary;
using Moq;
using NUnit.Framework;
using System;

namespace NUnitTest.Auxiliary
{
    [TestFixture]
    public class DiceTests
    {
        private MockRepository mockRepository;



        [SetUp]
        public void SetUp()
        {
            this.mockRepository = new MockRepository(MockBehavior.Strict);


        }

        [TearDown]
        public void TearDown()
        {
            this.mockRepository.VerifyAll();
        }

        private void CreateDice()
        {}

        [Test]
        public void Roll_StateUnderTest_ExpectedBehavior()
        {
            // Arrange
            int d = 20;

            // Act
            var result = Dice.Roll(d);

            // Assert
            Assert.True(result > 0 && result < d+1);
        }

        [Test]
        public void Roll_StateUnderTest_ExpectedBehavior1()
        {
            // Arrange
            string input = "w";

            // Act
            Assert.Throws<ArgumentException>( () => Dice.Roll(input));
        }

        [Test]
        public void Roll_zero_dice()
        {
            // Arrange
            int count = 0;
            int d = 2;

            // Act
            var result = Dice.Roll(
                count,
                d);

            // Assert
            Assert.AreEqual(0, result);
        }
    }
}