public void SetsCorrectStatuses()
            {
                var statuses = new List <string> {
                    "0:1:1", "0:1:6", "11:1:2..4", "0:1:9"
                };

                var filter = new WorkerFilter(new WorkerFilterConfig {
                    Statuses = statuses
                });

                filter.Statuses.Should().Equal(TmAddr.EncodeComplexInteger(0, 1, 1),
                                               TmAddr.EncodeComplexInteger(0, 1, 6),
                                               TmAddr.EncodeComplexInteger(0, 1, 9),
                                               TmAddr.EncodeComplexInteger(11, 1, 2),
                                               TmAddr.EncodeComplexInteger(11, 1, 3),
                                               TmAddr.EncodeComplexInteger(11, 1, 4));
            }
            public void SetsCorrectAnalogs()
            {
                var statuses = new List <string> {
                    "20:1:1", "10:3:5", "0:1:1..5"
                };

                var filter = new WorkerFilter(new WorkerFilterConfig {
                    Statuses = statuses
                });

                filter.Statuses.Should().Equal(TmAddr.EncodeComplexInteger(0, 1, 1),
                                               TmAddr.EncodeComplexInteger(0, 1, 2),
                                               TmAddr.EncodeComplexInteger(0, 1, 3),
                                               TmAddr.EncodeComplexInteger(0, 1, 4),
                                               TmAddr.EncodeComplexInteger(0, 1, 5),
                                               TmAddr.EncodeComplexInteger(10, 3, 5),
                                               TmAddr.EncodeComplexInteger(20, 1, 1));
            }
            public void ReturnsCorrectValueWithAnalogsFilter(int ch, int rtu, int point, bool expected)
            {
                var analogs = new List <string> {
                    "20:3:2..4", "20:3:6"
                };
                var filter = new WorkerFilter(new WorkerFilterConfig {
                    Analogs = analogs
                });
                var analogType = TmNativeDefs.TmDataTypes.Analog;
                var tmEvent    = TmEventUtil.CreateRandomValidTmEvent(dto =>
                {
                    dto.TmType = (short)analogType;
                    dto.Tma    = (int)TmAddr.EncodeComplexInteger(ch, rtu, point);
                });

                var result = filter.IsEventSuitable(tmEvent);

                result.Should().Be(expected);
            }
            public void ReturnsFalseWithStatusesAnalogsFilterAndOverlap()
            {
                var statuses = new List <string> {
                    "10:1:2..4", "10:1:6"
                };
                var analogs = new List <string> {
                    "20:3:2..4", "20:3:6"
                };
                var filter = new WorkerFilter(new WorkerFilterConfig {
                    Statuses = statuses, Analogs = analogs
                });
                var statusType         = TmNativeDefs.TmDataTypes.Status;
                var analogType         = TmNativeDefs.TmDataTypes.Analog;
                var tmEventStatusFalse = TmEventUtil.CreateRandomValidTmEvent(dto =>
                {
                    dto.TmType = (short)statusType;
                    dto.Tma    = (int)TmAddr.EncodeComplexInteger(20, 3, 6);
                });
                var tmEventStatusTrue = TmEventUtil.CreateRandomValidTmEvent(dto =>
                {
                    dto.TmType = (short)statusType;
                    dto.Tma    = (int)TmAddr.EncodeComplexInteger(10, 1, 6);
                });
                var tmEventAnalogFalse = TmEventUtil.CreateRandomValidTmEvent(dto =>
                {
                    dto.TmType = (short)analogType;
                    dto.Tma    = (int)TmAddr.EncodeComplexInteger(10, 1, 6);
                });
                var tmEventAnalogTrue = TmEventUtil.CreateRandomValidTmEvent(dto =>
                {
                    dto.TmType = (short)analogType;
                    dto.Tma    = (int)TmAddr.EncodeComplexInteger(20, 3, 6);
                });

                filter.IsEventSuitable(tmEventStatusFalse).Should().BeFalse();
                filter.IsEventSuitable(tmEventStatusTrue).Should().BeTrue();
                filter.IsEventSuitable(tmEventAnalogFalse).Should().BeFalse();
                filter.IsEventSuitable(tmEventAnalogTrue).Should().BeTrue();
            }