コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }