Пример #1
0
        public void Constructors_ConstructDto_ExpectDto()
        {
            Guid         guid         = Guid.NewGuid();
            WorkplaceDto workplaceDto = new WorkplaceDto(guid, LocationType.FAIRYTALE);

            Assert.Equal(LocationType.FAIRYTALE, workplaceDto.LocationType);
            Assert.Equal(guid, workplaceDto.Guid);
        }
Пример #2
0
        public void HandleEmployeeChangedWorkplace(WorkplaceDto workplace, Guid employee, WorkplaceSkill skill)
        {
            if (rideRepo.All().Any(ride => ride.Guid.Equals(workplace.Guid)))
            {
                var ride = rideRepo.All().First(ride => ride.Guid.Equals(workplace.Guid));

                ride.AddEmployee(employee, skill);
            }
        }
Пример #3
0
        public void Setters_ConstructAndUseSetters_ExpectDto()
        {
            Guid         guid         = Guid.NewGuid();
            WorkplaceDto workplaceDto = new WorkplaceDto();

            workplaceDto.Guid         = guid;
            workplaceDto.LocationType = LocationType.RIDE;

            Assert.Equal(guid, workplaceDto.Guid);
            Assert.Equal(LocationType.RIDE, workplaceDto.LocationType);
        }
Пример #4
0
        public void HandleMessage_ExpectRequestEmployeeEvent_CallsControlFunction()
        {
            WorkplaceDto   workplaceDto         = new WorkplaceDto(Guid.NewGuid(), LocationType.RIDE);
            WorkplaceSkill skill                = WorkplaceSkill.Control;
            Dictionary <string, string> payload = new Dictionary <string, string>()
            {
                { "Workplace", JsonConvert.SerializeObject(workplaceDto) }, { "Skill", skill.ToString() }
            };
            Event incomingEvent = new Event(EventType.RequestEmployee, EventSource.Visitor, payload);

            this.eventConsumer.HandleMessage(JsonConvert.SerializeObject(incomingEvent));

            employeeMock.Verify(control => control.AssignEmployee(It.IsAny <WorkplaceDto>(), It.IsAny <WorkplaceSkill>()), Times.Once);
        }
Пример #5
0
        public override void HandleMessage(string incomingMessage)
        {
            var incomingEvent = JsonConvert.DeserializeObject <Event>(incomingMessage);

            if (incomingEvent is not null && incomingEvent.Type.Equals(EventType.RequestEmployee) &&
                incomingEvent.Payload.TryGetValue("Workplace", out var workplaceString) &&
                incomingEvent.Payload.TryGetValue("Skill", out var skillString))
            {
                WorkplaceDto workplaceDto = JsonConvert.DeserializeObject <WorkplaceDto>(workplaceString);
                if (Enum.TryParse(skillString, out WorkplaceSkill skill))
                {
                    employeeControl.AssignEmployee(workplaceDto, skill);
                }
            }
        }
Пример #6
0
        public void GoToWorkAndStop_GoToRideAndStop_ExpectRide()
        {
            WorkplaceDto ride     = new WorkplaceDto(Guid.NewGuid(), LocationType.RIDE);
            Employee     employee = new Employee("Jan", "Jansen", new List <WorkplaceSkill>()
            {
                WorkplaceSkill.Engineer
            });

            employee.GoToWork(ride, WorkplaceSkill.Engineer);
            Assert.Equal(WorkplaceSkill.Engineer, employee.ActiveSkill);
            Assert.Equal(ride, employee.ActiveWorkplace);

            employee.StopWork();
            Assert.Null(employee.ActiveSkill);
            Assert.Null(employee.ActiveWorkplace);
        }
        public void GetEmployee_givenRide_ExpectEmployee()
        {
            ILogger <EmployeeControl> logger = Mock.Of <ILogger <EmployeeControl> >();
            INameService    nameService      = new NameService();
            IEventProducer  eventProducer    = Mock.Of <IEventProducer>();
            EmployeeControl employeeControl  = new EmployeeControl(nameService, logger, eventProducer);

            Employee     employee = employeeControl.HireEmployee("First", "Last", WorkplaceSkill.Control);
            WorkplaceDto ride     = new WorkplaceDto(Guid.NewGuid(), LocationType.RIDE);

            employee.GoToWork(ride, WorkplaceSkill.Engineer);

            List <Employee> result = employeeControl.GetEmployees(ride);

            Assert.Contains(employee, result);
        }
        public void AssignEmployee_givenRideAndSkill_ExpectEmployeeAssigned()
        {
            ILogger <EmployeeControl> logger = Mock.Of <ILogger <EmployeeControl> >();
            INameService    nameService      = new NameService();
            IEventProducer  eventProducer    = Mock.Of <IEventProducer>();
            EmployeeControl employeeControl  = new EmployeeControl(nameService, logger, eventProducer);

            WorkplaceDto ride = new WorkplaceDto(Guid.NewGuid(), LocationType.RIDE);

            employeeControl.AssignEmployee(ride, WorkplaceSkill.Control);

            List <Employee> result = employeeControl.GetEmployees(ride);

            Assert.NotEmpty(result);
            Assert.Equal(ride, result[0].ActiveWorkplace);
            Assert.Equal(WorkplaceSkill.Control, result[0].ActiveSkill);
        }
Пример #9
0
 public void GoToWork(WorkplaceDto workspace, WorkplaceSkill skill)
 {
     ActiveWorkplace = workspace;
     ActiveSkill     = skill;
 }