Ejemplo n.º 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();
		}
Ejemplo n.º 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();
		}
Ejemplo n.º 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();
		}
Ejemplo n.º 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();
		}