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 }
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 }