Esempio n. 1
0
        public async void Get()
        {
            Mock <ILogger <KeyAllocationRepository> > loggerMoc = KeyAllocationRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = KeyAllocationRepositoryMoc.GetContext();
            var repository = new KeyAllocationRepository(loggerMoc.Object, context);

            KeyAllocation entity = new KeyAllocation();

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

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

            record.Should().NotBeNull();
        }
Esempio n. 2
0
        public async void Update_Entity_Is_Tracked()
        {
            Mock <ILogger <KeyAllocationRepository> > loggerMoc = KeyAllocationRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = KeyAllocationRepositoryMoc.GetContext();
            var           repository     = new KeyAllocationRepository(loggerMoc.Object, context);
            KeyAllocation entity         = new KeyAllocation();

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

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

            await repository.Update(record);

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

            modifiedRecord.Should().NotBeNull();
        }