public async Task GetAsync_Projection_ShouldThrowInvalidSubscriberException_WhenSubscriberNotExists() { var correctConfirmationCode = Guid.NewGuid().ToString(); await this.dbContext.Subscribers.AddRangeAsync(new List <Subscriber>() { new Subscriber { Id = "1", ConfirmationCode = "1" }, new Subscriber { Id = "2", ConfirmationCode = correctConfirmationCode }, new Subscriber { Id = "3", ConfirmationCode = "3" }, }); await this.dbContext.SaveChangesAsync(); var subscriberService = new SubscriberService(this.dbContext); var incorrectId = Guid.NewGuid().ToString(); Assert.Throws <InvalidSubscriberException>(() => subscriberService.GetAsync <FakeSubscriber>(incorrectId, correctConfirmationCode).GetAwaiter().GetResult()); }
public async Task GetAsync_ShouldGetCorrectSubscriber_WhenEmailExists() { var wantedSubscriberId = Guid.NewGuid().ToString(); var wantedSubscriberEmail = Guid.NewGuid().ToString(); await this.dbContext.Subscribers.AddRangeAsync(new List <Subscriber>() { new Subscriber { Id = "1", Email = "*****@*****.**" }, new Subscriber { Id = wantedSubscriberId, Email = wantedSubscriberEmail }, new Subscriber { Id = "3", Email = "*****@*****.**" }, }); await this.dbContext.SaveChangesAsync(); var subscriberService = new SubscriberService(this.dbContext); var expectedSubscriberId = wantedSubscriberId; var subscriber = await subscriberService.GetAsync(wantedSubscriberEmail); Assert.Equal(expectedSubscriberId, subscriber.Id); }
public async Task GetAsync_Projection_ShouldGetCorrectSubscriber_WhenCategoryExists() { var wantedSubscriberId = Guid.NewGuid().ToString(); var wantedSubscriberConfirmationCode = Guid.NewGuid().ToString(); await this.dbContext.Subscribers.AddRangeAsync(new List <Subscriber>() { new Subscriber { Id = "1", ConfirmationCode = "1" }, new Subscriber { Id = wantedSubscriberId, ConfirmationCode = wantedSubscriberConfirmationCode }, new Subscriber { Id = "3", ConfirmationCode = "3" }, }); await this.dbContext.SaveChangesAsync(); var subscriberService = new SubscriberService(this.dbContext); var expectedSubscriberId = wantedSubscriberId; var subscriber = await subscriberService.GetAsync <FakeSubscriber>(wantedSubscriberId, wantedSubscriberConfirmationCode); Assert.Equal(expectedSubscriberId, subscriber.Id); }
public async Task GetAsync_ShouldThrowInvalidSubscriberException_WhenEmailNotExists() { await this.dbContext.Subscribers.AddRangeAsync(new List <Subscriber>() { new Subscriber { Id = "1", Email = "*****@*****.**" }, new Subscriber { Id = "2", Email = "*****@*****.**" }, }); await this.dbContext.SaveChangesAsync(); var subscriberService = new SubscriberService(this.dbContext); var incorrectEmail = "*****@*****.**"; Assert.Throws <InvalidSubscriberException>(() => subscriberService.GetAsync(incorrectEmail).GetAwaiter().GetResult()); }