コード例 #1
0
        public void SampleTransformer_Transform_Success()
        {
            var readerId    = "2";
            var transformer = ComponentRegistration.CreateInstance <ITransformer>(TYPE_SAMPLE_TRANSFORMER);
            var config      = ConfigurationTests.CreateTransformerConfig("4", ConfigurationTests.CreateMapperConfig("3", "4"), readerId);
            var handler     = new MockTransformationHandler();

            transformer.Configure(config, handler);

            var dataPoint = new KeyValuePair <string, object>("ABC", "Some Value");

            var dataRow = new EntityCollection();

            dataRow.Entities.Add(dataPoint.Key, dataPoint.Value);

            var data = new List <IEntityCollection>();

            data.Add(dataRow);

            transformer.HandleData(readerId, data, new Dictionary <string, string>()).Wait();

            handler.Invoked.Should().BeTrue();
            handler.SenderId.Should().Equals(readerId);

            handler.Data.Count.Should().Equals(1);
            foreach (var row in handler.Data)
            {
                row.GetType().Should().Be(typeof(MockEntity));
            }
        }
コード例 #2
0
        public void CollectorFactory_CreatePublisher_Succeeds()
        {
            var endpointConfig = CreateEndPointConfig("10", "URI", "http://acme.com/ivanti/uno/discovery");
            var config         = new PublisherConfiguration()
            {
                Id            = "4",
                Type          = TYPE_PUBLISHER,
                EndpointId    = "1",
                TransformerId = "4"
            };
            var handler   = new MockTransformationHandler();
            var publisher = CollectorFactory.CreatePublisher(config, endpointConfig);

            publisher.Should().NotBeNull();
        }
コード例 #3
0
        public void CollectorFactory_CreateTransformer_Succeeds()
        {
            var mapperConfigs = new List <MapperConfiguration>();

            var config = new TransformerConfiguration()
            {
                Id       = "4",
                Type     = TYPE_TRANSFORMER,
                Mappers  = mapperConfigs,
                ReaderId = "2"
            };

            mapperConfigs.Add(CreateMapperConfig("3", config.Id));

            var handler     = new MockTransformationHandler();
            var transformer = CollectorFactory.CreateTransformer(config, handler);

            transformer.Should().NotBeNull();
        }
コード例 #4
0
        public void Transformer_HandleData_PublisherInvoked()
        {
            var mapperConfig = ConfigurationTests.CreateMapperConfig("3", "4");
            var tconfig      = ConfigurationTests.CreateTransformerConfig("4", mapperConfig, "2");
            var handler      = new MockTransformationHandler();

            var transformer = CollectorFactory.CreateTransformer(tconfig, handler);

            transformer.Should().NotBeNull();

            List <IEntityCollection> data = new List <IEntityCollection>();
            IEntityCollection        row  = new EntityCollection();

            row.Entities.Add("foo", "bar");
            data.Add(row);

            transformer.HandleData("2", data, new Dictionary <string, string>()).Wait();

            handler.Invoked.Should().BeTrue();
            handler.Data.Count.Should().BeGreaterThan(0);
        }