Пример #1
0
        public override string ToString()
        {
            var builder = new StringBuilder();

            builder.Append(Enrichment.ToString());
            builder.Append(" enriched ");
            builder.Append(StandardDof);
            return(builder.ToString());
        }
Пример #2
0
        public void GivenEnrichedMessage_WhenAskingForEnrichedInstance_ThenItShouldReturnNewObjectWithOriginalAndNewEnrichment()
        {
            // arrange
            const string      json              = "{\"Dammit\":\"Bobby!\",\"Results\":[{\"Mother\":\"Will not be happy.\"}]}";
            const string      expected          = "{\"Dammit\":\"Bobby!\",\"Results\":[{\"Mother\":\"Will not be happy.\"},{\"Hello\":\", World.\"}]}";
            ServiceBusMessage serviceBusMessage = new ServiceBusMessage(json);
            Enrichment        enrichment        = new Enrichment();

            // act
            ServiceBusMessage actual = serviceBusMessage.EnrichedInstance(enrichment);

            // assert
            actual.Should().NotBe(serviceBusMessage);
            actual.IsEnriched().Should().BeTrue();
            ((string)actual).Should().Be(expected);
        }
        public IEnumerator TestCreateEnrichment()
        {
            Log.Debug("DiscoveryServiceV2IntegrationTests", "Attempting to CreateEnrichment...");
            Enrichment createEnrichmentResponse = null;
            var        languages = new List <string>();

            languages.Add("en");
            CreateEnrichment enrichment = new CreateEnrichment()
            {
                Name        = "Dictionary Unity",
                Description = "test dictionary",
                Type        = "dictionary",
                Options     = new EnrichmentOptions()
                {
                    EntityType = "keyword",
                    Languages  = languages
                }
            };

            using (FileStream fs = File.OpenRead(enrichmentFile))
            {
                using (MemoryStream ms = new MemoryStream())
                {
                    fs.CopyTo(ms);
                    service.CreateEnrichment(
                        callback: (DetailedResponse <Enrichment> response, IBMError error) =>
                    {
                        Log.Debug("DiscoveryServiceV2IntegrationTests", "CreateEnrichment result: {0}", response.Response);
                        createEnrichmentResponse = response.Result;
                        enrichmentId             = createEnrichmentResponse.EnrichmentId;
                        Assert.IsNotNull(createEnrichmentResponse);
                        Assert.IsNotNull(createEnrichmentResponse.EnrichmentId);
                        Assert.IsNull(error);
                    },
                        projectId: projectId,
                        file: ms,
                        enrichment: enrichment
                        );

                    while (createEnrichmentResponse == null)
                    {
                        yield return(null);
                    }
                }
            }
        }
        public IEnumerator TestGetEnrichment()
        {
            Log.Debug("DiscoveryServiceV2IntegrationTests", "Attempting to GetEnrichment...");
            Enrichment getEnrichmentResponse = null;

            service.GetEnrichment(
                callback: (DetailedResponse <Enrichment> response, IBMError error) =>
            {
                Log.Debug("DiscoveryServiceV2IntegrationTests", "GetEnrichment result: {0}", response.Response);
                getEnrichmentResponse = response.Result;
                Assert.IsNotNull(getEnrichmentResponse);
                Assert.IsNull(error);
            },
                projectId: projectId,
                enrichmentId: enrichmentId
                );

            while (getEnrichmentResponse == null)
            {
                yield return(null);
            }
        }