public async void ShouldReturnItem() { // Act var result = await UrlServiceToTest.GetUrl("fr7Y2J"); // Assert Assert.True(result.ActualUrl == "https://youtube.co.uk"); Assert.True(result.AccessCount == 1); }
public async void ShouldReturnItems() { // Arrange // Act var result = await UrlServiceToTest.GetAll(1, 10); // Assert Assert.True(3 == result.Items[0].Id); }
public async void ShouldAdd() { // Arrange UrlCreate urlCreate = new UrlCreate { ActualUrl = "https://bbc.co.uk" }; // Act var result = await UrlServiceToTest.AddUrl(urlCreate); // Assert Assert.True(result.ActualUrl == urlCreate.ActualUrl); }
public async void ShouldUpdate() { // Arrange UrlDto newUrl = new UrlDto { Id = 2, ActualUrl = "https://www.bbc.co.uk/news", ShortenedUrl = "FG5tYi" }; // Act var result = await UrlServiceToTest.UpdateUrl(newUrl); // Assert Assert.True(result.Id == newUrl.Id); Assert.True(result.ActualUrl == newUrl.ActualUrl); }
public async void ShouldRemove() { // This test is rather brittle and I'm not truly happy with it. Kept it in for coverage // Brittle because if GetUrl fails then this test also fails // Act await UrlServiceToTest.DeleteUrl(2); // Assert try { await UrlServiceToTest.GetUrl("fr7Y2J"); } catch (Exception ex) { Assert.True(ex.Message == "Not found"); } }