Ejemplo n.º 1
0
        public async Task CreateShortLink(string shortLink, string fullLink, string userName)
        {
            var user     = string.IsNullOrEmpty(userName) ? null : new User(userName);
            var expected = new ShortLink("QWERTY", "https://yahoo.com", user);

            _shortLinksRepository.Setup(r => r.InsertAsync(It.IsAny <ShortLink>()))
            .Returns(() => Task.Factory.StartNew(() => _shortLinks.Add(expected)));

            await _service.CreateShortLinkAsync("https://yahoo.com", It.IsAny <User>());

            (await _shortLinksRepository.Object.GetAllAsync()).Should().Contain(expected);
        }
Ejemplo n.º 2
0
 public async Task <dynamic> Post([FromBody] string fullLink)
 {
     return(new { ShortLink = await _service.CreateShortLinkAsync(fullLink, await CurrentUser) });
 }