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

            Badge entity = new Badge();

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

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

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

            Badge entity = new Badge();

            entity.SetProperties(default(int), DateTime.Parse("1/1/1988 12:00:00 AM"), "B", 1);
            context.Set <Badge>().Add(entity);
            await context.SaveChangesAsync();

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

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

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

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

            await repository.Update(record);

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

            modifiedRecord.Should().NotBeNull();
        }