コード例 #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();
        }