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

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

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

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

            MachinePolicy entity = new MachinePolicy();

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

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

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

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

            await repository.Delete(entity.Id);

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

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

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

            await repository.Update(new MachinePolicy());

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

            modifiedRecord.Should().NotBeNull();
        }