Пример #1
0
        public void HandleShortenUrl_CallToCreateRecord_Test()
        {
            //arrange
            string       url = "www.testurl.com/testlongurlpath";
            KittenUrlDto dto = new KittenUrlDto();

            _repository.CreateRecord().Returns(dto.Id);
            _repository.UpdateRecord(dto.Id, dto.LongUrl, dto.ShortUrl).Returns(true);
            _repository.testmethod().Returns(true);

            //act
            _repository.HandleShortenUrl(url);
            _repository.testmethod();


            //assert
            //--create record metjod called and id passed in
            //check the kittenurl collection is called
            _repository.Received().HandleShortenUrl("ppp");
            _repository.DidNotReceive().CreateRecord();
            _repository.DidNotReceive().UpdateRecord(dto.Id, dto.LongUrl, dto.ShortUrl);
            _repository.Received().UpdateRecord(dto.Id, dto.LongUrl, dto.ShortUrl);
            _repository.Received().CreateRecord();
            //check a record is returned with an id and empty fields


            Assert.Pass();
        }
Пример #2
0
        [HttpGet("createurl/{url?}")]//
        public string CreateUrl([FromQuery(Name = "url")] string url)
        {
            var result = _urlRepository.HandleShortenUrl(url);

            return(result);
        }