public async Task RemoveFromFavoritesAsync_WithInValidDataWithNotFoundOffer_ShouldNotAddOfferToFavorites() { var expectedOffersCount = 1; var guid = Guid.NewGuid().ToString(); var moqUsersService = new Mock <IUserService>(); moqUsersService.Setup(x => x.GetCurrentUserId()) .Returns("CurrentUserId"); var moqCategoriesService = new Mock <ICategoryService>(); var moqCloudinaryService = new Mock <ICloudinaryService>(); var moqIFormFile = new Mock <IFormFile>(); moqCloudinaryService.Setup(x => x.UploadPhotoAsync(moqIFormFile.Object, "FileName", "Folder")) .ReturnsAsync("http://test.com"); var createOfferInputModel = new CreateOfferModel { Name = "Wow Account", CategotyName = "Wow", CreatorId = guid, Description = "Some Test Description", Price = 10.00, PicUrl = "link", }; var user = new ApplicationUser() { Id = guid, UserName = "******", }; var context = InitializeContext.CreateContextForInMemory(); var offerService = new OfferService(context, moqCategoriesService.Object, moqCloudinaryService.Object); this.favoriteService = new FavoriteService(context, offerService); var approvedOffer = await offerService.CreateOfferAsync(createOfferInputModel); await offerService.ApproveOfferAsync(approvedOffer.Id); context.Users.Add(user); await context.SaveChangesAsync(); // Assert await this.favoriteService.AddToFavoritesAsync(approvedOffer.Id, guid); var result = await this.favoriteService.AddToFavoritesAsync("InvalidID", guid); var userFav = await context.UserFavorites.FirstOrDefaultAsync(x => x.OfferId == approvedOffer.Id && x.UserId == guid); Assert.NotNull(userFav); Assert.False(result); }