// GET: api/Lottery public IEnumerable <Data.Interface.ILottery> Get() { try { LotteryRepository repo = new LotteryRepository(); return(repo.GetAllLottery()); } catch (Exception exception) { throw new HttpResponseException(new HttpResponseMessage() { StatusCode = HttpStatusCode.InternalServerError, ReasonPhrase = exception.Message }); } }
public void Test_that_lottery_is_added() { // arrange var lottery = new Mock <ILottery>(); lottery.SetupAllProperties(); lottery.SetupGet(x => x.Name).Returns("owdwo"); lottery.SetupGet(x => x.Description).Returns("owdwo"); lottery.SetupGet(x => x.DateOfDraw).Returns(new System.DateTime(2017, 1, 1)); LotteryRepository repo = new LotteryRepository(); // act repo.Save(lottery.Object); // assert Assert.That(repo.GetAllLottery().Count() == 1); }