예제 #1
0
        public void Test()
        {
            // Arrange
            testContext = new TestContext();
            var properties = new EntityMetadataPart();

            properties.Properties.Add(CluedIn.Core.Data.Vocabularies.Vocabularies.CluedInOrganization.Website, "http://sitecore.net");
            properties.Properties.Add(CluedIn.Core.Data.Vocabularies.Vocabularies.CluedInOrganization.AddressCountryCode, "uk");
            properties.Properties.Add("Website", "http://sitecore.net.com");

            IEntityMetadata entityMetadata = new EntityMetadataPart()
            {
                Name       = "Sitecore",
                EntityType = EntityType.Organization,
                Properties = properties.Properties
            };

            var externalSearchProvider = new Mock <CompanyHouseExternalSearchProvider>(MockBehavior.Loose);
            var clues = new List <CompressedClue>();

            externalSearchProvider.CallBase = true;

            testContext.ProcessingHub.Setup(h => h.SendCommand(It.IsAny <ProcessClueCommand>())).Callback <IProcessingCommand>(c => clues.Add(((ProcessClueCommand)c).Clue));
            //this.testContext.Container.Register(Component.For<IPropertyTranslationService>().UsingFactoryMethod(() => new PropertyTranslationService()));
            testContext.Container.Register(Component.For <IExternalSearchProvider>().UsingFactoryMethod(() => externalSearchProvider.Object));

            var context  = testContext.Context.ToProcessingContext();
            var command  = new ExternalSearchCommand();
            var actor    = new ExternalSearchProcessingAccessor(context.ApplicationContext);
            var workflow = new Mock <Workflow>(MockBehavior.Loose, context,
                                               new EmptyWorkflowTemplate <ExternalSearchCommand>())
            {
                CallBase = true
            };

            command.With(context);
            command.OrganizationId = context.Organization.Id;
            command.EntityMetaData = entityMetadata;
            command.Workflow       = workflow.Object;
            context.Workflow       = command.Workflow;

            // Act
            var result = actor.ProcessWorkflowStep(context, command);

            Assert.Equal(WorkflowStepResult.Repeat.SaveResult, result.SaveResult);

            result = actor.ProcessWorkflowStep(context, command);
            Assert.Equal(WorkflowStepResult.Success.SaveResult, result.SaveResult);
            context.Workflow.AddStepResult(result);

            context.Workflow.ProcessStepResult(context, command);

            // Assert
            testContext.ProcessingHub.Verify(h => h.SendCommand(It.IsAny <ProcessClueCommand>()), Times.AtLeastOnce);

            Assert.True(clues.Count > 0);
        }
예제 #2
0
        public void Test()
        {
            //testContext.Container.Install(new InstallComponents());

            var properties = new EntityMetadataPart();

            properties.Properties.Add(HelloWorldVocabularies.User.Id, "1");


            // Arrange

            _testContext.Container.Install(new InstallComponents());

            IEntityMetadata entityMetadata = new EntityMetadataPart()
            {
                Name       = "jsonplaceholder",
                EntityType = EntityType.Person,
                Properties = properties.Properties
            };


            //var clues = new List<CompressedClue>();

            //_testContext.ProcessingHub.Setup(h => h.SendCommand(It.IsAny<ProcessClueCommand>())).Callback<IProcessingCommand>(c => clues.Add(((ProcessClueCommand)c).Clue));

            _testContext.Container.Register(Component.For <IExternalSearchProvider>().UsingFactoryMethod(() => new HelloWorldExternalSearchProvider(_testContext.Container.Resolve <IHelloWorldClient>())));


            var processingContext  = _testContext.Context.ToProcessingContext();
            var command            = new ExternalSearchCommand();
            var processingAccessor = new ExternalSearchProcessingAccessor(processingContext.ApplicationContext);
            var commandWorkflow    = new Workflow(processingContext, new EmptyWorkflowTemplate <ExternalSearchCommand>());

            command.With(processingContext);
            command.OrganizationId     = processingContext.Organization.Id;
            command.EntityMetaData     = entityMetadata;
            command.Workflow           = commandWorkflow;
            processingContext.Workflow = command.Workflow;

            var stepResult = processingAccessor.ProcessWorkflowStep(processingContext, command);

            Assert.Equal(WorkflowStepResult.Repeat.SaveResult, stepResult.SaveResult);

            stepResult = processingAccessor.ProcessWorkflowStep(processingContext, command);
            Assert.Equal(WorkflowStepResult.Ignored.SaveResult, stepResult.SaveResult);
            //processingContext.Workflow.AddStepResult(result);

            //processingContext.Workflow.ProcessStepResult(processingContext, command);

            //// Assert
            //testContext.ProcessingHub.Verify(h => h.SendCommand(It.IsAny<ProcessClueCommand>()), Times.AtLeastOnce);

            //Assert.True(clues.Count > 0);
        }
예제 #3
0
        public void TestCompanyWithInvalidLeiCode()
        {
            // Arrange
            this.testContext = new TestContext();
            var properties = new EntityMetadataPart();

            properties.Properties.Add(CluedIn.Core.Data.Vocabularies.Vocabularies.CluedInOrganization.CodesLeiCode, "549300TL5406I");

            IEntityMetadata entityMetadata = new EntityMetadataPart()
            {
                Name       = "Saxo Bank",
                EntityType = EntityType.Organization,
                Properties = properties.Properties
            };

            var externalSearchProvider = new Mock <GleifExternalSearchProvider>(MockBehavior.Loose);
            var clues = new List <CompressedClue>();

            externalSearchProvider.CallBase = true;

            this.testContext.ProcessingHub.Setup(h => h.SendCommand(It.IsAny <ProcessClueCommand>())).Callback <IProcessingCommand>(c => clues.Add(((ProcessClueCommand)c).Clue));

            this.testContext.Container.Register(Component.For <IExternalSearchProvider>().UsingFactoryMethod(() => externalSearchProvider.Object));

            var context  = this.testContext.Context.ToProcessingContext();
            var command  = new ExternalSearchCommand();
            var actor    = new ExternalSearchProcessingAccessor(context.ApplicationContext);
            var workflow = new Mock <Workflow>(MockBehavior.Loose, context, new EmptyWorkflowTemplate <ExternalSearchCommand>());

            workflow.CallBase = true;

            command.With(context);
            command.OrganizationId = context.Organization.Id;
            command.EntityMetaData = entityMetadata;
            command.Workflow       = workflow.Object;
            context.Workflow       = command.Workflow;

            // Act
            var result = actor.ProcessWorkflowStep(context, command);

            Assert.Equal(WorkflowStepResult.Ignored.SaveResult, result.SaveResult);

            result = actor.ProcessWorkflowStep(context, command);
            context.Workflow.AddStepResult(result);
            context.Workflow.ProcessStepResult(context, command);

            // Assert
            this.testContext.ProcessingHub.Verify(h => h.SendCommand(It.IsAny <ProcessClueCommand>()), Times.Never);

            Assert.True(clues.Count == 0);
        }
예제 #4
0
        public void Test()
        {
            // Arrange
            this.testContext = new TestContext();
            IEntityMetadata entityMetadata = new EntityMetadataPart()
            {
                Name       = "Nordea",
                EntityType = EntityType.Organization
            };

            var externalSearchProvider = new Mock <ClearBitExternalSearchProvider>(MockBehavior.Loose);
            var clues = new List <CompressedClue>();

            externalSearchProvider.CallBase = true;

            this.testContext.ProcessingHub.Setup(h => h.SendCommand(It.IsAny <ProcessClueCommand>())).Callback <IProcessingCommand>(c => clues.Add(((ProcessClueCommand)c).Clue));

            this.testContext.Container.Register(Component.For <IExternalSearchProvider>().UsingFactoryMethod(() => externalSearchProvider.Object));

            var context  = this.testContext.Context.ToProcessingContext();
            var command  = new ExternalSearchCommand();
            var actor    = new ExternalSearchProcessingAccessor(context.ApplicationContext);
            var workflow = new Mock <Workflow>(MockBehavior.Loose, context, new EmptyWorkflowTemplate <ExternalSearchCommand>());

            workflow.CallBase = true;

            command.With(context);
            command.OrganizationId = context.Organization.Id;
            command.EntityMetaData = entityMetadata;
            command.Workflow       = workflow.Object;
            context.Workflow       = command.Workflow;

            // Act
            var result = actor.ProcessWorkflowStep(context, command);

            Assert.Equal(WorkflowStepResult.Repeat.SaveResult, result.SaveResult);

            result = actor.ProcessWorkflowStep(context, command);
            Assert.Equal(WorkflowStepResult.Success.SaveResult, result.SaveResult);
            context.Workflow.AddStepResult(result);

            context.Workflow.ProcessStepResult(context, command);

            // Assert
            this.testContext.ProcessingHub.Verify(h => h.SendCommand(It.IsAny <ProcessClueCommand>()), Times.AtLeastOnce);

            Assert.True(clues.Count > 0);
        }