Skip to content

Commit

Permalink
Use mock network tables in tests (#675)
Browse files Browse the repository at this point in the history
  • Loading branch information
SamCarlberg authored Oct 5, 2016
1 parent 953c09e commit 7996fc8
Show file tree
Hide file tree
Showing 5 changed files with 562 additions and 52 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package edu.wpi.grip.core.operations.network.networktables;

import edu.wpi.grip.core.operations.network.NetworkReceiver;

import edu.wpi.first.wpilibj.tables.ITable;

import java.util.function.Consumer;

public class MockNTReceiver extends NetworkReceiver {

private final ITable table;

/**
* Create a new NetworkReceiver with the specified path.
*
* @param path The path of the object to get
* @param table the network table that values will be retrieved from
*/
public MockNTReceiver(String path, ITable table) {
super(path);
this.table = table;
}

@Override
public Object getValue() {
return table.getValue(path);
}

@Override
public void addListener(Consumer<Object> consumer) {
// Never called
throw new UnsupportedOperationException();
}

@Override
public void close() {
table.delete(path);
}
}
Loading

0 comments on commit 7996fc8

Please sign in to comment.