Ejemplo n.º 1
0
        public void GetSiteUrlForUser_ItemInDatabase_ShouldReturnItAccordingToFromat()
        {
            var id   = "someId";
            var list = new List <SiteUrl> {
                new SiteUrl {
                    OsmUserId = id
                }
            };

            _controller.SetupIdentity(id);
            _israelHikingRepository.GetUrlsByUser(id).Returns(list);

            var results = _controller.GetSiteUrlForUser().Result as OkObjectResult;

            Assert.IsNotNull(results);
            Assert.AreEqual(list.Count, (results.Value as List <SiteUrl>).Count);
        }
Ejemplo n.º 2
0
        public void GetShareUrlForUser_ItemInDatabase_ShouldReturnShortedByCreationDate()
        {
            var id   = "someId";
            var list = new List <ShareUrl>
            {
                new ShareUrl {
                    OsmUserId = id, CreationDate = DateTime.Now.AddDays(-1)
                },
                new ShareUrl {
                    OsmUserId = id, CreationDate = DateTime.Now.AddDays(-2)
                },
                new ShareUrl {
                    OsmUserId = id, CreationDate = DateTime.Now
                }
            };

            _controller.SetupIdentity(null, id);
            _repository.GetUrlsByUser(id).Returns(list);

            var results = _controller.GetShareUrlForUser().Result as OkObjectResult;

            Assert.IsNotNull(results);
            Assert.IsNotNull(results.Value as IEnumerable <ShareUrl>);
            Assert.AreEqual(list.Count, ((IEnumerable <ShareUrl>)results.Value).Count());
            Assert.AreEqual(list.OrderByDescending(d => d.CreationDate).First().CreationDate, ((IEnumerable <ShareUrl>)results.Value).First().CreationDate);
        }