Ejemplo n.º 1
0
        [InlineData("2F100718D9A3C41E00", "1018D6728000")] // Qbox van R. versie 47 nieuw
        public async Task Handle_NoMeterMessage(string message, string response)
        {
            string correlationId = Guid.NewGuid().ToString();

            var mini = new Mini();
            var ctx  = new QboxDataDumpContext(message, 16, "localhost", "::1", mini);

            var parserFactoryMock = new Mock <IParserFactory>();
            var protocolReader    = new ProtocolReader(_protocolReaderLoggerMock.Object, message.AsMemory());

            var protocolReaderFactoryMock = new Mock <IProtocolReaderFactory>();

            protocolReaderFactoryMock.Setup(pr => pr.Create(It.IsAny <ReadOnlyMemory <char> >())).Returns(protocolReader);

            var smartMeterCounterParser = new SmartMeterCounterParser(_smartMeterLoggerMock.Object, _validators);

            parserFactoryMock.Setup(pf => pf.GetParser(It.IsAny <string>())).Returns(new MiniR21(_miniLoggerMock.Object, protocolReaderFactoryMock.Object, smartMeterCounterParser));

            var sut = new QboxNextDataHandler(correlationId, ctx, parserFactoryMock.Object, _counterStoreServiceMock.Object, _stateStoreServiceMock.Object, _dateMock.Object, _qboxNextDataHandlerLoggerMock.Object);

            var result = await sut.HandleAsync();

            var resultAsText = result.Trim('\x02', '\x03');

            resultAsText.Should().Be(response);
        }
Ejemplo n.º 2
0
        public void ShouldReturnWhForStringTest()
        {
            // arrange
            var parser = new SmartMeterCounterParser(new NullLogger <SmartMeterCounterParser>(), new ICounterValueValidator[]
            {
                new EnergyCounterValueValidator(),
                new GasCounterValueValidator()
            });

            // assert
            // 7 digits 1 decimals
            Assert.AreEqual((ulong)12294600, parser.Parse("(0012294.6*kWh)", 181));
            // 6 digits 2 decimals
            Assert.AreEqual((ulong)1229460, parser.Parse("(001229.46*kWh)", 181));
            // 5 digits 3 decimals
            Assert.AreEqual((ulong)122946, parser.Parse("(00122.946*kWh)", 181));
            // 6 digits 3 decimals
            Assert.AreEqual((ulong)122946, parser.Parse("(000122.946*kWh)", 181));

            // 7 digits 1 decimals
            Assert.AreEqual((ulong)12294600, parser.Parse("(0012294.6*kWh)", 2421));
            // 6 digits 2 decimals
            Assert.AreEqual((ulong)1229460, parser.Parse("(001229.46*kWh)", 2421));
            // 5 digits 3 decimals
            Assert.AreEqual((ulong)122946, parser.Parse("(00122.946*kWh)", 2421));
        }
Ejemplo n.º 3
0
        public void ReadSmartMeterCounterValueForWindParkSmartMeterTest()
        {
            // Arrange
            var parser = new SmartMeterCounterParser(new NullLogger <SmartMeterCounterParser>(), new ICounterValueValidator[]
            {
                new EnergyCounterValueValidator()
            });

            // Act & Assert
            Assert.AreEqual(1002703872, parser.Parse("(1002703.872*kWh)", 281));
        }
Ejemplo n.º 4
0
        [InlineData("2F100718D9A3C41E00", MiniState.Operational)] // Qbox van R.
        public void Parse(string message, MiniState miniState)
        {
            // Arrange
            var protocolReader = new ProtocolReader(_protocolReaderLoggerMock.Object, message.AsMemory());

            var protocolReaderFactoryMock = new Mock <IProtocolReaderFactory>();

            protocolReaderFactoryMock.Setup(pr => pr.Create(It.IsAny <ReadOnlyMemory <char> >())).Returns(protocolReader);

            var smartMeterCounterParser = new SmartMeterCounterParser(_smartMeterLoggerMock.Object, _validators);
            var sut = new MiniR07(_miniLoggerMock.Object, protocolReaderFactoryMock.Object, smartMeterCounterParser);

            // Act
            var result = (MiniParseResult)sut.Parse(message);

            // Assert
            result.Model.Status.Status.Should().Be(miniState);
        }
Ejemplo n.º 5
0
        public async Task Handle_DataMessage()
        {
            string       correlationId = Guid.NewGuid().ToString();
            const string message       =
                @"FAFB070DABB7440780/KFM5KAIFA-METER 1-3:0.2.8(40) 0-0:1.0.0(000102045905W) 
0 - 0:96.1.1(4530303033303030303030303032343133)
1 - 0:1.8.1(000181.011 * kWh)
1 - 0:1.8.2(000182.044 * kWh)
1 - 0:2.8.1(000281.099 * kWh)
1 - 0:2.8.2(000282.077 * kWh)
0 - 0:96.14.0(0001) 1 - 0:1.7.0(00.034 * kW)
1 - 0:2.7.0(00.000 * kW) 0 - 0:17.0.0(999.9 * kW) 0 - 0:96.3.10(1) 0 - 0:96.7.21(00073)
0 - 0:96.7.9(00020) 1 - 0:99.97.0(3)(0 - 0:96.7.19)(000124235657W)(0000003149 * s)(000124225935W)(0000000289 * s)(000101000001W)(2147483647 * s)
1 - 0:32.32.0(00005) 1 - 0:52.32.0(00006) 1 - 0:72.32.0(00001) 1 - 0:32.36.0(00000)
1 - 0:52.36.0(00000) 1 - 0:72.36.0(00000) 0 - 0:96.13.1() 0 - 0:96.13.0() 1 - 0:31.7.0(000 * A)
1 - 0:51.7.0(000 * A) 1 - 0:71.7.0(000 * A) 1 - 0:21.7.0(00.034 * kW) 1 - 0:22.7.0(00.000 * kW) 1 - 0:41.7.0(00.000 * kW)
1 - 0:42.7.0(00.000 * kW) 1 - 0:61.7.0(00.000 * kW) 1 - 0:62.7.0(00.000 * kW) 0 - 1:24.1.0(003)
0 - 1:96.1.0(4730303131303033303832373133363133)
0 - 1:24.2.1(000102043601W)(72869.839 * m3) 0 - 1:24.4.0(1)!583C";

            var mini = new Mini();
            var ctx  = new QboxDataDumpContext(message, 16, "localhost", "::1", mini);

            var parserFactoryMock = new Mock <IParserFactory>();
            var protocolReader    = new ProtocolReader(_protocolReaderLoggerMock.Object, message.AsMemory());

            var protocolReaderFactoryMock = new Mock <IProtocolReaderFactory>();

            protocolReaderFactoryMock.Setup(pr => pr.Create(It.IsAny <ReadOnlyMemory <char> >())).Returns(protocolReader);

            var smartMeterCounterParser = new SmartMeterCounterParser(_smartMeterLoggerMock.Object, _validators);

            parserFactoryMock.Setup(pf => pf.GetParser(It.IsAny <string>())).Returns(new MiniR21(_miniLoggerMock.Object, protocolReaderFactoryMock.Object, smartMeterCounterParser));

            var sut = new QboxNextDataHandler(correlationId, ctx, parserFactoryMock.Object, _counterStoreServiceMock.Object, _stateStoreServiceMock.Object, _dateMock.Object, _qboxNextDataHandlerLoggerMock.Object);

            var result = await sut.HandleAsync();

            var resultAsText = result.Trim('\x02', '\x03');

            resultAsText.Should().Be("FB18D6728000");
        }
Ejemplo n.º 6
0
        public void ShouldReturnExceptionForInvalidFormatTest()
        {
            // arrange
            var parser = new SmartMeterCounterParser(new NullLogger <SmartMeterCounterParser>(), new ICounterValueValidator[]
            {
                new EnergyCounterValueValidator(),
                new GasCounterValueValidator(),
                new LiveCounterValueValidator()
            });

            // assert
            // 8 digits 0 decimals
            // qplat-116: waarden zonder decimalen punt niet meer accepteren
            Assert.Throws <SmartMeterProtocolException>(() => parser.Parse("(00122946*kWh)", 181));
            // 8 digits 0 decimals
            Assert.Throws <SmartMeterProtocolException>(() => parser.Parse("(00122946*kWh)", 2421));
            Assert.Throws <SmartMeterProtocolException>(() => parser.Parse("1-0:1.8.1(0012.946*kWh)", 181));
            Assert.Throws <SmartMeterProtocolException>(() => parser.Parse("1-0:1.8.1(0000012.96*kWh)", 181));
            Assert.Throws <SmartMeterProtocolException>(() => parser.Parse("1-0:1.8.1(12946*kWh)", 181));
        }
Ejemplo n.º 7
0
        [InlineData("2F100718D9A3C41E00", "1018D6728000")] // Qbox van R. versie 47 nieuw
        public void Handle_NoMeterMessage(string message, string response)
        {
            var mini = new Mini();
            var ctx  = new QboxDataDumpContext(message, 16, "localhost", "::1", mini);

            var parserFactoryMock = new Mock <IParserFactory>();
            var protocolReader    = new ProtocolReader(_protocolReaderLoggerMock.Object, message.AsMemory());

            var protocolReaderFactoryMock = new Mock <IProtocolReaderFactory>();

            protocolReaderFactoryMock.Setup(pr => pr.Create(It.IsAny <ReadOnlyMemory <char> >())).Returns(protocolReader);

            var smartMeterCounterParser = new SmartMeterCounterParser(_smartMeterLoggerMock.Object, _validators);

            parserFactoryMock.Setup(pf => pf.GetParser(It.IsAny <string>())).Returns(new MiniR21(_miniLoggerMock.Object, protocolReaderFactoryMock.Object, smartMeterCounterParser));

            var sut = new MiniDataHandler(ctx, _qboxMessagesLoggerMock.Object, parserFactoryMock.Object, _dateMock.Object);

            var result       = sut.Handle();
            var resultAsText = result.Trim('\x02', '\x03');

            resultAsText.Should().Be(response);
        }
Ejemplo n.º 8
0
 public MiniParser(ILogger <MiniParser> logger, IProtocolReaderFactory protocolReaderFactory, SmartMeterCounterParser smartMeterCounterParser)
 {
     _logger = logger ?? throw new ArgumentNullException(nameof(logger));
     _protocolReaderFactory   = protocolReaderFactory ?? throw new ArgumentNullException(nameof(protocolReaderFactory));
     _smartMeterCounterParser = smartMeterCounterParser ?? throw new ArgumentNullException(nameof(smartMeterCounterParser));
 }
Ejemplo n.º 9
0
 public MiniR07(ILogger <MiniR07> logger, IProtocolReaderFactory protocolReaderFactory, SmartMeterCounterParser smartMeterCounterParser) : base(logger, protocolReaderFactory, smartMeterCounterParser)
 {
     _logger = logger;
 }
Ejemplo n.º 10
0
 public MiniResponse(ILogger <MiniResponse> logger, IProtocolReaderFactory protocolReaderFactory, SmartMeterCounterParser smartMeterCounterParser) : base(logger, protocolReaderFactory, smartMeterCounterParser)
 {
     _logger = logger ?? throw new ArgumentNullException(nameof(logger));
 }