using NUnit.Framework;
using Rhino.Mocks;

namespace IoCConcepts.Tests {
    [TestFixture]
    public class OrderControllerTests {
        [Test]
        public void WhenTheOrderScreenIsRequestedItWillDisplayTheOrder() {
            // arrange
            var orderRepository = MockRepository.GenerateMock<IOrderRepository>();
            var orderController = new OrderController(orderRepository);

            // act
            var result = orderController.Index();

            // assert
            Assert.That(result, Is.EqualTo("success"));
            orderRepository.AssertWasCalled(x => x.FindAll());
        }
    }

    public class OrderController {
        private readonly IOrderRepository orderRepository;

        public OrderController(IOrderRepository orderRepository) {
            this.orderRepository = orderRepository;
        }

        public string Index() {
            throw new System.NotImplementedException();
        }
    }

    public interface IOrderRepository {
        void FindAll();
    }
}