当前位置: 首页>>代码示例>>C#>>正文


C# DataAccess.SaveTournamentAssignment方法代码示例

本文整理汇总了C#中DataAccess.SaveTournamentAssignment方法的典型用法代码示例。如果您正苦于以下问题:C# DataAccess.SaveTournamentAssignment方法的具体用法?C# DataAccess.SaveTournamentAssignment怎么用?C# DataAccess.SaveTournamentAssignment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataAccess的用法示例。


在下文中一共展示了DataAccess.SaveTournamentAssignment方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TournamentAssignment_SelectAddSelectDeleteSelect_OK

        public void TournamentAssignment_SelectAddSelectDeleteSelect_OK()
        {
            using (System.Transactions.TransactionScope updateTransaction =
              new System.Transactions.TransactionScope())
            {
                string connectionString = GetConnectionstring();
                DataAccess d2 = new DataAccess(connectionString);

                Tournament t = new Tournament();
                t.Id = -1;
                t.Name = "TESTING";
                d2.SaveTournament(t);

                Assignment a = new Assignment();
                a.AssignmentId = -1;
                a.AssignmentName = "ASSIGNMENT";
                d2.SaveAssignment(a);

                List<TournamentAssignment> tournamentAssignmentsBefore = d2.GetTournamentAssignmentsForTournament(t.Id);
                //there should be no assignments for the new tournament
                Assert.AreEqual(tournamentAssignmentsBefore.Count, 0);

                TournamentAssignment ta = new TournamentAssignment();
                ta.TournamentAssignmentId = -1;
                ta.TournamentId = t.Id;
                ta.AssignmentId = a.AssignmentId;
                ta.AssignmentOrder = 1;
                ta.Points1 = 100;
                ta.Points2 = 50;
                ta.Points3 = 25;
                ta.Active = false;

                d2.SaveTournamentAssignment(ta);
                //id should be set
                Assert.AreNotEqual(ta.TournamentAssignmentId, -1);

                List<TournamentAssignment> tournamentAssignmentsAfterSave = d2.GetTournamentAssignmentsForTournament(t.Id);
                //there should be one more
                Assert.AreEqual(tournamentAssignmentsAfterSave.Count, tournamentAssignmentsBefore.Count + 1);

                TournamentAssignment byId = d2.GetTournamentAssignmentById(ta.TournamentAssignmentId);
                Assert.AreEqual(ta.Points1, byId.Points1);
                Assert.AreEqual(ta.Points2, byId.Points2);
                Assert.AreEqual(ta.Points3, byId.Points3);
                Assert.AreEqual(ta.Active, byId.Active);
                Assert.AreEqual(a.AssignmentName, byId.AssignmentName);

                d2.DeleteTournamentAssignment(ta.TournamentAssignmentId);

                List<TournamentAssignment> tournamentAssignmentsAfterDelete = d2.GetTournamentAssignmentsForTournament(t.Id);
                //after deleting, there should be 0 entries again
                Assert.AreEqual(tournamentAssignmentsBefore.Count, tournamentAssignmentsAfterDelete.Count);
            }
        }
开发者ID:ruudkok,项目名称:MoCS,代码行数:54,代码来源:DataAccessTests.cs

示例2: TeamSubmit_SelectAddSelectDeleteSelect_OK

        public void TeamSubmit_SelectAddSelectDeleteSelect_OK()
        {
            using (System.Transactions.TransactionScope updateTransaction =
                    new System.Transactions.TransactionScope())
            {
                string connectionString = GetConnectionstring();
                DataAccess d2 = new DataAccess(connectionString);

                Team team = new Team();
                team.ID = -1;
                team.TeamName = "blabla";
                team.TeamMembers = "asdf";
                team.Password = "xxx";
                team.IsAdmin = false;
                d2.SaveTeam(team);

                Tournament t = new Tournament();
                t.Id = -1;
                t.Name = "TESTING";
                d2.SaveTournament(t);

                Assignment a = new Assignment();
                a.AssignmentId = -1;
                a.AssignmentName = "ASSIGNMENT";
                d2.SaveAssignment(a);

                TournamentAssignment ta = new TournamentAssignment();
                ta.TournamentAssignmentId = -1;
                ta.TournamentId = t.Id;
                ta.AssignmentId = a.AssignmentId;
                ta.AssignmentOrder = 1;
                ta.Points1 = 100;
                ta.Points2 = 50;
                ta.Points3 = 25;
                ta.Active = false;
                d2.SaveTournamentAssignment(ta);

                TeamTournamentAssignment tta = new TeamTournamentAssignment();
                tta.TeamTournamentAssignmentId = -1;
                tta.TeamId = team.ID;
                tta.TournamentAssignmentId = ta.TournamentAssignmentId;
                d2.SaveTeamTournamentAssignment(tta);

                Submit submit = new Submit();
                submit.ID = -1;
                submit.TeamTournamentAssignmentId = (int)tta.TeamTournamentAssignmentId;
                submit.TeamId = team.ID;
                byte[] uploadstream = new byte[2] {1,2};
                submit.UploadStream = uploadstream;
                submit.FileName = "somename.cs";
                d2.InsertTeamSubmit(submit);

                Assert.AreNotEqual(submit.ID, -1);

                List<Submit> submits = d2.GetTeamSubmitsForAssignment(submit.TeamTournamentAssignmentId);

                Assert.AreEqual(submits.Count, 1);

                //getbyid
                Submit byId = d2.GetTeamSubmitById(submit.ID);

                Assert.AreEqual(byId.ID,submit.ID);

                d2.DeleteTeamSubmit(submit.ID);

                List<Submit> submitsAfterDelete = d2.GetTeamSubmitsForAssignment(submit.TeamTournamentAssignmentId);

                Assert.AreEqual(0, submitsAfterDelete.Count);

            }
        }
开发者ID:ruudkok,项目名称:MoCS,代码行数:71,代码来源:DataAccessTests.cs

示例3: TeamTournamentAssignment_SelectAddSelectDeleteSelect_OK

        public void TeamTournamentAssignment_SelectAddSelectDeleteSelect_OK()
        {
            using (System.Transactions.TransactionScope updateTransaction =
                new System.Transactions.TransactionScope())
            {
                string connectionString = GetConnectionstring();
                DataAccess d2 = new DataAccess(connectionString);

                Team team = new Team();
                team.ID = -1;
                team.TeamName = "blabla";
                team.TeamMembers = "asdf";
                team.Password = "xxx";
                team.IsAdmin=false;
                d2.SaveTeam(team);

                Tournament t = new Tournament();
                t.Id = -1;
                t.Name = "TESTING";
                d2.SaveTournament(t);

                Assignment a = new Assignment();
                a.AssignmentId = -1;
                a.AssignmentName = "ASSIGNMENT";
                d2.SaveAssignment(a);

                TournamentAssignment ta = new TournamentAssignment();
                ta.TournamentAssignmentId = -1;
                ta.TournamentId = t.Id;
                ta.AssignmentId = a.AssignmentId;
                ta.AssignmentOrder = 1;
                ta.Points1 = 100;
                ta.Points2 = 50;
                ta.Points3 = 25;
                ta.Active = false;

                d2.SaveTournamentAssignment(ta);

                List<TeamTournamentAssignment> ttaBefore = d2.GetTeamTournamentAssignmentsForTeam(ta.TournamentId, team.ID);
                Assert.AreNotEqual(ttaBefore.Count, 0);

                TeamTournamentAssignment tta = new TeamTournamentAssignment();
                tta.TeamTournamentAssignmentId = -1;
                tta.TeamId = team.ID;
                tta.TournamentAssignmentId = ta.TournamentAssignmentId;

                d2.SaveTeamTournamentAssignment(tta);
                //id should be set
                Assert.AreNotEqual(tta.TeamTournamentAssignmentId, -1);

                List<TeamTournamentAssignment> ttaAfterSave = d2.GetTeamTournamentAssignmentsForTeam(ta.TournamentId, team.ID);
                Assert.AreEqual(ttaAfterSave.Count, 1);

                TeamTournamentAssignment ttaById = d2.GetTeamTournamentAssignmentById((int)tta.TeamTournamentAssignmentId);
                Assert.AreEqual(tta.TeamId, ttaById.TeamId);

                d2.DeleteTeamTournamentAssignment((int)tta.TeamTournamentAssignmentId);

                List<TeamTournamentAssignment> ttaAfterDelete = d2.GetTeamTournamentAssignmentsForTeam(ta.TournamentId, team.ID);
            //    Assert.AreEqual(ttaAfterDelete.Count, 0);

            }
        }
开发者ID:ruudkok,项目名称:MoCS,代码行数:63,代码来源:DataAccessTests.cs


注:本文中的DataAccess.SaveTournamentAssignment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。