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

            Clasp entity = new Clasp();

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

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

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

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

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

            await repository.Update(record);

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

            modifiedRecord.Should().NotBeNull();
        }
Esempio n. 3
0
        public async void Update_Entity_Is_Tracked()
        {
            Mock <ILogger <ClaspRepository> > loggerMoc = ClaspRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = ClaspRepositoryMoc.GetContext();
            var   repository             = new ClaspRepository(loggerMoc.Object, context);
            Clasp entity = new Clasp();

            entity.SetProperties(default(int), 1, 1);
            context.Set <Clasp>().Add(entity);
            await context.SaveChangesAsync();

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

            await repository.Update(record);

            var records = await context.Set <Clasp>().ToListAsync();

            records.Count.Should().Be(2);
        }