public async Task DeleteAsync_WithManufacturerId_ShouldDeleteManufacturer() { // Arrange FitStoreDbContext database = this.Database; DatabaseHelper.SeedData(database); IManagerManufacturerService managerManufacturerService = new ManagerManufacturerService(database); // Act await managerManufacturerService.DeleteAsync(firstNotDeletedManufacturerId); // Assert Manufacturer manufacturer = database.Manufacturers.Find(firstNotDeletedManufacturerId); manufacturer.IsDeleted.Should().Be(true); IEnumerable <Supplement> supplements = manufacturer.Supplements; foreach (Supplement supplement in supplements) { supplement.IsDeleted.Should().Be(true); foreach (Review review in supplement.Reviews) { review.IsDeleted.Should().Be(true); } foreach (Comment comment in supplement.Comments) { comment.IsDeleted.Should().Be(true); } } }
public async Task RestoreAsync_WithManufacturerId_ShouldRestoreManufacturer() { // Arrange FitStoreDbContext database = this.Database; DatabaseHelper.SeedData(database); Manufacturer manufacturer = database.Manufacturers.Find(firstDeletedManufacturerId); foreach (Supplement supplement in manufacturer.Supplements) { supplement.Manufacturer.IsDeleted = true; supplement.Subcategory.IsDeleted = false; foreach (Review review in supplement.Reviews) { review.IsDeleted.Should().Be(true); } foreach (Comment comment in supplement.Comments) { comment.IsDeleted.Should().Be(true); } } database.SaveChanges(); IManagerManufacturerService managerManufacturerService = new ManagerManufacturerService(database); // Act await managerManufacturerService.RestoreAsync(firstDeletedManufacturerId); // Assert manufacturer.IsDeleted.Should().Be(false); foreach (Supplement supplement in manufacturer.Supplements) { supplement.IsDeleted.Should().Be(false); foreach (Review review in supplement.Reviews) { review.IsDeleted.Should().Be(false); } foreach (Comment comment in supplement.Comments) { comment.IsDeleted.Should().Be(false); } } }
public async Task IsManufacturerModified_WithManufacturerIdAndName_ShouldReturnFalse() { // Arrange FitStoreDbContext database = this.Database; DatabaseHelper.SeedData(database); IManagerManufacturerService managerManufacturerService = new ManagerManufacturerService(database); // Act bool result = await managerManufacturerService.IsManufacturerModified(firstNotDeletedManufacturerId, firstNotDeletedManufacturerName, manufacturerAddres); // Assert result.Should().Be(false); }
public async Task GetEditModelAsync_WithManufacturerId_ShouldReturnValidServiceModel() { // Arrange FitStoreDbContext database = this.Database; DatabaseHelper.SeedData(database); IManagerManufacturerService managerManufacturerService = new ManagerManufacturerService(database); // Act ManufacturerBasicServiceModel result = await managerManufacturerService.GetEditModelAsync(firstNotDeletedManufacturerId); // Assert result.Id.Should().Be(firstNotDeletedManufacturerId); result.Name.Should().Be(firstNotDeletedManufacturerName); }
public async Task CreateAsync_WithNameAndAddress_ShouldCreateNewManufacturer() { // Arrange FitStoreDbContext database = this.Database; IManagerManufacturerService managerManufacturerService = new ManagerManufacturerService(database); // Act await managerManufacturerService.CreateAsync(manufacturerName, manufacturerAddres); // Assert Manufacturer manufacturer = database.Manufacturers.Find(1); manufacturer.Id.Should().Be(1); manufacturer.Name.Should().Be(manufacturerName); manufacturer.Address.Should().Be(manufacturerAddres); }
public async Task EditAsync_WithManufacturerIdAndName_ShouldEditManufacturer() { // Arrange FitStoreDbContext database = this.Database; DatabaseHelper.SeedData(database); IManagerManufacturerService managerManufacturerService = new ManagerManufacturerService(database); // Act await managerManufacturerService.EditAsync(firstNotDeletedManufacturerId, manufacturerName, manufacturerAddres); // Assert Manufacturer manufacturer = database.Manufacturers.Find(firstNotDeletedManufacturerId); manufacturer.Id.Should().Be(firstNotDeletedManufacturerId); manufacturer.Name.Should().Be(manufacturerName); }
public async Task GetAllPagedListingAsync_WithSearchTokenAndIsDeletedTrue_ShouldReturnPagedDeletedManufacturers() { // Arrange FitStoreDbContext database = this.Database; DatabaseHelper.SeedData(database); IManagerManufacturerService managerManufacturerService = new ManagerManufacturerService(database); // Act IEnumerable <ManufacturerAdvancedServiceModel> result = await managerManufacturerService.GetAllPagedListingAsync(true, "manufacturer", page); // Assert result.Count().Should().Be(3); result.First().Id.Should().Be(firstDeletedManufacturerId); result.First().Name.Should().Be(firstDeletedManufacturerName); result.Last().Id.Should().Be(lastDeletedManufacturerId); result.Last().Name.Should().Be(lastDeletedManufacturerName); }
public async Task GetAllBasicListingAsync_WithIsDeletedTrue_ShouldReturnAllDeletedManufacturers() { // Arrange FitStoreDbContext database = this.Database; DatabaseHelper.SeedData(database); IManagerManufacturerService managerManufacturerService = new ManagerManufacturerService(database); // Act IEnumerable <ManufacturerBasicServiceModel> result = await managerManufacturerService.GetAllBasicListingAsync(true); // Assert result.Count().Should().Be(10); result.First().Id.Should().Be(firstDeletedManufacturerId); result.First().Name.Should().Be(firstDeletedManufacturerName); result.Last().Id.Should().Be(8); result.Last().Name.Should().Be("Manufacturer 8"); }
public async Task TotalCountAsync_WithSearchTokenAndIsDeletedFalse_ShouldReturnManufacturersCount() { // Arrange FitStoreDbContext database = this.Database; DatabaseHelper.SeedData(database); database.Manufacturers.Add(new Manufacturer { Id = 100, Name = otherName }); database.SaveChanges(); IManagerManufacturerService managerManufacturerService = new ManagerManufacturerService(database); // Act int result = await managerManufacturerService.TotalCountAsync(false, otherName); // Assert result.Should().Be(1); }