public void Get_NoParameters_ReturnsListAdResponse() { var adRequest = _factory.GetAdRequest(); var dbObj = _repository.Insert(new Ad(adRequest)); var response = _service.Get(); Assert.IsNotNull(response); Assert.AreSame(typeof(List <AdResponse>), response.GetType()); Assert.AreEqual(response.Count(), 1); }
public ActionResult Modify() { int adId = CECRequest.GetQueryInt("Id", 0); var model = AdService.Get(adId); return(View("Create", model)); }
public void RepositoryContainsNoAds_ShouldReturnEmptyResult() { var sut = new AdService(AdRepositoryMock.Object); var result = sut.Get(OrderAdBy.Time); Assert.Empty(result); }
public ActionResult <IEnumerable <Ad> > Get() { if (!IsLogged()) { return(Unauthorized()); } return(_adService.Get()); }
public void RepositoryContainsAds_ShouldReturnAds() { // arrange AdRepositoryMock.Setup(m => m.Get()).Returns(new List <Ad> { new Ad { Body = "meh" } }); var sut = new AdService(AdRepositoryMock.Object); // act var result = sut.Get(OrderAdBy.Time); // assert Assert.NotEmpty(result); }
public void RepositoryContainsAds_ShouldReturnSortedAds() { // arrange var secondOldest = new Ad { Subject = "secondOldest", Created = new DateTime(2001, 01, 25) }; var oldest = new Ad { Subject = "oldest", Created = new DateTime(2000, 04, 12) }; var newest = new Ad { Subject = "newest", Created = new DateTime(2019, 08, 11) }; var secondNewest = new Ad { Subject = "secondNewest", Created = new DateTime(2018, 09, 29) }; var ads = new List <Ad> { secondOldest, oldest, newest, secondNewest }; AdRepositoryMock.Setup(m => m.Get()).Returns(ads); var sut = new AdService(AdRepositoryMock.Object); // act var result = sut.Get(OrderAdBy.Time).Select(a => a.Created); // assert var sorted = new List <Ad> { newest, secondNewest, secondOldest, oldest } .Select(a => a.Created); Assert.True(sorted.SequenceEqual(result)); }
public Ad Get() { return(adService.Get());//.Result; }