Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added some integration tests for enron extension
- Loading branch information
sjalex
committed
Mar 28, 2009
1 parent
88ba70b
commit a49ea83
Showing
4 changed files
with
81 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using MbUnit.Framework; | ||
using Modbus.Extensions.Enron; | ||
|
||
namespace Modbus.IntegrationTests | ||
{ | ||
[TestFixture] | ||
public class EnronFixture : NModbusSerialRtuMasterDl06SlaveFixture | ||
{ | ||
[Test] | ||
public virtual void ReadHoldingRegisters32() | ||
{ | ||
uint[] registers = Master.ReadHoldingRegisters32(SlaveAddress, 104, 2); | ||
Assert.AreEqual(new uint[] { 0, 0 }, registers); | ||
} | ||
|
||
[Test] | ||
public virtual void ReadInputRegisters32() | ||
{ | ||
uint[] registers = Master.ReadInputRegisters32(SlaveAddress, 104, 2); | ||
Assert.AreEqual(new uint[] { 0, 0 }, registers); | ||
} | ||
|
||
[Test] | ||
public virtual void WriteSingleRegister32() | ||
{ | ||
ushort testAddress = 200; | ||
uint testValue = 350; | ||
|
||
uint originalValue = Master.ReadHoldingRegisters32(SlaveAddress, testAddress, 1)[0]; | ||
Master.WriteSingleRegister32(SlaveAddress, testAddress, testValue); | ||
Assert.AreEqual(testValue, Master.ReadHoldingRegisters32(SlaveAddress, testAddress, 1)[0]); | ||
Master.WriteSingleRegister32(SlaveAddress, testAddress, originalValue); | ||
Assert.AreEqual(originalValue, Master.ReadHoldingRegisters(SlaveAddress, testAddress, 1)[0]); | ||
} | ||
|
||
[Test] | ||
public virtual void WriteMultipleRegisters32() | ||
{ | ||
ushort testAddress = 120; | ||
uint[] testValues = new uint[] { 10, 20, 30, 40, 50 }; | ||
|
||
uint[] originalValues = Master.ReadHoldingRegisters32(SlaveAddress, testAddress, (ushort) testValues.Length); | ||
Master.WriteMultipleRegisters32(SlaveAddress, testAddress, testValues); | ||
uint[] newValues = Master.ReadHoldingRegisters32(SlaveAddress, testAddress, (ushort) testValues.Length); | ||
Assert.AreEqual(testValues, newValues); | ||
Master.WriteMultipleRegisters32(SlaveAddress, testAddress, originalValues); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters