コード例 #1
0
        public async void Create()
        {
            Mock <ILogger <LifecycleRepository> > loggerMoc = LifecycleRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = LifecycleRepositoryMoc.GetContext();
            var repository = new LifecycleRepository(loggerMoc.Object, context);

            var entity = new Lifecycle();
            await repository.Create(entity);

            var record = await context.Set <Lifecycle>().FirstOrDefaultAsync();

            record.Should().NotBeNull();
        }
コード例 #2
0
        public async void Get()
        {
            Mock <ILogger <LifecycleRepository> > loggerMoc = LifecycleRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = LifecycleRepositoryMoc.GetContext();
            var repository = new LifecycleRepository(loggerMoc.Object, context);

            Lifecycle entity = new Lifecycle();

            context.Set <Lifecycle>().Add(entity);
            await context.SaveChangesAsync();

            var record = await repository.Get(entity.Id);

            record.Should().NotBeNull();
        }
コード例 #3
0
        public async void Delete()
        {
            Mock <ILogger <LifecycleRepository> > loggerMoc = LifecycleRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = LifecycleRepositoryMoc.GetContext();
            var       repository         = new LifecycleRepository(loggerMoc.Object, context);
            Lifecycle entity             = new Lifecycle();

            context.Set <Lifecycle>().Add(entity);
            await context.SaveChangesAsync();

            await repository.Delete(entity.Id);

            Lifecycle modifiedRecord = await context.Set <Lifecycle>().FirstOrDefaultAsync();

            modifiedRecord.Should().BeNull();
        }
コード例 #4
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <LifecycleRepository> > loggerMoc = LifecycleRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = LifecycleRepositoryMoc.GetContext();
            var       repository         = new LifecycleRepository(loggerMoc.Object, context);
            Lifecycle entity             = new Lifecycle();

            context.Set <Lifecycle>().Add(entity);
            await context.SaveChangesAsync();

            await repository.Update(new Lifecycle());

            var modifiedRecord = context.Set <Lifecycle>().FirstOrDefaultAsync();

            modifiedRecord.Should().NotBeNull();
        }