public async void UpdatingLostDogFailsForNonExistingDog() { var lostDog = new LostDog { Id = -1 }; Assert.False((await lostDogRepository.UpdateLostDog(lostDog)).Successful); }
public async void DeletingLostDogClearsAllData() { var saveDog = new LostDog() { Breed = "dogdog", Age = 5, Size = "Large, very large", Color = "Orange but a bit yellow and green dots", SpecialMark = "tattoo of you on the neck", Name = "Cat", Picture = new PictureDog() { FileName = "photo", FileType = "png", Data = new byte[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } }, HairLength = "Long", EarsType = "Short", TailLength = "None", Behaviors = new List <DogBehavior>() { new DogBehavior() { Behavior = "Angry" } }, Location = new LocationDog() { City = "Biała", District = "Lol ther's none" }, DateLost = new DateTime(2021, 3, 20), OwnerId = 1, Comments = new List <LostDogComment>() }; var dog = await lostDogRepository.AddLostDog(saveDog); Assert.True(dog.Successful); var result = await lostDogRepository.DeleteLostDog(dog.Data.Id); Assert.True(result.Successful); dog = await lostDogRepository.GetLostDogDetails(dog.Data.Id); Assert.False(dog.Successful); }
public void Seed() { var account = new AddAccountDto() { Name = "bob", Email = "*****@*****.**", PhoneNumber = "222333444", Password = "******", AccountRole = AccountRoles.Regular }; if (!AccountService.AddAccount(account).Result.Successful) { throw new ApplicationException("Could not seed the database with a user"); } var saveDogDog = new LostDog() { Breed = "dogdog", Age = 5, Size = "Large, very large", Color = "Orange but a bit yellow and green dots", SpecialMark = "tattoo of you on the neck", Name = "Cat", Picture = new PictureDog() { FileName = "photo", FileType = "png", Data = new byte[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } }, HairLength = "Long", EarsType = "Short", TailLength = "None", Behaviors = new List <DogBehavior>() { new DogBehavior() { Behavior = "Angry" } }, Location = new LocationDog() { City = "Biała", District = "Lol ther's none" }, DateLost = new DateTime(2021, 3, 20), OwnerId = 1, Comments = new List <LostDogComment>() }; if (LostDogRepository.AddLostDog(saveDogDog).Result == null) { throw new ApplicationException("Could not seed the database with a dog assigned to user"); } var shelter = new Shelter() { IsApproved = true, Name = $"VeryNiceShelter-1", PhoneNumber = $"2111111111", Email = $"*****@*****.**", Address = new Address { City = "Gdańsk", PostCode = "12-345", Street = "Bursztynowa", BuildingNumber = "123" } }; if (ShelterRepository.AddShelter(shelter).Result == null) { throw new ApplicationException("Could not seed the database with a shelter"); } }
public async void GetLostDogSortsProperly() { var saveDog = new LostDog() { Breed = "dogdog", Age = 5, Size = "Large, very large", Color = "Orange but a bit yellow and green dots", SpecialMark = "tattoo of you on the neck", Name = "Cat", Picture = new PictureDog() { FileName = "photo", FileType = "png", Data = new byte[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } }, HairLength = "Long", EarsType = "Short", TailLength = "None", Behaviors = new List <DogBehavior>() { new DogBehavior() { Behavior = "Angry" } }, Location = new LocationDog() { City = "Biała", District = "Lol ther's none" }, DateLost = new DateTime(2021, 3, 20), OwnerId = 1, Comments = new List <LostDogComment>() }; var saveDog2 = new LostDog() { Breed = "dogdog", Age = 6, Size = "Large, very large", Color = "Orange but a bit yellow and green dots", SpecialMark = "tattoo of you on the neck", Name = "Cat", Picture = new PictureDog() { FileName = "photo", FileType = "png", Data = new byte[] { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } }, HairLength = "Long", EarsType = "Short", TailLength = "None", Behaviors = new List <DogBehavior>() { new DogBehavior() { Behavior = "Angry" } }, Location = new LocationDog() { City = "Czarna", District = "Lol ther's none" }, DateLost = new DateTime(2021, 3, 20), OwnerId = 1, Comments = new List <LostDogComment>() }; Assert.True((await lostDogRepository.AddLostDog(saveDog)).Successful); Assert.True((await lostDogRepository.AddLostDog(saveDog2)).Successful); var filteringResult = await lostDogRepository.GetLostDogs(new LostDogFilter(), "location.city", 0, 50); var filteringResult2 = await lostDogRepository.GetLostDogs(new LostDogFilter(), "Location.City,ASC", 0, 50); var filteringResult3 = await lostDogRepository.GetLostDogs(new LostDogFilter(), "location.city,DESC", 0, 50); var filteringResult4 = await lostDogRepository.GetLostDogs(new LostDogFilter(), "location.city,deSc", 0, 50); var filteringResult5 = await lostDogRepository.GetLostDogs(new LostDogFilter(), "notexsitant,DESC", 0, 50); Assert.True(filteringResult.Successful && filteringResult2.Successful && filteringResult3.Successful && filteringResult4.Successful && !filteringResult5.Successful); Assert.True(filteringResult.Data[0].Id == filteringResult2.Data[0].Id && filteringResult.Data[^ 1].Id == filteringResult3.Data[0].Id && filteringResult3.Data[0].Id == filteringResult4.Data[0].Id); }