public async void Create() { Mock <ILogger <SubscriptionRepository> > loggerMoc = SubscriptionRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = SubscriptionRepositoryMoc.GetContext(); var repository = new SubscriptionRepository(loggerMoc.Object, context); var entity = new Subscription(); await repository.Create(entity); var record = await context.Set <Subscription>().FirstOrDefaultAsync(); record.Should().NotBeNull(); }
public async void Get() { Mock <ILogger <SubscriptionRepository> > loggerMoc = SubscriptionRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = SubscriptionRepositoryMoc.GetContext(); var repository = new SubscriptionRepository(loggerMoc.Object, context); Subscription entity = new Subscription(); context.Set <Subscription>().Add(entity); await context.SaveChangesAsync(); var record = await repository.Get(entity.Id); record.Should().NotBeNull(); }
public async void Delete() { Mock <ILogger <SubscriptionRepository> > loggerMoc = SubscriptionRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = SubscriptionRepositoryMoc.GetContext(); var repository = new SubscriptionRepository(loggerMoc.Object, context); Subscription entity = new Subscription(); context.Set <Subscription>().Add(entity); await context.SaveChangesAsync(); await repository.Delete(entity.Id); Subscription modifiedRecord = await context.Set <Subscription>().FirstOrDefaultAsync(); modifiedRecord.Should().BeNull(); }
public async void Update_Entity_Is_Not_Tracked() { Mock <ILogger <SubscriptionRepository> > loggerMoc = SubscriptionRepositoryMoc.GetLoggerMoc(); ApplicationDbContext context = SubscriptionRepositoryMoc.GetContext(); var repository = new SubscriptionRepository(loggerMoc.Object, context); Subscription entity = new Subscription(); context.Set <Subscription>().Add(entity); await context.SaveChangesAsync(); await repository.Update(new Subscription()); var modifiedRecord = context.Set <Subscription>().FirstOrDefaultAsync(); modifiedRecord.Should().NotBeNull(); }