public void Setup()
        {
            _fakereceiver      = Substitute.For <ITransponderReceiver>();
            _fakevelocity      = Substitute.For <IVelocity>();
            _fakecompassCourse = Substitute.For <ICompassCourse>();

            _uut = new ConvertFilter(_fakereceiver, _fakecompassCourse, _fakevelocity);
        }
Exemple #2
0
        public void WithoutConverter()
        {
            //arrange
            var filter = new ConvertFilter {
                WithoutConverter = 0
            };

            //act

            //assert
            Assert.ThrowsAny <Exception>(() => ConverterTestsData.Items.AutoFilter(filter));
        }
        public void WithoutConverter()
        {
            //arrange
            Init();
            var filter = new ConvertFilter {
                WithoutConverter = 0
            };

            //act

            //assert
            Assert.ThrowsAny <Exception>(() => Context.ConvertItems.AutoFilter(filter));
        }
Exemple #4
0
        public void WithConverter()
        {
            //arrange
            var filter = new ConvertFilter {
                WithConverter = 1
            };

            //act
            var filtered = ConverterTestsData.Items.AutoFilter(filter).ToList();

            //assert
            Assert.Equal(1, filtered.Count);
            Assert.Equal(true, filtered[0].WithConverter);
        }
Exemple #5
0
        public void CONVERT_FILTER_SHOULD_USE_TO_LOWER_ON_CORRECT_KEY()
        {
            //Arrange
            var          filter = new ConvertFilter();
            const string key    = "key";
            const string value  = "HELLO";

            filter.AddToLower(key);
            var eventProperties = new Dictionary <string, object> {
                { key, value }
            };

            //Act
            filter.PrepareEvent(eventProperties);

            //value
            eventProperties[key].Should().Be("hello");
        }
Exemple #6
0
        public void CONVERT_FILTER_SHOULD_RETURN_ZERO_ON_TO_INT_WHEN_VALUE_IS_NOT_A_NUMBER()
        {
            //Arrange
            var          filter = new ConvertFilter();
            const string key    = "key";
            const string value  = "hello";

            filter.AddToInt(key);
            var eventProperties = new Dictionary <string, object> {
                { key, value }
            };

            //Act
            filter.PrepareEvent(eventProperties);

            //value
            eventProperties[key].Should().Be(0);
        }
Exemple #7
0
        public void CONVERT_FILTER_SHOULD_RETURN_VALUE_ITSELF_WHEN_VALUE_IS_INT()
        {
            //Arrange
            var          filter = new ConvertFilter();
            const string key    = "key";
            const int    value  = 111;

            filter.AddToInt(key);
            var eventProperties = new Dictionary <string, object> {
                { key, value }
            };

            //Act
            filter.PrepareEvent(eventProperties);

            //value
            eventProperties[key].Should().Be(value);
        }
Exemple #8
0
        public void CONVERT_FILTER_SHOULD_USE_TO_STRING_ON_CORRECT_KEY()
        {
            //Arrange
            var          filter      = new ConvertFilter();
            const string key         = "key";
            const string stringValue = "hello";

            filter.AddToString(key);
            var obj             = new MockEventObject(stringValue);
            var eventProperties = new Dictionary <string, object> {
                { key, obj }
            };

            //Act
            filter.PrepareEvent(eventProperties);

            //Assert
            eventProperties[key].Should().Be(stringValue);
        }
        public void can_parse_log4net_context_stacks()
        {
            const string sourceKey = "UserName";

            ElasticAppenderFilters oldFilters = null;

            QueryConfiguration(appender =>
            {
                oldFilters = appender.ElasticFilters;
                appender.ElasticFilters = new ElasticAppenderFilters();
                var convert             = new ConvertFilter();
                convert.AddToString(sourceKey);

                var toArray = new ConvertToArrayFilter {
                    SourceKey = sourceKey
                };
                convert.AddToArray(toArray);

                appender.ElasticFilters.AddConvert(convert);
            });

            LogicalThreadContext.Stacks[sourceKey].Push("name1");
            LogicalThreadContext.Stacks[sourceKey].Push("name2");
            _log.Info("hi");

            Client.Refresh(TestIndex);

            var res     = Client.Search <JObject>(s => s.AllIndices().Type("LogEvent").Take(1));
            var doc     = res.Documents.First();
            var usrName = doc[sourceKey];

            Assert.NotNull(usrName);
            Assert.AreEqual("name1", usrName[0].Value <string>());
            Assert.AreEqual("name2", usrName[1].Value <string>());

            QueryConfiguration(appender =>
            {
                appender.ElasticFilters = oldFilters;
            });
        }
Exemple #10
0
 public void AddConvert(ConvertFilter filter)
 {
     AddFilter(filter);
 }