public async Task AddImageToBicycle() { var options = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase("add_image").Options; var dbContext = new ApplicationDbContext(options); var imageService = new ImageService(dbContext); var bicycleService = new BicycleService(dbContext, imageService); AutoMapperConfig.RegisterMappings(typeof(BicycleViewModel).Assembly, typeof(Bicycle).Assembly); AutoMapperConfig.RegisterMappings(typeof(EditBicycleViewModel).Assembly, typeof(Bicycle).Assembly); var addBycicle1 = new AddBycicleViewModel() { Type = BicycleType.Mountain, Made = "Something", Speeds = 21, Size = BicycleSize.M, SizeOfTires = 21, PriceForHour = 21, Description = "Something", }; var imagePath = "Test"; var addedBycicle1 = await bicycleService.AddVehicle <AddBycicleViewModel>(addBycicle1); await bicycleService.AddImageUrls(addedBycicle1, imagePath); var bycicles = bicycleService.GetAll <BicycleViewModel>(false); var result = bicycleService.EditDetails <BicycleViewModel>(addedBycicle1); Assert.Equal(imagePath, result.ImageUrl); }
public async Task EditVechicleShouldEdit() { var options = new DbContextOptionsBuilder <ApplicationDbContext>().UseInMemoryDatabase("Edit_tests").Options; var dbContext = new ApplicationDbContext(options); var imageService = new ImageService(dbContext); var bicycleService = new BicycleService(dbContext, imageService); AutoMapperConfig.RegisterMappings(typeof(EditBicycleViewModel).Assembly, typeof(Bicycle).Assembly); var addBycicle = new AddBycicleViewModel() { Type = BicycleType.Mountain, Made = "Something", Speeds = 21, Size = BicycleSize.M, SizeOfTires = 21, PriceForHour = 21, Description = "Something", }; var addedBycicle = await bicycleService.AddVehicle <AddBycicleViewModel>(addBycicle); var editBycicle = new EditBicycleViewModel() { Id = addedBycicle, Type = BicycleType.Mountain, Made = "Edited", Speeds = 21, Size = BicycleSize.M, SizeOfTires = 21, PriceForHour = 21, Description = "Something", }; await bicycleService.DoEdit <EditBicycleViewModel>(editBycicle); var editedBycicle = bicycleService.EditDetails <EditBicycleViewModel>(addedBycicle); Assert.Equal("Edited", editedBycicle.Made); }