public static void ClassCleanup() { using (var ctx = new DataFlowDbContext()) { AgentAgentChrome aac = ctx.AgentAgentChromes.Find(_agentAgentChromeId); ctx.AgentAgentChromes.Remove(aac); AgentChrome chrome = ctx.AgentChromes.Find(_agentChromeId); ctx.AgentChromes.Remove(chrome); Agent agent = ctx.Agents.Find(_agentId); // Remove the directory with the agent temp file sample.csv System.IO.Directory.Delete(PathUtility.EnsureTrailingSlash(ConfigurationManager.AppSettings["ShareName"]) + agent.Queue.ToString(), true); ctx.Agents.Remove(agent); ctx.SaveChanges(); } }
public void RegisterAgent() { ChromeExtensionController cec = new ChromeExtensionController(); cec.Request = new HttpRequestMessage(); cec.Request.SetConfiguration(new HttpConfiguration()); AgentMessage message = new AgentMessage(); message.uuid = Guid.NewGuid(); HttpResponseMessage response = cec.Register(message); var content = response.Content; Assert.IsNotNull(content); Assert.IsInstanceOfType(content, typeof(ObjectContent <AgentMessage>)); AgentMessage responseMessage = (AgentMessage)((ObjectContent <AgentMessage>)content).Value; Assert.IsNotNull(responseMessage.token); Assert.AreNotEqual(Guid.Parse("00000000-0000-0000-0000-000000000000"), responseMessage.token); _agentGuid = responseMessage.uuid; _agentToken = responseMessage.token; // If we've gotten this far, we've registered a new AgentChrome, let's associate it with the agent using (var ctx = new DataFlowDbContext()) { AgentChrome ac = ctx.AgentChromes.Where(chr => chr.AgentUuid == _agentGuid && chr.AccessToken == _agentToken).FirstOrDefault(); AgentAgentChrome aac = new AgentAgentChrome(); aac.AgentChromeId = ac.Id; aac.AgentId = _agentId; ctx.AgentAgentChromes.Add(aac); ctx.SaveChanges(); _agentChromeId = ac.Id; _agentAgentChromeId = aac.Id; } }