Example #1
0
        public void Setup()
        {
            _metrics    = new Moq.Mock <IMetrics>();
            _snapshots  = new Moq.Mock <IStoreSnapshots>();
            _eventstore = new Moq.Mock <IStoreEvents>();
            _oobStore   = new Moq.Mock <IOobWriter>();
            _factory    = new Moq.Mock <IEventFactory>();
            _uow        = new Moq.Mock <IDomainUnitOfWork>();
            _event      = new Moq.Mock <IFullEvent>();
            _mapper     = new Moq.Mock <IEventMapper>();

            _mapper.Setup(x => x.GetMappedTypeFor(typeof(FakeEvent))).Returns(typeof(FakeEvent));
            _resolver = new FakeResolver();

            var fake = new FakeConfiguration();

            fake.FakeContainer.Setup(x => x.Resolve <IEventMapper>()).Returns(_mapper.Object);
            fake.FakeContainer.Setup(x => x.Resolve <IMetrics>()).Returns(_metrics.Object);
            fake.FakeContainer.Setup(x => x.Resolve(typeof(FakeResolver))).Returns(_resolver);
            fake.FakeContainer.Setup(x => x.Resolve <IStoreSnapshots>()).Returns(_snapshots.Object);
            fake.FakeContainer.Setup(x => x.Resolve <IStoreEvents>()).Returns(_eventstore.Object);

            Configuration.Settings = fake;

            _snapshots.Setup(x => x.GetSnapshot <FakeEntity>(Moq.It.IsAny <string>(), Moq.It.IsAny <Id>(), Moq.It.IsAny <Id[]>()))
            .Returns(Task.FromResult((ISnapshot)null));

            _event.Setup(x => x.Event).Returns(new FakeEvent());
            _repository = new Aggregates.Internal.Repository <FakeEntity, FakeState>(_metrics.Object, _eventstore.Object, _snapshots.Object, _oobStore.Object, _factory.Object, _uow.Object);
        }
Example #2
0
        public void bad_entity_throws()
        {
            _streams.Setup(x => x.NewStream <Entity>(Moq.It.IsAny <string>(), new Id("test"),
                                                     Moq.It.IsAny <IEnumerable <Id> >())).Returns(Task.FromResult(_stream.Object));
            _streams.Setup(x => x.GetStream <Entity>(Moq.It.IsAny <string>(), new Id("test"),
                                                     Moq.It.IsAny <IEnumerable <Id> >())).Returns(Task.FromResult(_stream.Object));

            var repository = new Aggregates.Internal.Repository <BadEntity>(_builder.Object);

            Assert.ThrowsAsync <Aggregates.Exceptions.AggregateException>(() => repository.New("test"));
            Assert.ThrowsAsync <Aggregates.Exceptions.AggregateException>(() => repository.Get("test"));
        }
Example #3
0
        public void Setup()
        {
            _builder   = new Moq.Mock <IBuilder>();
            _snapshots = new Moq.Mock <IStoreSnapshots>();
            _streams   = new Moq.Mock <IStoreStreams>();
            _stream    = new Moq.Mock <IEventStream>();
            _resolver  = new FakeResolver();

            _builder.Setup(x => x.Build <IStoreSnapshots>()).Returns(_snapshots.Object);
            _builder.Setup(x => x.Build <IStoreStreams>()).Returns(_streams.Object);
            _builder.Setup(x => x.Build(typeof(FakeResolver))).Returns(_resolver);

            _repository = new Aggregates.Internal.Repository <Entity>(_builder.Object);
        }