Exemplo n.º 1
0
        public async void Create()
        {
            Mock <ILogger <VersionInfoRepository> > loggerMoc = VersionInfoRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = VersionInfoRepositoryMoc.GetContext();
            var repository = new VersionInfoRepository(loggerMoc.Object, context);

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

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

            record.Should().NotBeNull();
        }
Exemplo n.º 2
0
        public async void Get()
        {
            Mock <ILogger <VersionInfoRepository> > loggerMoc = VersionInfoRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = VersionInfoRepositoryMoc.GetContext();
            var repository = new VersionInfoRepository(loggerMoc.Object, context);

            VersionInfo entity = new VersionInfo();

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

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

            record.Should().NotBeNull();
        }
Exemplo n.º 3
0
        public async void Delete()
        {
            Mock <ILogger <VersionInfoRepository> > loggerMoc = VersionInfoRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = VersionInfoRepositoryMoc.GetContext();
            var         repository       = new VersionInfoRepository(loggerMoc.Object, context);
            VersionInfo entity           = new VersionInfo();

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

            await repository.Delete(entity.Version);

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

            modifiedRecord.Should().BeNull();
        }
Exemplo n.º 4
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <VersionInfoRepository> > loggerMoc = VersionInfoRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = VersionInfoRepositoryMoc.GetContext();
            var         repository       = new VersionInfoRepository(loggerMoc.Object, context);
            VersionInfo entity           = new VersionInfo();

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

            await repository.Update(new VersionInfo());

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

            modifiedRecord.Should().NotBeNull();
        }