public async Task ShouldNotSaveWithSameName() { PetFinderContext context = dbContextFactory.CreateContext(); AnimalType animalType = CreateAnimalType("Perro"); AnimalType animalTypeRepeated = CreateAnimalType("Perro"); AnimalTypeService animalTypeService = new AnimalTypeService(context, logger); await animalTypeService.Save(animalType); GenericResult result = await animalTypeService.Save(animalTypeRepeated); // No deberia insertarse ya que existe una ciudad con el mismo nombre Assert.False(result.Success); }
public async Task ShouldAddAsync() { PetFinderContext context = dbContextFactory.CreateContext(); AnimalType animalType = CreateAnimalType("Perro Lobo"); AnimalTypeService animalTypeService = new AnimalTypeService(context, logger); await animalTypeService.Save(animalType); AnimalType animalTypeGato = CreateAnimalType("Gato"); await animalTypeService.Save(animalTypeGato); int numberOfAnimalTypes = context.AnimalTypes.Count(); // Deberia haber una sola ciudad ya que editamos la misma que insertamos Assert.Equal <int>(2, numberOfAnimalTypes); }