Exemple #1
0
        public async void StoreAsync_InsertIntoCollection()
        {
            StubStore  eventStore = new StubStore("mongodb://localhost:27017", "eventsTest");
            EventTest1 @event1    = new EventTest1 {
                Test1 = "test", SourceId = Guid.NewGuid()
            };

            eventStore.MoqCollection
            .Setup(c => c.Insert(It.IsAny <EventWrapper>()))
            .Returns(new WriteConcernResult(new BsonDocument()));
            await eventStore.StoreAsync(@event1, default(CancellationToken));

            eventStore.MoqCollection.Verify(c => c.Insert(It.IsAny <EventWrapper>()), Times.Once());
        }
Exemple #2
0
        public void LoadAsync_ReturnsResults()
        {
            StubStore  eventStore = new StubStore("mongodb://localhost:27017", "eventsTest");
            EventTest1 event1     = new EventTest1 {
                Test1 = "test", SourceId = Guid.NewGuid()
            };
            EventTest2 event2 = new EventTest2 {
                Test2 = "test", SourceId = Guid.NewGuid()
            };

            EventWrapper[] events = { new EventWrapper(event1), new EventWrapper(event2) };

            eventStore.MoqCollection
            .Setup(c => c.FindAs(It.IsAny <Type>(), It.IsAny <IMongoQuery>()))
            .Returns(CreateCursor(eventStore.MoqCollection.Object, events));

            var task1   = eventStore.LoadAsync(Guid.Empty, default(CancellationToken));
            var result1 = task1.Result;

            Assert.NotNull(result1);
            Assert.Equal(2, result1.Count);
        }