public void InsertMatchs() { TournamentDao tdao = new TournamentDao(database); int t = tdao.Insert(new Tournament("name", DateTime.Now)); PlayerDao pd = new PlayerDao(database); var plist = pd.FindAll(); int p1id = plist[0].ID; int p2id = plist[1].ID; int p3id = plist[2].ID; int p4id = plist[3].ID; Match m = new Match(p1id, p2id, p3id, p4id, t, false); int stat1 = dao.FindAll().Count; dao.Insert(m); int stat2 = dao.FindAll().Count; Assert.IsTrue(stat1 == stat2 - 1); }
public HttpResponseMessage GetAgenda() { IMatchDao MatchDao = DalFactory.CreateMatchDao(database); ITournamentDao to = DalFactory.CreateTournamentDao(database); var list = MatchDao.FindAll(); var listMatchIEn = list.Where(m => { return(!m.Finished); }); // MatchPaginateClass mpc = new MatchPaginateClass(list.Count, list); return(Request.CreateResponse <IEnumerable <Match> >(HttpStatusCode.OK, listMatchIEn)); }
public HttpResponseMessage GetAll() { //if (Authentication.getInstance().isAuthenticateWithHeader(Request)) //{ IMatchDao MatchDao = DalFactory.CreateMatchDao(database); var list = MatchDao.FindAll(); // MatchPaginateClass mpc = new MatchPaginateClass(list.Count, list); return(Request.CreateResponse <IList <Match> >(HttpStatusCode.OK, list)); //} //else //{ // return Request.CreateResponse(HttpStatusCode.Forbidden); //} }
public HttpResponseMessage GetAllByPage(int page, int numberPerPage) { //if (Authentication.getInstance().isAuthenticateWithHeader(Request)) //{ IMatchDao MatchDao = DalFactory.CreateMatchDao(database); var list = MatchDao.FindAll().OrderByDescending(s => s.ID).ToList(); var remain = list.Count - (page - 1) * numberPerPage; var count = remain >= numberPerPage ? numberPerPage : remain; var newlist = list.ToList().GetRange(((page - 1) * numberPerPage), count).OrderBy(s => s.ID).ToList(); MatchPaginateClass mpc = new MatchPaginateClass(list.Count, newlist); return(Request.CreateResponse <MatchPaginateClass>(HttpStatusCode.OK, mpc)); //} //else //{ // return Request.CreateResponse(HttpStatusCode.Forbidden); //} }
public void AssertThatFindAllIsCalled() { _matchDao.FindAll(); _collection.Received().Find(new BsonDocument()); Assert.IsInstanceOf <Task <List <Match> > >(_matchDao.FindAll()); }