public override void SetUp()
        {
            base.SetUp();

            workitemWriterMock = Repository.StrictMock<WorkitemWriter>();
            eventManagerMock = Repository.StrictMock<IEventManager>();

            eventManager = new EventManager();
            service = new WorkitemWriterHostedService();

            service.Initialize(null, eventManager, null);
        }
        public void UpdateWorkitemTest()
        {
            //given
            WorkitemWriter writer = new WorkitemWriter("Source");
            var defect = new VersionOne.ServiceHost.WorkitemServices.Defect();
            defect.Number = "D-78694";
            defect.ExternalId = "JRA-1000";
            defect.ExternalSystemName = "JIRA";
            UrlToExternalSystem url = new UrlToExternalSystem("http://jira.sabre.com/", "JIRA LINK");
            defect.ExternalUrl = url;

            //when
            writer.UpdateExternalWorkitem(defect);

            //then
            //TODO check if it was executed
        }
        private void InitializeComponents()
        {
            v1Processor = new VersionOneProcessor(configElement["Settings"], logger);
            ComponentRepository.Instance.Register(v1Processor);
            ComponentRepository.Instance.Register(logger);

            workitemWriter = new WorkitemWriter(externalIdFieldName);
            externalWorkitemsQuerier = new ExternalWorkitemQuerier();

            v1Processor.AddProperty(Entity.NameProperty, VersionOneProcessor.PrimaryWorkitemType, false);
            v1Processor.AddProperty(ServerConnector.Entities.Workitem.DescriptionProperty, VersionOneProcessor.PrimaryWorkitemType, false);
            v1Processor.AddProperty(ServerConnector.Entities.Workitem.NumberProperty, VersionOneProcessor.PrimaryWorkitemType, false);
            //v1Processor.AddProperty(ServerConnector.Entities.Workitem.OwnersProperty, VersionOneProcessor.PrimaryWorkitemType, false);
            v1Processor.AddProperty(ServerConnector.Entities.Workitem.OwnersUsernamesProperty, VersionOneProcessor.PrimaryWorkitemType, false);
            v1Processor.AddProperty(externalIdFieldName, VersionOneProcessor.PrimaryWorkitemType, false);
            v1Processor.AddProperty(Entity.ChangeDateUtcProperty, VersionOneProcessor.PrimaryWorkitemType, false);
            v1Processor.AddProperty(Entity.ScopeProperty, VersionOneProcessor.PrimaryWorkitemType, false);
            v1Processor.AddProperty(Entity.ScopeNameProperty, VersionOneProcessor.DefectType, false);
            v1Processor.AddProperty(Entity.CreateDateUtcProperty, VersionOneProcessor.PrimaryWorkitemType, false);
            v1Processor.AddProperty(Entity.CreatedByUsernameProperty, VersionOneProcessor.PrimaryWorkitemType, false);
            v1Processor.AddProperty(Entity.StatusNameProperty, VersionOneProcessor.PrimaryWorkitemType, false);
            v1Processor.AddProperty(Entity.StatusProperty, VersionOneProcessor.PrimaryWorkitemType, true);
            v1Processor.AddProperty(Entity.SourceProperty, VersionOneProcessor.PrimaryWorkitemType, true);
            v1Processor.AddProperty(ServerConnector.Entities.Workitem.PriorityProperty, VersionOneProcessor.PrimaryWorkitemType, true); // to get options list
            v1Processor.AddProperty(ServerConnector.Entities.Workitem.PriorityProperty, VersionOneProcessor.PrimaryWorkitemType, false);

            v1Processor.AddProperty(Entity.NameProperty, VersionOneProcessor.DefectType, false);
            v1Processor.AddProperty(ServerConnector.Entities.Workitem.DescriptionProperty, VersionOneProcessor.DefectType, false);
            v1Processor.AddProperty(ServerConnector.Entities.Workitem.NumberProperty, VersionOneProcessor.DefectType, false);
            //v1Processor.AddProperty(ServerConnector.Entities.Workitem.OwnersProperty, VersionOneProcessor.DefectType, false);
            v1Processor.AddProperty(ServerConnector.Entities.Workitem.OwnersUsernamesProperty, VersionOneProcessor.DefectType, false);
            v1Processor.AddProperty(externalIdFieldName, VersionOneProcessor.DefectType, false);
            v1Processor.AddProperty(Entity.ChangeDateUtcProperty, VersionOneProcessor.DefectType, false);
            v1Processor.AddProperty(Entity.ScopeProperty, VersionOneProcessor.DefectType, false);
            v1Processor.AddProperty(Entity.ScopeNameProperty, VersionOneProcessor.DefectType, false);
            v1Processor.AddProperty(Entity.CreateDateUtcProperty, VersionOneProcessor.DefectType, false);
            v1Processor.AddProperty(Entity.CreatedByUsernameProperty, VersionOneProcessor.DefectType, false);
            v1Processor.AddProperty(Entity.StatusProperty, VersionOneProcessor.DefectType, true);
            v1Processor.AddProperty(Entity.SourceProperty, VersionOneProcessor.DefectType, true);
            v1Processor.AddProperty(ServerConnector.Entities.Workitem.PriorityProperty, VersionOneProcessor.DefectType, false);
            v1Processor.AddProperty(ServerConnector.Entities.Workitem.FoundInBuildProperty, VersionOneProcessor.DefectType, false); // defect-only
            v1Processor.AddProperty(VersionOneProcessor.EnvironmentAttribute, VersionOneProcessor.DefectType, false); // defect-only
            v1Processor.AddProperty(ServerConnector.Entities.Workitem.SeverityLevelProperty, VersionOneProcessor.DefectType, true);

            v1Processor.AddProperty(Entity.NameProperty, VersionOneProcessor.StoryType, false);
            v1Processor.AddProperty(ServerConnector.Entities.Workitem.DescriptionProperty, VersionOneProcessor.StoryType, false);
            v1Processor.AddProperty(ServerConnector.Entities.Workitem.NumberProperty, VersionOneProcessor.StoryType, false);
            //v1Processor.AddProperty(ServerConnector.Entities.Workitem.OwnersProperty, VersionOneProcessor.StoryType, false);
            v1Processor.AddProperty(ServerConnector.Entities.Workitem.OwnersUsernamesProperty, VersionOneProcessor.StoryType, false);
            v1Processor.AddProperty(externalIdFieldName, VersionOneProcessor.StoryType, false);
            v1Processor.AddProperty(Entity.ChangeDateUtcProperty, VersionOneProcessor.StoryType, false);
            v1Processor.AddProperty(Entity.ScopeProperty, VersionOneProcessor.StoryType, false);
            v1Processor.AddProperty(Entity.ScopeNameProperty, VersionOneProcessor.StoryType, false);
            v1Processor.AddProperty(ServerConnector.Entities.Workitem.PriorityProperty, VersionOneProcessor.StoryType, false);
            v1Processor.AddProperty(Entity.CreateDateUtcProperty, VersionOneProcessor.StoryType, false);
            v1Processor.AddProperty(Entity.CreatedByUsernameProperty, VersionOneProcessor.StoryType, false);
            v1Processor.AddProperty(Entity.StatusProperty, VersionOneProcessor.StoryType, true);
            v1Processor.AddProperty(Entity.SourceProperty, VersionOneProcessor.StoryType, true);

            v1Processor.AddProperty(Member.NameProperty, VersionOneProcessor.MemberType, false);
            v1Processor.AddProperty(Member.UsernameProperty, VersionOneProcessor.MemberType, false);

            ComponentRepository.Instance.Register(workitemWriter);
            ComponentRepository.Instance.Register(externalWorkitemsQuerier);
        }