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

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

            var records = await repository.All(1, 0, DateTime.Parse("1/1/1987 12:00:00 AM").ToString());

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

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

            delete.Should().NotThrow();
        }
Esempio n. 4
0
        public async void Create()
        {
            Mock <ILogger <TeacherRepository> > loggerMoc = TeacherRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TeacherRepositoryMoc.GetContext();
            var repository = new TeacherRepository(loggerMoc.Object, context);

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

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

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

            var entity = new Teacher();

            entity.SetProperties(default(int), DateTime.Parse("1/1/1988 12:00:00 AM"), "B", "B", "B", "B", 1);
            await repository.Create(entity);

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

            records.Count.Should().Be(2);
        }
Esempio n. 6
0
        public async void Get()
        {
            Mock <ILogger <TeacherRepository> > loggerMoc = TeacherRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TeacherRepositoryMoc.GetContext();
            var repository = new TeacherRepository(loggerMoc.Object, context);

            Teacher entity = new Teacher();

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

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

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

            Teacher entity = new Teacher();

            entity.SetProperties(default(int), DateTime.Parse("1/1/1988 12:00:00 AM"), "B", "B", "B", "B", 1);
            context.Set <Teacher>().Add(entity);
            await context.SaveChangesAsync();

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

            record.Should().NotBeNull();
        }
Esempio n. 8
0
        public async void Delete()
        {
            Mock <ILogger <TeacherRepository> > loggerMoc = TeacherRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TeacherRepositoryMoc.GetContext();
            var     repository           = new TeacherRepository(loggerMoc.Object, context);
            Teacher entity = new Teacher();

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

            await repository.Delete(entity.Id);

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

            modifiedRecord.Should().BeNull();
        }
Esempio n. 9
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <TeacherRepository> > loggerMoc = TeacherRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TeacherRepositoryMoc.GetContext();
            var     repository           = new TeacherRepository(loggerMoc.Object, context);
            Teacher entity = new Teacher();

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

            await repository.Update(new Teacher());

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

            modifiedRecord.Should().NotBeNull();
        }
Esempio n. 10
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <TeacherRepository> > loggerMoc = TeacherRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TeacherRepositoryMoc.GetContext();
            var     repository           = new TeacherRepository(loggerMoc.Object, context);
            Teacher entity = new Teacher();

            entity.SetProperties(default(int), DateTime.Parse("1/1/1988 12:00:00 AM"), "B", "B", "B", "B", 1);
            context.Set <Teacher>().Add(entity);
            await context.SaveChangesAsync();

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

            await repository.Update(entity);

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

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