public async Task ShortenControllerGetIsCorrect() { var shortenController = new ShortenController(shortenRepositoryMock.Object); var shortedUrls = await shortenController.Get(rawUrls); Assert.IsNotNull(shortedUrls); Assert.AreEqual(1, shortedUrls.Count); }
public async Task ShortenControllerCreateIsCorrect() { var shortenController = new ShortenController(shortenRepositoryMock.Object); var shortedUrls = await shortenController.Create("tk.com"); shortenRepositoryMock.Verify(v => v.SaveAsync(shortedUrls), Times.Once); Assert.IsNotNull(shortedUrls); Assert.AreEqual("tk.com", shortedUrls.RawUrl); }
public void ShortenController_PostUrlForShortening_ReturnOkAndShortUrl() { // Arrange var shortenController = new ShortenController(dbContext); var originalUrl = "http://www.google.com"; var shortenUrlDto = new ShortenUrlDTO { Url = originalUrl }; // Act var actionResult = shortenController.Post(shortenUrlDto); // Assert actionResult.Should().NotBeNull(); var okResult = actionResult as OkObjectResult; okResult.Should().NotBeNull(); var shortenedUrlDto = okResult.Value as ShortenedUrlDTO; shortenedUrlDto.Should().NotBeNull(); shortenedUrlDto.Original_link.Should().Be(originalUrl); dbContext.ShortUrls.Any(url => url.OriginalUrl == originalUrl).Should().BeTrue(); }