Example #1
0
        public async void Get()
        {
            Mock <ILogger <WorkerRepository> > loggerMoc = WorkerRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = WorkerRepositoryMoc.GetContext();
            var repository = new WorkerRepository(loggerMoc.Object, context);

            Worker entity = new Worker();

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

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

            record.Should().NotBeNull();
        }
Example #2
0
        public async void Update_Entity_Is_Tracked()
        {
            Mock <ILogger <WorkerRepository> > loggerMoc = WorkerRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = WorkerRepositoryMoc.GetContext();
            var    repository            = new WorkerRepository(loggerMoc.Object, context);
            Worker entity = new Worker();

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

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

            await repository.Update(record);

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

            modifiedRecord.Should().NotBeNull();
        }