public async Task DeletePhotoTest() { // Populate our db with necessary objects var user = await _repository.CreateUser("Test User " + DateTime.UtcNow.Ticks); var category = await _repository.CreateCategory("Test Category " + DateTime.UtcNow.Ticks); var photo = await _repository.InsertPhoto(CreateTestPhoto(category, user), 1); _userRegistrationReferenceProviderMock.GetCurrentUserRegistrationReference = () => user.RegistrationReference; await _photoController.DeleteAsync(photo.Id); // Act await _photoController.GetAsync(photo.Id); }
public async Task UploadPhotoAndPostAnnotationsTest() { // Populate our db with necessary objects var user1 = await _repository.CreateUser("test user " + DateTime.UtcNow.Ticks); var user2 = await _repository.CreateUser("test user " + DateTime.UtcNow.Ticks); var category = await _repository.CreateCategory("Test Category " + DateTime.UtcNow.Ticks); _userRegistrationReferenceProviderMock.GetCurrentUserRegistrationReference = () => user1.RegistrationReference; var photoContract = CreateTestPhoto(category, user1); // Post photo var insertedPhoto = await _photoController.PostAsync(photoContract); // Verify Assert.IsNotNull(insertedPhoto, "null response from service"); Assert.IsNotNull(insertedPhoto.Id, "null id from service"); // Fetch inserted photo var photo = await _photoController.GetAsync(insertedPhoto.Id); // Verify Assert.IsNotNull(photo); Assert.AreEqual(photo.Id, insertedPhoto.Id, "fetched photo Id isn't matching with the requested photo"); // Fetch Categories data var photoStream = await _categoryController.GetAsync(category.Id, null); // Verify Assert.IsNotNull(photoStream, "null response from service"); Assert.IsNotNull(photoStream.Items, "null items from service"); Assert.AreEqual(category.Id, photoStream.Items.FirstOrDefault()?.CategoryId, "categoryId from service did not match correct categoryId"); // Add Annotation with null text var annotation = CreateTestAnnotation(user2, 0, photo.Id, photo.User.UserId); // Act var actionResult = await _annotationController.PostAsync(annotation); // Verify Assert.IsNotNull(actionResult, "null response from service"); Assert.IsNotNull(actionResult.Id, "null id from service"); // Add Annotation with not null text annotation = CreateTestAnnotation(user2, 1, photo.Id, photo.User.UserId, "Not null text"); // Act actionResult = await _annotationController.PostAsync(annotation); // Verify Assert.IsNotNull(actionResult, "null response from service"); Assert.IsNotNull(actionResult.Id, "null id from service"); Assert.IsNotNull(actionResult.Text, "annotation text was null when it should not have been"); }