public async Task DeleteCollectionAsync_Should_Pass() { // Arrange CollectionDto collectionDto = new CollectionDto { UserId = 1, Name = "Dank Memes" }; await CollectionService.CreateCollectionAsync(collectionDto); List <CollectionDto> collections = (await CollectionService.GetAllCollectionsAsync()).ToList(); Assert.IsTrue(collections.Count.Equals(1)); // Act DeleteCollectionDto deleteCollectionDto = new DeleteCollectionDto { Id = 1, UserId = 1 }; ServiceResponseDto deleteCollectionResultDto = await CollectionService.DeleteCollectionAsync(deleteCollectionDto); // Assert Assert.IsTrue(deleteCollectionResultDto.Success); collections = (await CollectionService.GetAllCollectionsAsync()).ToList(); Assert.IsTrue(collections.Count.Equals(0)); }
public async Task DeleteCollectionCallsRequestSenderWithValidRequest() { var result = new { }; _apiRequestSenderMock.Setup(sender => sender.SendRequestAsync(It.IsAny <ApiRequest>())) .ReturnsAsync(result); var collectionId = "collectionId"; await _collectionService.DeleteCollectionAsync(collectionId); _apiRequestSenderMock.Verify(sender => sender.SendRequestAsync( It.Is <ApiRequest>( req => req.Path == $"/api/v4/collections/{collectionId}/" && req.HTTPMethod == HttpMethod.Delete ) )); }
public async Task DeleteCollectionCallsRequestSenderWithValidRequest() { var apiRequestSender = new Mock <IApiRequestSender>(); var result = ""; apiRequestSender.Setup(sender => sender.SendRequestAsync(It.IsAny <Request <string> >())) .Returns(Task.FromResult(result)); var collectionService = new CollectionService(apiRequestSender.Object); var collectionId = "collectionId"; await collectionService.DeleteCollectionAsync(collectionId); apiRequestSender.Verify(sender => sender.SendRequestAsync( It.Is <Request <string> >( req => req.Path == $"/api/v4/collections/{collectionId}/" && req.HTTPMethod == HttpMethod.Delete))); }