public static CommandLog GetCommandLog() { CommandLog res = new CommandLog(); res.Name = "GeneratedCommandLog" + RandomIntModifier(); res.Sent = RandomBoolModifier(); res.Timestamp = RandomIntModifier(); return res; }
public static CommandLogDTO Convert(CommandLog from) { CommandLogDTO res = new CommandLogDTO(); res.Id = from.Id; res.Name = from.Name; res.Sent = from.Sent; res.Timestamp = from.Timestamp; res.TokenDTO = TokenDTO.Convert(from.Token); res.CommandDTO = CommandDTO.Convert(from.Command); return res; }
public bool AddCommandToQueue(int commandId, int tokenId) { Command recieved = commRep.GetById(commandId); CommandLog newRecord = new CommandLog(); newRecord.Command = recieved; newRecord.Name = recieved.Name; newRecord.Sent = false; newRecord.Timestamp = Utils.GetUnixTime(); Token token = tokRep.GetById(tokenId); newRecord.Token = token; commLogRep.Save(newRecord); return true; }
public void TestCommandSend() { int id = command[new Random().Next(0, command.Count)].Id; Command recieved = commRep.GetById(id); CommandLog newRecord = new CommandLog(); newRecord.Command = recieved; newRecord.Name = recieved.Name; newRecord.Sent = false; newRecord.Timestamp = Utils.GetUnixTime(); newRecord.Token = token; commLogRep.Save(newRecord); Console.WriteLine("CommLog ID: " + newRecord.Id); List<CommandLog> logs = new List<CommandLog>(commLogRep.GetByDevice(device.Id)); bool found = false; foreach (var log in logs) if (log.Id == newRecord.Id) found = true; Assert.IsTrue(found); }