summaryrefslogtreecommitdiff
path: root/Calculator/src/test/Calculator.Test/presentation/commands/AppendDigitCommandTest.cs
blob: c39e59f935eb27d8b44e1d019ecfaea459381e6e (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
using Calculator.Domain;
using Calculator.Infrastructure;
using Calculator.Presentation.Commands;
using MbUnit.Framework;
using Rhino.Mocks;

namespace Calculator.Test.presentation.commands
{
    [TestFixture]
    public class AppendDigitCommandTest
    {
        private MockRepository mockery;
        private INumberBuilder builder;

        [SetUp]
        public void Setup()
        {
            mockery = new MockRepository();
            builder = mockery.DynamicMock<INumberBuilder>();
        }

        private ICommand CreateSUT(IDigit digit)
        {
            return new AppendDigitCommand(builder, digit);
        }

        [Test]
        public void should_append_digit_when_command_is_executed()
        {
            IDigit digit = mockery.DynamicMock<IDigit>();
            using (mockery.Record())
            {
                builder.Append(digit);
            }

            using (mockery.Playback())
            {
                CreateSUT(digit).Execute();
            }
        }
    }
}