public void DeleteEmployee()
        {
            //Arrange
            var service = new TechService();

            //Act
            var director = service.CreateDirector("Директор");

            service.Employees.Remove(director);

            //Assert
            Assert.AreEqual(0, service.Employees.Count);
        }
        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));
        }
Exemplo n.º 3
0
        public void DirectorHandlingTask()
        {
            //Arrange
            var config = new TechServiceConfig
            {
                TimeRange = new TimeRange(TimeSpan.FromSeconds(3)),
                Tm        = TimeSpan.FromSeconds(0),
                Td        = TimeSpan.FromSeconds(1),
            };

            var service = new TechService(config);

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

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

            //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(3, 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);
                Assert.AreEqual(director, service.TaskManager.Done.First(t => t.Description == "Запрос в службу поддержки №3 (для директора)").Handler);
            });

            task.Wait();
        }