public void EventStampIsUnixTimeStampWhenGreaterThan0()
        {
            int timestamp = 5876;
            var huntgroup = new Huntgroup
                                {
                                    time = timestamp
                                };

            Assert.That(huntgroup.EventStamp, Is.EqualTo(new DateTime(1970, 1, 1).AddSeconds(timestamp)));
        }
        public void CreatesGenericForEachAgent()
        {
            var huntgroup = new Huntgroup
                                {
                                    huntgroup = "does not really matter",
                                    agents = new List<Agent> {new Agent(), new Agent()}
                                };

            IEnumerable<Generic> generics = _translator.Translate(huntgroup, _callCopyEntities);

            Assert.That(generics.Count(), Is.EqualTo(2));
        }
        public void GenericTimeComesFromHuntgroupTime()
        {
            int seconds = 1234567890;
            DateTime expectedDateTime = new DateTime(1970, 1, 1).AddSeconds(seconds);
            var huntgroup = new Huntgroup
                                {
                                    time = seconds,
                                    agents = new List<Agent> {new Agent()}
                                };

            Generic generic = _translator.Translate(huntgroup, _callCopyEntities).First();

            Assert.That(generic.CreateDate, Is.EqualTo(expectedDateTime));
        }
        public void ACDCallsIsEqualToActivePendingAutoQueuedOutbound()
        {
            var huntgroup = new Huntgroup
                                {
                                    active = 1,
                                    auto = 2,
                                    outbound = 3,
                                    pending = 4,
                                    queued = 5
                                };

            Socket socket = _translator.Translate(huntgroup, _callCopyEntities).First();

            Assert.That(socket.ACDCalls, Is.EqualTo(15));
        }
        public void TranslatesProperResponseIntoHuntgroup()
        {
            var expectedHuntgroup = new Huntgroup();
            string responseString = "response";
            var webRequest = new Mock<WebRequest>();
            var response = new Mock<WebResponse>();
            var responseStream = new MemoryStream(Encoding.ASCII.GetBytes(responseString));
            var translator = new Mock<IDatastreamDeserializer>();
            var readService = new RevationLiveReadService(webRequest.Object, translator.Object);

            webRequest.Setup(x => x.GetResponse()).Returns(response.Object);
            response.Setup(x => x.GetResponseStream()).Returns(responseStream);
            translator.Setup(x => x.ToHuntgroup(responseString)).Returns(expectedHuntgroup);

            Huntgroup huntgroup = readService.Read();

            Assert.That(huntgroup, Is.SameAs(huntgroup));
        }
        public void EventStampDefaultsToDateTimeMinWhenTimeIs0()
        {
            var huntgroup = new Huntgroup();

            Assert.That(huntgroup.EventStamp, Is.EqualTo(DateTime.MinValue));
        }
        public void StaffedIsEqualToNumberOfAgents()
        {
            var expectedAgentList = new List<Agent>
                                        {
                                            new Agent(),
                                            new Agent(),
                                            new Agent()
                                        };
            var huntgroup = new Huntgroup
                                {
                                    agents = expectedAgentList
                                };

            Socket socket = _translator.Translate(huntgroup, _callCopyEntities).First();

            Assert.That(socket.Staffed, Is.EqualTo(expectedAgentList.Count()));
        }
        public void CallsWaitingEqualsHuntgroupPending()
        {
            int expected = 42;
            var huntgroup = new Huntgroup
                                {
                                    pending = expected
                                };

            Socket socket = _translator.Translate(huntgroup, _callCopyEntities).First();

            Assert.That(socket.CallsWaiting, Is.EqualTo(expected));
        }
        public void InQueuedIsHuntGroupTimeMinusMatchingDialogArrivedWhenStateIsQueued()
        {
            int huntgroupTime = 1000;
            int dialogArrived = 100;
            string agentPid = "good";
            var huntgroup = new Huntgroup
                                {
                                    time = huntgroupTime,
                                    dialogs = new List<Dialog>
                                                  {
                                                      new Dialog
                                                          {
                                                              agents = new List<DialogAgent>
                                                                           {
                                                                               new DialogAgent {pid = agentPid}
                                                                           },
                                                              arrived = dialogArrived,
                                                              state = "queued"
                                                          },
                                                      new Dialog
                                                          {
                                                              agents = new List<DialogAgent>
                                                                           {
                                                                               new DialogAgent {pid = "bad"}
                                                                           },
                                                              arrived = 200
                                                          },
                                                  },
                                    agents = new List<Agent> {new Agent {pid = agentPid}}
                                };

            Generic generic = _translator.Translate(huntgroup, _callCopyEntities).First();

            Assert.That(generic.InQueue, Is.EqualTo(huntgroupTime - dialogArrived));
        }
        public void UnknownPropertiesAreInitializedToZeroOrNull()
        {
            var huntgroup = new Huntgroup
                                {
                                    agents = new List<Agent> {new Agent()}
                                };

            Generic generic = _translator.Translate(huntgroup, _callCopyEntities).First();

            Assert.That(generic.AutomatedCallDirectory, Is.Null);
            Assert.That(generic.AuxReason, Is.Null);
            Assert.That(generic.Extension, Is.Null);
            Assert.That(generic.OnHold, Is.EqualTo(0));
        }
        public void DateIsEqualToHuntgroupEventStamp()
        {
            int expected = 42;
            var huntgroup = new Huntgroup
                                {
                                    time = expected
                                };

            Socket socket = _translator.Translate(huntgroup, _callCopyEntities).First();

            Assert.That(socket.Date, Is.EqualTo(huntgroup.EventStamp));
        }
        public void InAcwIsEqualToWrapUp()
        {
            int expected = 42;
            var huntgroup = new Huntgroup
                                {
                                    wrapup = expected
                                };

            Socket socket = _translator.Translate(huntgroup, _callCopyEntities).First();

            Assert.That(socket.InACW, Is.EqualTo(expected));
        }
        public void AgentsAvailableIsCountOfAgentsWhoAreOnlineInHuntgroupWithAvailableSessions()
        {
            string huntgroupName = "blah";
            var expectedAgentList = new List<Agent>
                                        {
                                            new Agent
                                                {
                                                    groups = new List<Group>
                                                                 {
                                                                     new Group
                                                                         {
                                                                             group = huntgroupName,
                                                                             status = "online",
                                                                             maxSessions = 2,
                                                                             activeSessions = 1
                                                                         }
                                                                 }
                                                },
                                            new Agent
                                                {
                                                    groups = new List<Group>
                                                                 {
                                                                     new Group
                                                                         {
                                                                             group = huntgroupName,
                                                                             status = "online",
                                                                             maxSessions = 1,
                                                                             activeSessions = 0
                                                                         }
                                                                 }
                                                },
                                            new Agent
                                                {
                                                    groups = new List<Group>
                                                                 {
                                                                     new Group
                                                                         {
                                                                             group = huntgroupName,
                                                                             status = "online",
                                                                             maxSessions = 2,
                                                                             activeSessions = 2
                                                                         }
                                                                 }
                                                },
                                            new Agent
                                                {
                                                    groups = new List<Group>
                                                                 {
                                                                     new Group
                                                                         {
                                                                             group = huntgroupName,
                                                                             status = "wrong",
                                                                             maxSessions = 2,
                                                                             activeSessions = 1
                                                                         },
                                                                     new Group
                                                                         {
                                                                             group = "wrong",
                                                                             status = "online",
                                                                             maxSessions = 2,
                                                                             activeSessions = 1
                                                                         }
                                                                 }
                                                }
                                        };
            var huntgroup = new Huntgroup
                                {
                                    huntgroup = huntgroupName,
                                    agents = expectedAgentList
                                };

            Socket socket = _translator.Translate(huntgroup, _callCopyEntities).First();

            Assert.That(socket.AgentsAvailable, Is.EqualTo(2));
        }
        public void AverageACDTimeIsAverageOfHuntgroupTimeMinusActiveDialogsActivityTime()
        {
            int huntgroupTime = 40;
            var expectedDialogs = new List<Dialog>
                                      {
                                          new Dialog {state = "active", activity = 30},
                                          new Dialog {state = "active", activity = 20},
                                          new Dialog {state = "other", activity = 10}
                                      };
            var huntgroup = new Huntgroup
                                {
                                    time = huntgroupTime,
                                    dialogs = expectedDialogs
                                };

            Socket socket = _translator.Translate(huntgroup, _callCopyEntities).First();

            Assert.That(socket.AverageACDTime, Is.EqualTo(15));
        }
        public void ReturnsListContainingASingleSocket()
        {
            var huntgroup = new Huntgroup();

            IEnumerable<Socket> sockets = _translator.Translate(huntgroup, _callCopyEntities);

            Assert.That(sockets.Count(), Is.EqualTo(1));
        }
        public void OldestCallWaitingIsEqualToQueuedLongest()
        {
            int expected = 42;
            var huntgroup = new Huntgroup
                                {
                                    queued_longest = expected
                                };

            Socket socket = _translator.Translate(huntgroup, _callCopyEntities).First();

            Assert.That(socket.OldestCallWaiting, Is.EqualTo(expected));
        }
        public void InRingIsEqualToDialogsWhereAssignedIsGreaterThan0ButActivityEquals0()
        {
            var expectedDialogs = new List<Dialog>
                                      {
                                          new Dialog {assigned = 2, activity = 1},
                                          new Dialog {assigned = 3, activity = 0},
                                          new Dialog {assigned = 4, activity = 0}
                                      };
            var huntgroup = new Huntgroup
                                {
                                    dialogs = expectedDialogs
                                };

            Socket socket = _translator.Translate(huntgroup, _callCopyEntities).First();

            Assert.That(socket.InRing, Is.EqualTo(2));
        }
        public void InCallIsNumberOfAgentsWithActivityGreaterThan0()
        {
            var expectedDialogs = new List<Dialog>
                                      {
                                          new Dialog {activity = 1},
                                          new Dialog {activity = 1},
                                          new Dialog {activity = 0}
                                      };
            var huntgroup = new Huntgroup
                                {
                                    dialogs = expectedDialogs
                                };

            Socket socket = _translator.Translate(huntgroup, _callCopyEntities).First();

            Assert.That(socket.InCall, Is.EqualTo(2));
        }