public void OnAgentStatusChanged(object sender, IntelEventArgs args)
        {
            switch (args.EventType)
            {
                case IntelEventType.AgentEnter:
                    var offline = (from a in this.Agents where a.IsOnline == false select a).ToArray();

                    foreach (var a in offline)
                        this.Agents.Remove(a);

                    AgentViewModel agentViewModel = new AgentViewModel(args.AgentProfile);
                    agentViewModel.IsOnline = true;
                    this.Agents.Add(agentViewModel);
                    break;
                case IntelEventType.AgentLeave:
                    var agent = (from a in this.Agents where a.Agent == args.AgentProfile.Agent select a).First();
                    if (agent != null)
                        agent.IsOnline = false;            
                   
                    break;
            }
        }
 public void Image_IsNotNull_When_AgentProfileImage_IsNull()
 {
     AgentProfile agentProfile = new AgentProfile("agent");
     AgentViewModel target = new AgentViewModel(agentProfile);
     Assert.IsNotNull(target.Image);
 }
 public void IsOnline_IsFalse_At_Creation()
 {
     AgentProfile agentProfile = new AgentProfile("agent");
     AgentViewModel target = new AgentViewModel(agentProfile);
     Assert.IsFalse(target.IsOnline);
 }
 public void Throw_Exception_With_EmpyAgent_In_AgentProfile()
 {
     AgentProfile profile = new AgentProfile(string.Empty);
     AgentViewModel target = new AgentViewModel(profile);
 }
 public void Throw_Excpetion_With_NullAgentProfile()
 {
     AgentViewModel target = new AgentViewModel(null);
 }
 public void PropertyChangedEvent_When_IsOnline_Updated()
 {
     bool result = false;
     AgentProfile agentProfile = new AgentProfile("agent");
     AgentViewModel target = new AgentViewModel(agentProfile);
     target.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler((o,e) => { if (e.PropertyName.Equals("IsOnline")) result = true; });
     target.IsOnline = true;
     Assert.IsTrue(result);
 }
 public void IsOnline_Can_Be_Set()
 {
     AgentProfile agentProfile = new AgentProfile("agent");
     AgentViewModel target = new AgentViewModel(agentProfile);
     target.IsOnline = true;
     Assert.IsTrue(target.IsOnline);
 }