public async void WithoutPictures_ShouldNotChangePictures() { var dbContext = this.GetDbContext(); var dbPicture = EntitiesCreateMethods.CreatePicture(Guid.NewGuid().ToString()); var dbCar = SeedCarsMethods.SeedCar <NewCar>(dbContext, dbPicture); var service = this.GetService(dbContext); var model = CarServiceModelCreateMethods.Create(dbCar.Id); var exception = await Assert.ThrowsAsync <RepositoryUpdateNoRowsAffectedException>( async() => await service.EditAsync <NewCar>(model)); Assert.Equal(ErrorConstants.UnitOfWorkNoRowsAffected, exception.Message); }
public async void WithPictures_ShouldReplacePictures() { var dbContext = this.GetDbContext(); var dbPictures = EntitiesCreateMethods.CreatePicture(Guid.NewGuid().ToString()); var dbCar = SeedCarsMethods.SeedCar <NewCar>(dbContext, dbPictures); var picturePublicId = Guid.NewGuid().ToString(); var model = CarServiceModelCreateMethods.Create(dbCar.Id, picturePublicId); var service = this.GetService(dbContext); await service.EditAsync <NewCar>(model); Assert.Single(dbContext.Pictures); Assert.Equal(picturePublicId, dbContext.Pictures.First().PublicId); }
public async void WithOptions_ShouldReplaceOptions() { var dbContext = this.GetDbContext(); var carOption = SeedOptionsMethods.SeedOption(dbContext); var dbCarOptions = EntitiesCreateMethods.CreateCarOption(carOption); var dbCar = SeedCarsMethods.SeedCar <NewCar>(dbContext, dbCarOptions); var service = this.GetService(dbContext); var inputOption = SeedOptionsMethods.SeedOption(dbContext); var model = CarServiceModelCreateMethods.Create(dbCar.Id, inputOption); await service.EditAsync <NewCar>(model); Assert.True(dbCar.Options.All(o => inputOption.Id == o.OptionId)); }