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

            Artifact entity = new Artifact();

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

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

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

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

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

            await repository.Update(record);

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

            modifiedRecord.Should().NotBeNull();
        }