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

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

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

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

            NuGetPackage entity = new NuGetPackage();

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

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

            record.Should().NotBeNull();
        }
Esempio n. 3
0
        public async void Delete()
        {
            Mock <ILogger <NuGetPackageRepository> > loggerMoc = NuGetPackageRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = NuGetPackageRepositoryMoc.GetContext();
            var          repository      = new NuGetPackageRepository(loggerMoc.Object, context);
            NuGetPackage entity          = new NuGetPackage();

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

            await repository.Delete(entity.Id);

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

            modifiedRecord.Should().BeNull();
        }
Esempio n. 4
0
        public async void Update_Entity_Is_Not_Tracked()
        {
            Mock <ILogger <NuGetPackageRepository> > loggerMoc = NuGetPackageRepositoryMoc.GetLoggerMoc();
            ApplicationDbContext context = NuGetPackageRepositoryMoc.GetContext();
            var          repository      = new NuGetPackageRepository(loggerMoc.Object, context);
            NuGetPackage entity          = new NuGetPackage();

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

            await repository.Update(new NuGetPackage());

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

            modifiedRecord.Should().NotBeNull();
        }