Example #1
0
        public async Task id_not_excited_should_throw_exception()
        {
            #region Arrange
            Mock <IEventStore> mockEventSotre = new Mock <IEventStore>();
            var accountId = Guid.Parse("1805FB93-2A90-4C9C-B286-EE9A62A94212");
            mockEventSotre.Setup(x => x.GetByStreamId(It.IsAny <StreamIdentifier>())).Throws <InvalidOperationException>();
            Myrepo.IRepository repo = new Myrepo.Repository(mockEventSotre.Object);
            #endregion
            #region Act and Assert cause async callback
            await Assert.ThrowsAsync <InvalidOperationException>(() => repo.GetById <Account>(accountId));

            #endregion
        }
Example #2
0
        public async Task Save_should_be_called_once()
        {
            #region Arrange
            var accountId = Guid.Parse("1805FB93-2A90-4C9C-B286-EE9A62A94212");
            Mock <IEventStore> mockEventSotre = new Mock <IEventStore>();
            mockEventSotre.Setup(x => x.Save(It.IsAny <List <EventStoreStream> >()));

            Myrepo.IRepository repo = new Myrepo.Repository(mockEventSotre.Object);
            var account             = Account.Create(accountId, "Med");
            #endregion
            #region Act
            await repo.Save(account);

            #endregion
            mockEventSotre.Verify(x => x.Save(It.IsAny <List <EventStoreStream> >()), Times.Once);
        }
Example #3
0
        public async void getting_an_item_by_id()
        {
            #region Arrange
            var accountId = Guid.Parse("1805FB93-2A90-4C9C-B286-EE9A62A94212");
            Mock <IEventStore> mockEventSotre = new Mock <IEventStore>();
            Myrepo.IRepository repo           = new Myrepo.Repository(mockEventSotre.Object);
            mockEventSotre.Setup(x => x.GetByStreamId(It.IsAny <StreamIdentifier>())).Returns(Task.FromResult <IEnumerable <IEvent> >(GetEvents()));
            #endregion
            #region Act
            var account = await repo.GetById <Account>(accountId);

            #endregion
            #region Assert
            Assert.Equal("Med", account.AccountName);
            Assert.Equal(200, account.Debt);
            #endregion
        }