예제 #1
0
        public async void Create()
        {
            Mock <ILogger <TenantRepository> > loggerMoc = TenantRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TenantRepositoryMoc.GetContext();
            var repository = new TenantRepository(loggerMoc.Object, context);

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

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

            record.Should().NotBeNull();
        }
예제 #2
0
        public async void Get()
        {
            Mock <ILogger <TenantRepository> > loggerMoc = TenantRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TenantRepositoryMoc.GetContext();
            var repository = new TenantRepository(loggerMoc.Object, context);

            Tenant entity = new Tenant();

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

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

            record.Should().NotBeNull();
        }
예제 #3
0
        public async void Delete()
        {
            Mock <ILogger <TenantRepository> > loggerMoc = TenantRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TenantRepositoryMoc.GetContext();
            var    repository            = new TenantRepository(loggerMoc.Object, context);
            Tenant entity = new Tenant();

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

            await repository.Delete(entity.Id);

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

            modifiedRecord.Should().BeNull();
        }
예제 #4
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <TenantRepository> > loggerMoc = TenantRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = TenantRepositoryMoc.GetContext();
            var    repository            = new TenantRepository(loggerMoc.Object, context);
            Tenant entity = new Tenant();

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

            await repository.Update(new Tenant());

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

            modifiedRecord.Should().NotBeNull();
        }