public void UpdateShouldUpdateValidAgencyAgent() { AgencyAgent toUpdate = agencyAgentRepo.Insert(testAgencyAgent).Data; toUpdate.DeactivationDate = new DateTime(21, 01, 02); toUpdate.IsActive = false; Response response = agencyAgentRepo.Update(toUpdate); Assert.IsTrue(response.Success); Assert.IsTrue(String.IsNullOrEmpty(response.Message)); }
public Response <AgencyAgent> Insert(AgencyAgent agencyAgent) { Response <AgencyAgent> response = new Response <AgencyAgent>(); response.Data = agencyAgent; context.AgencyAgent.Add(agencyAgent); response.Success = context.SaveChanges() == 1; if (!response.Success) { response.Message += "Could not add AgencyAgent"; } return(response); }
public void UpdateWithNoIdShouldNotUpdate() { agencyAgentRepo.Insert(testAgencyAgent); AgencyAgent toUpdate = new AgencyAgent { AgentId = 2, AgencyId = 2 }; Response response = agencyAgentRepo.Update(toUpdate); Assert.IsFalse(response.Success); Assert.AreEqual("AgencyAgent not found", response.Message); }
public static AgencyAgent MakeAgencyAgent3() { AgencyAgent agencyAgent = new AgencyAgent() { AgencyId = 1, AgentId = 4, SecurityClearanceId = 1, BadgeId = new Guid("3c12153d-b366-40df-a36d-bd9f99870108"), ActivationDate = DateTime.Parse("4/11/2008"), DeactivationDate = DateTime.Parse("4/21/2014"), IsActive = 1, }; return(agencyAgent); }
public Response Update(AgencyAgent agencyAgent) { Response response = new Response(); try { context.AgencyAgent.Update(agencyAgent); response.Success = context.SaveChanges() == 1; } catch { response.Message += $"AgencyAgent not found"; } return(response); }
public Response Delete(int agencyid, int agentid) { Response response = new Response(); AgencyAgent toDelete = context.AgencyAgent.Find(agencyid, agentid); if (toDelete == null) { response.Message += $"AgencyAgent with ID {agencyid}, {agentid} not found"; response.Success = false; return(response); } context.AgencyAgent.Remove(toDelete); response.Success = context.SaveChanges() == 1; return(response); }
public void Setup() { context = GetDbContext(); context.Database.EnsureDeleted(); context.Database.EnsureCreated(); agencyAgentRepo = new AgencyAgentEFRepo(context); testAgencyAgent = new AgencyAgent { AgentId = 1, AgencyId = 1, ActivationDate = new DateTime(20, 1, 1), IsActive = true, SecurityClearanceId = 1 }; }
public void DeletingAgencyAndDepedencies() { Response aResponse = new Response(); agencyRepo.Insert(AGENCY1); AgencyAgent agencyAgent = AgencyAgentTesting.AGENCYAGENT1; agencyAgent.Agency = AGENCY1; agencyagentRepo.Insert(agencyAgent); Mission mission = MissionTesting.MISSION1; mission.Agency = AGENCY1; missionRepo.Insert(mission); aResponse = agencyRepo.Delete(1); Assert.IsTrue(aResponse.Success); }
public void DeleteingDependencyAndAgentObject() { Response aResponse = new Response(); repo.Insert(AGENT1); Alias alias = AliasTesting.ALIAS; alias.Agent = AGENT1; aliasRepo.Insert(alias); AgencyAgent agencyAgent = AgencyAgentTesting.AGENCYAGENT1; agencyAgent.Agent = AGENT1; agencyAgentRepo.Insert(agencyAgent); aResponse = repo.Delete(1); Assert.IsTrue(aResponse.Success); }