public void CreatePost(CreatePostModel createPostModel, int userId) { var locationId = locationServices.GetLocationIdByLocationName(context, createPostModel.LocationName); var animalTypeId = animalTypeServices.GetAnimalTypeIdByAnimalTypeName(context, createPostModel.AnimalTypeName); var breedTypeId = breedTypeServices.GetBreedTypeIdByBreedTypeName(createPostModel.BreedTypeName); var animal = new Animal { AnimalName = createPostModel.AnimalName, Birthday = createPostModel.Birthday, AnimalTypeId = animalTypeId, BreedTypeId = breedTypeId, LocationId = locationId, UserId = userId }; var postToCreate = AutoMapper.Mapper.Map <Post>(createPostModel); postToCreate.Animal = animal; postToCreate.User = context.Users.Find(userId); this.context.Posts.Add(postToCreate); this.context.SaveChanges(); }
public void Throw_ArgumentException_When_SuchLocationDoesNotExist() { //Act & Assert Assert.ThrowsException <ArgumentException>(() => locationService.GetLocationIdByLocationName(mockContext.Object, "Varna")); }