public void Encode(string longUrl, string expectedEncodedUrl) { var mockGenerator = new Mock <IGuidGenerator>(); mockGenerator.Setup(x => x.Generate()).Returns("4e9iAk"); var url = new EncodeAndDecodeTinyUrl(new Dictionary <string, string>(), mockGenerator.Object); var actual = url.Encode(longUrl); Assert.AreEqual(expectedEncodedUrl, actual); }
public void Test1() { var url1 = "https://leetcode.com/problems/design-tinyurl"; var encoder = new EncodeAndDecodeTinyUrl(); var encodedUrl = encoder.Encode(url1); var decodedUrl = encoder.Decode(encodedUrl); decodedUrl.Should().Equals(url1); }
public void Decode(string shortUrl, string expectedLongUrl) { var dataStore = new Dictionary <string, string> { { shortUrl, expectedLongUrl } }; var mockGenerator = new Mock <IGuidGenerator>(); var url = new EncodeAndDecodeTinyUrl(dataStore, mockGenerator.Object); var actual = url.Decode(shortUrl); Assert.AreEqual(expectedLongUrl, actual); }