本文整理汇总了C#中DataAccess.SaveAssignment方法的典型用法代码示例。如果您正苦于以下问题:C# DataAccess.SaveAssignment方法的具体用法?C# DataAccess.SaveAssignment怎么用?C# DataAccess.SaveAssignment使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataAccess
的用法示例。
在下文中一共展示了DataAccess.SaveAssignment方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Assignment_SelectAddSelectDeleteSelect_OK
public void Assignment_SelectAddSelectDeleteSelect_OK()
{
using (System.Transactions.TransactionScope updateTransaction =
new System.Transactions.TransactionScope())
{
string connectionString = GetConnectionstring();
DataAccess d2 = new DataAccess(connectionString);
List<Assignment> assignmentsBefore = d2.GetAssignments();
Assignment assignment = new Assignment();
assignment.AssignmentId = -1;
assignment.AssignmentName = "asfdasfasdfsaf";
Assignment assignmentAfterSave = d2.SaveAssignment(assignment);
Assignment assignmentGetById = d2.GetAssignmentByID(assignment.AssignmentId);
Assert.AreNotEqual(assignment.AssignmentId, -1);
Assert.AreEqual(assignment.AssignmentName, assignmentGetById.AssignmentName);
List<Assignment> assignmentsAfterSave = d2.GetAssignments();
Assert.AreEqual(assignmentsAfterSave.Count, assignmentsBefore.Count + 1);
d2.DeleteAssignment(assignment.AssignmentId);
List<Assignment> assignmentsAfterDelete = d2.GetAssignments();
Assert.AreEqual(assignmentsBefore.Count, assignmentsAfterDelete.Count);
}
}
示例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);
}
}
示例3: 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);
}
}
示例4: 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);
}
}