Beispiel #1
0
        public void TestLinkRecordSaving()
        {

            RepositoryResult<LinkRecord> response=default(RepositoryResult<LinkRecord>);
            var now = DateTime.Now;
            using (var scope = new TransactionScope())
            {
                using (var rep = new LinkRepository())
                {
                    var url = string.Format("https://google.kz?id={0}", (new Random()).Next(int.MaxValue));                       
                    response = rep.CreateAndSave(url);
                }
            }
            Assert.IsTrue(response.IsSuccess);
            Assert.That(response.Data.Id, Is.GreaterThan(0));
            Assert.That(response.Data.CreateDate, Is.GreaterThan(now));
        }
Beispiel #2
0
        public void TestRetrieveByShortLink()
        {
            using (var scope = new TransactionScope())
            {
                var now = DateTime.Now;
                LinkRecord created = null;
                using (var createRep = new LinkRepository())
                {
                    var url = string.Format("http://google.kz?id={0}", (new Random()).Next(int.MaxValue));
                    var response = createRep.CreateAndSave(url);
                    created = response.Data;
                }
                LinkRecord readen = null;
                using(var readRep = new LinkRepository())
                {
                    readen = readRep.RetrieveByShortLink(created.ShortLink).Data;

                }

                Assert.That(readen.Id, Is.EqualTo(created.Id));
                Assert.That(readen.OriginalLink, Is.EqualTo(created.OriginalLink));
            }
        }