Beispiel #1
0
        public void TestAtBrevhovedGetByNummerKasterIntranetRepositoryExceptionHvisBrevhovedIkkeFindes()
        {
            var fixture              = new Fixture();
            var objectMapperMock     = MockRepository.GenerateMock <IObjectMapper>();
            var exceptionBuilderMock = MockRepository.GenerateMock <IExceptionBuilder>();

            var brevhoveder          = fixture.CreateMany <Brevhoved>(3).ToList();
            var fællesRepositoryMock = MockRepository.GenerateMock <IFællesRepository>();

            fællesRepositoryMock.Expect(m => m.BrevhovedGetAll())
            .Return(brevhoveder)
            .Repeat.Any();

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

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

            var exception = Assert.Throws <IntranetRepositoryException>(() => commandHandler.BrevhovedGetByNummer(-1));

            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(Brevhoved).Name, -1)));
            Assert.That(exception.InnerException, Is.Not.Null);
            Assert.That(exception.InnerException, Is.TypeOf <InvalidOperationException>());
        }
Beispiel #2
0
        public void TestAtBrevhovedGetByNummerHenterBrevhoved()
        {
            var fixture              = new Fixture();
            var objectMapperMock     = MockRepository.GenerateMock <IObjectMapper>();
            var exceptionBuilderMock = MockRepository.GenerateMock <IExceptionBuilder>();

            var brevhoveder          = fixture.CreateMany <Brevhoved>(3).ToList();
            var fællesRepositoryMock = MockRepository.GenerateMock <IFællesRepository>();

            fællesRepositoryMock.Expect(m => m.BrevhovedGetAll())
            .Return(brevhoveder)
            .Repeat.Any();

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

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

            var brevhoved = commandHandler.BrevhovedGetByNummer(brevhoveder.ElementAt(1).Nummer);

            Assert.That(brevhoved, Is.Not.Null);
            Assert.That(brevhoved.Nummer, Is.EqualTo(brevhoveder.ElementAt(1).Nummer));
        }