]> git.basschouten.com Git - openhab-addons.git/blob
7fea0b1af19573c20279ee1e45d0e30e80ac541f
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.lcn.internal.subhandler;
14
15 import static org.mockito.Mockito.verify;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.junit.jupiter.api.BeforeEach;
19 import org.junit.jupiter.api.Test;
20 import org.openhab.binding.lcn.internal.common.LcnChannelGroup;
21 import org.openhab.core.library.types.DecimalType;
22
23 /**
24  * Test class.
25  *
26  * @author Fabian Wolter - Initial contribution
27  */
28 @NonNullByDefault
29 public class LcnModuleS0CounterSubHandlerTest extends AbstractTestLcnModuleSubHandler {
30     private @NonNullByDefault({}) LcnModuleS0CounterSubHandler l;
31
32     @Override
33     @BeforeEach
34     public void setUp() {
35         super.setUp();
36
37         l = new LcnModuleS0CounterSubHandler(handler, info);
38     }
39
40     @Test
41     public void testZero() {
42         l.tryParse("=M000005.C10");
43         verify(handler).updateChannel(LcnChannelGroup.S0INPUT, "1", new DecimalType(0));
44     }
45
46     @Test
47     public void testMaxValue() {
48         l.tryParse("=M000005.C14294967295");
49         verify(handler).updateChannel(LcnChannelGroup.S0INPUT, "1", new DecimalType(4294967295L));
50     }
51
52     @Test
53     public void test4() {
54         l.tryParse("=M000005.C412345");
55         verify(handler).updateChannel(LcnChannelGroup.S0INPUT, "4", new DecimalType(12345));
56     }
57 }