public void TestAtSystemGetByNummerHenterSystem()
        {
            var fixture = new Fixture();

            fixture.Customize <ISystem>(e => e.FromFactory(() =>
            {
                var systemMock = MockRepository.GenerateMock <ISystem>();
                systemMock.Stub(m => m.Nummer)
                .Return(fixture.Create <int>())
                .Repeat.Any();
                return(systemMock);
            }));
            var kalenderRepositoryMock = MockRepository.GenerateMock <IKalenderRepository>();
            var objectMapperMock       = MockRepository.GenerateMock <IObjectMapper>();
            var exceptionBuilderMock   = MockRepository.GenerateMock <IExceptionBuilder>();

            var systemer             = fixture.CreateMany <ISystem>(4).ToList();
            var fællesRepositoryMock = MockRepository.GenerateMock <IFællesRepository>();

            fællesRepositoryMock.Expect(m => m.SystemGetAll())
            .Return(systemer)
            .Repeat.Any();

            var commandHandler = new MyKalenderCommandHandler(kalenderRepositoryMock, fællesRepositoryMock, objectMapperMock, exceptionBuilderMock);

            Assert.That(commandHandler, Is.Not.Null);

            var result = commandHandler.SystemGetByNummer(systemer.ElementAt(1).Nummer);

            Assert.That(result, Is.Not.Null);
            Assert.That(result.Nummer, Is.EqualTo(systemer.ElementAt(1).Nummer));

            fællesRepositoryMock.AssertWasCalled(m => m.SystemGetAll());
        }
        public void TestAtSystemGetByNummerKasterIntranetRepositoryExceptionHvisSystemIkkeFindes()
        {
            var fixture = new Fixture();

            fixture.Customize <ISystem>(e => e.FromFactory(() =>
            {
                var systemMock = MockRepository.GenerateMock <ISystem>();
                systemMock.Stub(m => m.Nummer)
                .Return(fixture.Create <int>())
                .Repeat.Any();
                return(systemMock);
            }));
            var kalenderRepositoryMock = MockRepository.GenerateMock <IKalenderRepository>();
            var objectMapperMock       = MockRepository.GenerateMock <IObjectMapper>();
            var exceptionBuilderMock   = MockRepository.GenerateMock <IExceptionBuilder>();

            var systemer             = fixture.CreateMany <ISystem>(4).ToList();
            var fællesRepositoryMock = MockRepository.GenerateMock <IFællesRepository>();

            fællesRepositoryMock.Expect(m => m.SystemGetAll())
            .Return(systemer)
            .Repeat.Any();

            var commandHandler = new MyKalenderCommandHandler(kalenderRepositoryMock, fællesRepositoryMock, objectMapperMock, exceptionBuilderMock);

            Assert.That(commandHandler, Is.Not.Null);

            var systemNummer = fixture.Create <int>();
            var exception    = Assert.Throws <IntranetRepositoryException>(() => commandHandler.SystemGetByNummer(systemNummer));

            Assert.That(exception, Is.Not.Null);
            Assert.That(exception.Message, Is.Not.Null);
            Assert.That(exception.Message, Is.Not.Empty);
            Assert.That(exception.Message, Is.EqualTo(Resource.GetExceptionMessage(ExceptionMessage.CantFindObjectById, typeof(ISystem).Name, systemNummer)));
            Assert.That(exception.InnerException, Is.Not.Null);
            Assert.That(exception.InnerException, Is.TypeOf <InvalidOperationException>());

            fællesRepositoryMock.AssertWasCalled(m => m.SystemGetAll());
        }