]> git.basschouten.com Git - openhab-addons.git/blob
276124fd5d31565c13860c1622d67388786e2efa
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2020 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.omnikinverter.internal.test;
14
15 import static org.junit.jupiter.api.Assertions.*;
16
17 import java.io.File;
18 import java.io.IOException;
19 import java.nio.file.Files;
20
21 import org.junit.jupiter.api.BeforeEach;
22 import org.junit.jupiter.api.Test;
23 import org.openhab.binding.omnikinverter.internal.OmnikInverterMessage;
24
25 /**
26  * @author Hans van den Bogert - Initial contribution
27  */
28 public class OmnikInverterMessageTest {
29
30     private OmnikInverterMessage message;
31
32     @BeforeEach
33     public void setUp() throws IOException {
34         File file = new File("src/test/resources/omnik.output");
35         message = new OmnikInverterMessage(Files.readAllBytes(file.toPath()));
36     }
37
38     @Test
39     public void testGetPower() {
40         assertEquals(137.0, message.getPower(), 0.01);
41     }
42
43     @Test
44     public void testGetTotalEnergy() {
45         assertEquals(12412.7, message.getTotalEnergy(), 0.01);
46     }
47
48     @Test
49     public void testGetEnergyToday() {
50         assertEquals(11.13, message.getEnergyToday(), 0.01);
51     }
52 }