public async void All()
        {
            Mock <ILogger <SpaceFeatureRepository> > loggerMoc = SpaceFeatureRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SpaceFeatureRepositoryMoc.GetContext();
            var repository = new SpaceFeatureRepository(loggerMoc.Object, context);
            var records    = await repository.All();

            records.Should().NotBeEmpty();
            records.Count.Should().Be(1);
        }
        public void DeleteNotFound()
        {
            Mock <ILogger <SpaceFeatureRepository> > loggerMoc = SpaceFeatureRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SpaceFeatureRepositoryMoc.GetContext();
            var repository = new SpaceFeatureRepository(loggerMoc.Object, context);

            Func <Task> delete = async() =>
            {
                await repository.Delete(default(int));
            };

            delete.Should().NotThrow();
        }
Beispiel #3
0
        public async void Create()
        {
            Mock <ILogger <SpaceFeatureRepository> > loggerMoc = SpaceFeatureRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SpaceFeatureRepositoryMoc.GetContext();
            var repository = new SpaceFeatureRepository(loggerMoc.Object, context);

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

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

            record.Should().NotBeNull();
        }
        public async void Create()
        {
            Mock <ILogger <SpaceFeatureRepository> > loggerMoc = SpaceFeatureRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SpaceFeatureRepositoryMoc.GetContext();
            var repository = new SpaceFeatureRepository(loggerMoc.Object, context);

            var entity = new SpaceFeature();

            entity.SetProperties(default(int), "B");
            await repository.Create(entity);

            var records = await context.Set <SpaceFeature>().ToListAsync();

            records.Count.Should().Be(2);
        }
Beispiel #5
0
        public async void Get()
        {
            Mock <ILogger <SpaceFeatureRepository> > loggerMoc = SpaceFeatureRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SpaceFeatureRepositoryMoc.GetContext();
            var repository = new SpaceFeatureRepository(loggerMoc.Object, context);

            SpaceFeature entity = new SpaceFeature();

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

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

            record.Should().NotBeNull();
        }
Beispiel #6
0
        public async void Delete()
        {
            Mock <ILogger <SpaceFeatureRepository> > loggerMoc = SpaceFeatureRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SpaceFeatureRepositoryMoc.GetContext();
            var          repository      = new SpaceFeatureRepository(loggerMoc.Object, context);
            SpaceFeature entity          = new SpaceFeature();

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

            await repository.Delete(entity.Id);

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

            modifiedRecord.Should().BeNull();
        }
Beispiel #7
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <SpaceFeatureRepository> > loggerMoc = SpaceFeatureRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SpaceFeatureRepositoryMoc.GetContext();
            var          repository      = new SpaceFeatureRepository(loggerMoc.Object, context);
            SpaceFeature entity          = new SpaceFeature();

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

            await repository.Update(new SpaceFeature());

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

            modifiedRecord.Should().NotBeNull();
        }
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <SpaceFeatureRepository> > loggerMoc = SpaceFeatureRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = SpaceFeatureRepositoryMoc.GetContext();
            var          repository      = new SpaceFeatureRepository(loggerMoc.Object, context);
            SpaceFeature entity          = new SpaceFeature();

            entity.SetProperties(default(int), "B");
            context.Set <SpaceFeature>().Add(entity);
            await context.SaveChangesAsync();

            context.Entry(entity).State = EntityState.Detached;

            await repository.Update(entity);

            var records = await context.Set <SpaceFeature>().ToListAsync();

            records.Count.Should().Be(2);
        }