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

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

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

			record.Should().NotBeNull();
		}
Пример #2
0
		public async void Update_Entity_Is_Not_Tracked()
		{
			Mock<ILogger<ProductVendorRepository>> loggerMoc = ProductVendorRepositoryMoc.GetLoggerMoc();
			ApplicationDbContext context = ProductVendorRepositoryMoc.GetContext();
			var repository = new ProductVendorRepository(loggerMoc.Object, context);
			ProductVendor entity = new ProductVendor();
			context.Set<ProductVendor>().Add(entity);
			await context.SaveChangesAsync();

			await repository.Update(new ProductVendor());

			var modifiedRecord = context.Set<ProductVendor>().FirstOrDefaultAsync();
			modifiedRecord.Should().NotBeNull();
		}
Пример #3
0
		public async void Get()
		{
			Mock<ILogger<ProductVendorRepository>> loggerMoc = ProductVendorRepositoryMoc.GetLoggerMoc();
			ApplicationDbContext context = ProductVendorRepositoryMoc.GetContext();
			var repository = new ProductVendorRepository(loggerMoc.Object, context);

			ProductVendor entity = new ProductVendor();
			context.Set<ProductVendor>().Add(entity);
			await context.SaveChangesAsync();

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

			record.Should().NotBeNull();
		}
Пример #4
0
		public async void Delete()
		{
			Mock<ILogger<ProductVendorRepository>> loggerMoc = ProductVendorRepositoryMoc.GetLoggerMoc();
			ApplicationDbContext context = ProductVendorRepositoryMoc.GetContext();
			var repository = new ProductVendorRepository(loggerMoc.Object, context);
			ProductVendor entity = new ProductVendor();
			context.Set<ProductVendor>().Add(entity);
			await context.SaveChangesAsync();

			await repository.Delete(entity.ProductID);

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

			modifiedRecord.Should().BeNull();
		}