Ejemplo n.º 1
0
        public void ManagerHandlingTask()
        {
            //Arrange
            var config = new TechServiceConfig
            {
                TimeRange = new TimeRange(TimeSpan.FromSeconds(2)),
                Tm        = TimeSpan.FromSeconds(0),
            };

            var service = new TechService(config);

            //Act
            service.CreateTask("Запрос в службу поддержки №1");
            service.CreateTask("Запрос в службу поддержки №2 (для менеджера)");

            Employee operator1 = service.CreateOperator("Оператор");
            Employee manager   = service.CreateManager("Менеджер");

            //Assert
            var task = Task.Run(async() => {
                //Ждем выполнения всех заявок
                while (!service.TaskManager.AllDone)
                {
                    await Task.Delay(500);
                }

                Assert.AreEqual(0, service.TaskManager.InQueue.Count());
                Assert.AreEqual(0, service.TaskManager.InWork.Count());
                Assert.AreEqual(2, service.TaskManager.Done.Count());
                Assert.AreEqual(operator1, service.TaskManager.Done.First(t => t.Description == "Запрос в службу поддержки №1").Handler);
                Assert.AreEqual(manager, service.TaskManager.Done.First(t => t.Description == "Запрос в службу поддержки №2 (для менеджера)").Handler);
            });

            task.Wait();
        }
        public void CreateEmployees()
        {
            //Arrange
            var service = new TechService();
            //Act
            var director  = service.CreateDirector("Директор");
            var manager   = service.CreateManager("Менеджер");
            var operator1 = service.CreateOperator("Оператор №1");
            var operator2 = service.CreateOperator("Оператор №2");

            //Assert
            Assert.AreEqual(4, service.Employees.Count);
            Assert.AreEqual(1, service.Employees.Directors.Count);
            Assert.AreEqual(1, service.Employees.Managers.Count);
            Assert.AreEqual(2, service.Employees.Operators.Count);
            Assert.IsInstanceOfType(director, typeof(Director));
            Assert.IsInstanceOfType(manager, typeof(Manager));
            Assert.IsInstanceOfType(operator1, typeof(Operator));
            Assert.IsInstanceOfType(operator2, typeof(Operator));
        }