public void Initialise()
        {
            this.inactivityThresholdPeriod = int.Parse(ConfigurationManager.AppSettings["InactivityThresholdPeriod"]);
            this.reviewEventyTypeCode = ConfigurationManager.AppSettings["ReviewEventyTypeCode"];
            this.inactivityDetectionProcess = ConfigurationManager.AppSettings["InactivityDetectionProcess"];
            
            var container = new UnityContainer();
            ObjectFactory.Instance = new ObjectFactory(container);
            this.inactivityTask = new InactivityDetectionTask();
            this.processes = new List<ITaskProcess>();
            this.processEvents = new List<IProcessEvent>();
            
            var taskService = MockRepository.GenerateStub<ITaskService>();
            container.RegisterInstance(taskService);
            taskService.Stub(a => a.FindActiveProcesses(null)).IgnoreArguments().Return(this.processes);
            taskService.Stub(a => a.FindProcessEvents(null, 0, 0)).IgnoreArguments().Return(this.processEvents);

            this.claimHeader = new BusinessComponentBuilder<ClaimHeader>()
                    .SetProperty(a => a.ClaimReference = "CH Reference")
                    .SetProperty(a => a.CustomCode20 = MaxClaimDetails.ToString())
                    .Add(new BusinessComponentBuilder<ClaimDetail>()
                        .SetProperty(a => a.ClaimDetailReference = "CD1 Reference"))
                    .Add(new BusinessComponentBuilder<ClaimDetail>()
                        .SetProperty(a => a.ClaimDetailReference = "CD2 Reference"))
                    .Add(new BusinessComponentBuilder<ClaimInvolvement>()
                        .SetProperty(a => a.ClaimInvolvementType = (short)StaticValues.LinkableComponentType.NameInvolvement)
                        .Add(new BusinessComponentBuilder<ClaimNameInvolvement>()
                            .SetProperty(a => a.NameInvolvementType = (short)StaticValues.NameInvolvementType_ClaimNameInvolvement.MainClaimHandler)
                            .SetProperty(a => a.NameInvolvementMaintenanceStatus = (short)StaticValues.ClaimNameInvolvementMaintenanceStatus.Latest)
                            .SetProperty(a => a.NameID = 2)))
                    .Build();

            var claimEntities = MockRepository.GenerateStub<IClaimsQuery>();
            this.targetClaimEvent = new ClaimEvent();
            this.targetUser = new User { UserID = 999};

            Func<DateTime, IEnumerable<long>, ILookup<ClaimHeader, ClaimDetail>> returnLookup = (x, y) => this.claimHeader.InternalClaimDetails.ToLookup(a => a.ClaimHeader);
            claimEntities.Stub(a => a.GetInactiveClaims(DateTime.Now, null)).IgnoreArguments().Do((Func<DateTime, IEnumerable<long>, ILookup<ClaimHeader, ClaimDetail>>)returnLookup);
            container.RegisterInstance<IClaimsQuery>(claimEntities);
            MockRepository repository = new MockRepository();
            container.RegisterInstance(MockRepository.GenerateStub<ICopyValidation>());
            this.claimEventTransaction = new MockBusinessTransaction(new TransactionContext(string.Empty, string.Empty, string.Empty));
            this.claimEventTransaction.Context.SetUsage(BusinessProcessUsage.Updateable);
            this.claimEventTransaction.Component = this.targetClaimEvent;
            container.RegisterInstance<IBusinessTransaction>("Claims.CreateEvent", this.claimEventTransaction);

            var metadataEntities = MockRepository.GenerateStub<IMetadataQuery>();
            metadataEntities.Stub(a => a.GetEventTypeVersion(null)).IgnoreArguments().Return(new EventTypeVersion[] { }.AsQueryable());
            metadataEntities.Stub(a => a.GetUserByNameId(2)).Return(this.targetUser);
            container.RegisterInstance(metadataEntities);
            container.RegisterInstance<IMessageService>(new MockMessagingService());

            this.inactivityTask.GetInactiveClaimDetails = this.GetInactiveTestClaims;
        }
Ejemplo n.º 2
0
		public void Initialize()
		{
			string qualityControlEventTypeCode = ClaimsBusinessLogicHelper.ResolveMandatoryConfig<string>(QualityControlEventTypeCode);
			string processName = ClaimsBusinessLogicHelper.ResolveMandatoryConfig<string>(QualityControlProcess);
			string claimUserRoleCode = ClaimsBusinessLogicHelper.ResolveMandatoryConfig<string>(ClaimUserRoleCode);

			var container = new UnityContainer();
			ObjectFactory.Instance = new ObjectFactory(container);
			this.qualityCheckTask = new QualityCheckTask();
			this.processes = new List<ITaskProcess>();

			List<string> processNames = new List<string>();

			object[] parameters = new object[] { XiapConstants.XIAP_DATASOURCE };
			this.taskService = MockRepository.GenerateStub<ITaskService>();
			container.RegisterInstance(this.taskService);
			this.taskService.Stub(a => a.GetFinishedTasksForUserByDateRange(null, null, DateTime.Now, DateTime.Now)).IgnoreArguments().Return(this.processes);

			this.claimEntities = MockRepository.GenerateStub<IClaimsQuery>();
            container.RegisterInstance<IClaimsQuery>(this.claimEntities);
	
			this.claimHeader = new BusinessComponentBuilder<ClaimHeader>()
					.SetProperty(a => a.ClaimReference = "CH Reference")
					.Add(new BusinessComponentBuilder<ClaimDetail>()
						.SetProperty(a => a.ClaimDetailReference = "CD1 Reference"))
                    .Add(new BusinessComponentBuilder<ClaimInvolvement>()
						.SetProperty(a => a.ClaimInvolvementType = (short)StaticValues.LinkableComponentType.NameInvolvement)
                        .Add(new BusinessComponentBuilder<ClaimNameInvolvement>()
							.SetProperty(a => a.NameInvolvementType = (short)StaticValues.NameInvolvementType_ClaimNameInvolvement.MainClaimHandler)
							.SetProperty(a => a.NameInvolvementMaintenanceStatus = (short)StaticValues.ClaimNameInvolvementMaintenanceStatus.Latest)
							.SetProperty(a => a.NameID = 2)))
					.Build();
			
			this.targetUser = new User { UserID = 999, UserIdentity = "TestUser" };
			var metadataEntities = MockRepository.GenerateStub<IMetadataQuery>();
			container.RegisterInstance(metadataEntities);
			metadataEntities.Stub(a => a.GetUserByNameId(2)).Return(this.targetUser);
			metadataEntities.Stub(a => a.GetUsersByRole("Developer")).IgnoreArguments().Return(new List<User>() { this.targetUser });

			MockRepository repository = new MockRepository();
			container.RegisterInstance(MockRepository.GenerateStub<ICopyValidation>());
			this.claimEventTransaction = new MockBusinessTransaction(new TransactionContext(String.Empty, String.Empty,String.Empty));
			this.claimEventTransaction.Context.SetUsage(BusinessProcessUsage.Updateable);
			this.targetClaimEvent = new ClaimEvent();
			this.claimEventTransaction.Component = this.targetClaimEvent;
			container.RegisterInstance<IBusinessTransaction>("Claims.CreateEvent", this.claimEventTransaction);
		}