public void TestAtBogføringslinjeAddKasterIntranetRepositoryExceptionVedException() { var fixture = new Fixture(); var mocker = new MockRepository(); var service = mocker.DynamicMultiMock <IFinansstyringRepositoryService>(new[] { typeof(ICommunicationObject) }); service.Expect(m => m.BogføringslinjeAdd(Arg <BogføringslinjeAddCommand> .Is.Anything)) .Throw(fixture.Create <Exception>()); Expect.Call(((ICommunicationObject)service).State).Return(CommunicationState.Closed); mocker.ReplayAll(); var channelFactory = MockRepository.GenerateMock <IChannelFactory>(); channelFactory.Expect(m => m.CreateChannel <IFinansstyringRepositoryService>(Arg <string> .Is.Anything)) .Return(service); var domainObjectBuilder = MockRepository.GenerateMock <IDomainObjectBuilder>(); var repository = new FinansstyringRepository(channelFactory, domainObjectBuilder); var konto = fixture.Create <Konto>(); Assert.Throws <IntranetRepositoryException>( () => repository.BogføringslinjeAdd(fixture.Create <DateTime>(), null, konto, fixture.Create <string>(), null, fixture.Create <decimal>(), fixture.Create <decimal>(), null)); }
public void TestAtBogføringslinjeAddKasterEnArgumentNullExceptionHvisTekstErNull() { var fixture = new Fixture(); var channelFactory = MockRepository.GenerateMock <IChannelFactory>(); var domainObjectBuilder = MockRepository.GenerateMock <IDomainObjectBuilder>(); var repository = new FinansstyringRepository(channelFactory, domainObjectBuilder); var konto = fixture.Create <Konto>(); Assert.Throws <ArgumentNullException>( () => repository.BogføringslinjeAdd(fixture.Create <DateTime>(), null, konto, null, null, fixture.Create <decimal>(), fixture.Create <decimal>(), null)); }
public void TestAtBogføringslinjeAddKalderServicemetode() { var fixture = new Fixture(); var mocker = new MockRepository(); var service = mocker.DynamicMultiMock <IFinansstyringRepositoryService>(new[] { typeof(ICommunicationObject) }); service.Expect(m => m.BogføringslinjeAdd(Arg <BogføringslinjeAddCommand> .Is.NotNull)) .Return(fixture.Create <BogføringslinjeView>()); Expect.Call(((ICommunicationObject)service).State).Return(CommunicationState.Closed); mocker.ReplayAll(); var channelFactory = MockRepository.GenerateMock <IChannelFactory>(); channelFactory.Expect(m => m.CreateChannel <IFinansstyringRepositoryService>(Arg <string> .Is.Anything)) .Return(service); var domainObjectBuilder = MockRepository.GenerateMock <IDomainObjectBuilder>(); var repository = new FinansstyringRepository(channelFactory, domainObjectBuilder); var konto = fixture.Create <Konto>(); var budgetkonto = fixture.Create <Budgetkonto>(); var adressekonto = fixture.Create <Person>(); var result = repository.BogføringslinjeAdd(fixture.Create <DateTime>(), null, konto, fixture.Create <string>(), budgetkonto, fixture.Create <decimal>(), fixture.Create <decimal>(), adressekonto); Assert.That(result, Is.Not.Null); Assert.That(konto.Bogføringslinjer.Count(), Is.EqualTo(1)); Assert.That(budgetkonto.Bogføringslinjer.Count(), Is.EqualTo(1)); Assert.That(adressekonto.Bogføringslinjer.Count(), Is.EqualTo(1)); service.AssertWasCalled(m => m.BogføringslinjeAdd(Arg <BogføringslinjeAddCommand> .Is.NotNull)); }