Пример #1
0
        public async void Create()
        {
            Mock <ILogger <UserRoleRepository> > loggerMoc = UserRoleRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = UserRoleRepositoryMoc.GetContext();
            var repository = new UserRoleRepository(loggerMoc.Object, context);

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

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

            record.Should().NotBeNull();
        }
Пример #2
0
        public async void Get()
        {
            Mock <ILogger <UserRoleRepository> > loggerMoc = UserRoleRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = UserRoleRepositoryMoc.GetContext();
            var repository = new UserRoleRepository(loggerMoc.Object, context);

            UserRole entity = new UserRole();

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

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

            record.Should().NotBeNull();
        }
Пример #3
0
        public async void Delete()
        {
            Mock <ILogger <UserRoleRepository> > loggerMoc = UserRoleRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = UserRoleRepositoryMoc.GetContext();
            var      repository          = new UserRoleRepository(loggerMoc.Object, context);
            UserRole entity = new UserRole();

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

            await repository.Delete(entity.Id);

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

            modifiedRecord.Should().BeNull();
        }
Пример #4
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <UserRoleRepository> > loggerMoc = UserRoleRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = UserRoleRepositoryMoc.GetContext();
            var      repository          = new UserRoleRepository(loggerMoc.Object, context);
            UserRole entity = new UserRole();

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

            await repository.Update(new UserRole());

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

            modifiedRecord.Should().NotBeNull();
        }