init
This commit is contained in:
130
DataPRO/SensorDB.Test/SensorCalibrationShould.cs
Normal file
130
DataPRO/SensorDB.Test/SensorCalibrationShould.cs
Normal file
@@ -0,0 +1,130 @@
|
||||
using DTS.SensorDB;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
|
||||
namespace SensorDB.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public class SensorCalibrationShould
|
||||
{
|
||||
[Test]
|
||||
public void IsCompatibleWithIEPE_ShouldReturnFalse_WhenSensorProportionalIsTrue()
|
||||
{
|
||||
//Arange
|
||||
SensorCalibration sut = new SensorCalibration();
|
||||
sut.IsProportional = true;
|
||||
|
||||
//Act
|
||||
var compatibleWithIEPE = sut.IsCompatibleWithIEPE();
|
||||
|
||||
//Assert
|
||||
Assert.That(compatibleWithIEPE, Is.EqualTo(false));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsCompatibleWithIEPE_ShouldReturnFalse_WhenSensorIsNonLinear()
|
||||
{
|
||||
//Arange
|
||||
SensorCalibration sut = new SensorCalibration();
|
||||
sut.NonLinear = true;
|
||||
|
||||
//Act
|
||||
var compatibleWithIEPE = sut.IsCompatibleWithIEPE();
|
||||
|
||||
//Assert
|
||||
Assert.That(compatibleWithIEPE, Is.EqualTo(false));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsCompatibleWithIEPE_ShouldReturnTrue()
|
||||
{
|
||||
//Arange
|
||||
SensorCalibration sut = new SensorCalibration();
|
||||
sut.NonLinear = false;
|
||||
sut.IsProportional = false;
|
||||
|
||||
//Act
|
||||
var compatibleWithIEPE = sut.IsCompatibleWithIEPE();
|
||||
|
||||
//Assert
|
||||
Assert.That(compatibleWithIEPE, Is.EqualTo(true));
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ToNonLinearDisplayString_ShouldReturnEmpty_WhenNonLinearIsFalse()
|
||||
{
|
||||
//Arange
|
||||
SensorCalibration sut = new SensorCalibration();
|
||||
sut.NonLinear = false;
|
||||
|
||||
//Act
|
||||
var compatibleWithIEPE = sut.ToNonLinearDisplayString("Test", false);
|
||||
|
||||
//Assert
|
||||
Assert.That(compatibleWithIEPE, Is.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ToNonLinearDisplayString_ShouldReturnEmpty_WhenNonLinearFormatIsNull()
|
||||
{
|
||||
//Arange
|
||||
SensorCalibration sut = new SensorCalibration();
|
||||
sut.NonLinear = true;
|
||||
|
||||
//Act
|
||||
var compatibleWithIEPE = sut.ToNonLinearDisplayString(null, false);
|
||||
|
||||
//Assert
|
||||
Assert.That(compatibleWithIEPE, Is.Empty);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CompareTo_ShouldReturn1_ComparedWithNull()
|
||||
{
|
||||
//Arange
|
||||
SensorCalibration sut = new SensorCalibration();
|
||||
|
||||
//Act
|
||||
var compatibleWithIEPE = sut.CompareTo(null);
|
||||
|
||||
//Assert
|
||||
Assert.That(compatibleWithIEPE, Is.EqualTo(1));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CompareTo_ShouldReturn0_WhenObjectsHaveSameCalibrationDates()
|
||||
{
|
||||
//Arange
|
||||
var now = DateTime.Now;
|
||||
SensorCalibration sut = new SensorCalibration();
|
||||
sut.CalibrationDate = now;
|
||||
|
||||
//Act
|
||||
var secondObjectDate = new SensorCalibration();
|
||||
secondObjectDate.CalibrationDate = now;
|
||||
var compatibleWithIEPE = sut.CompareTo(secondObjectDate);
|
||||
|
||||
//Assert
|
||||
Assert.That(compatibleWithIEPE, Is.EqualTo(0));
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CompareTo_ShouldReturnNegative_WhenObjectsHaveDifferentCalibrationDates()
|
||||
{
|
||||
//Arange
|
||||
var now = DateTime.Now;
|
||||
SensorCalibration sut = new SensorCalibration();
|
||||
sut.CalibrationDate = now;
|
||||
|
||||
//Act
|
||||
var secondObjectDate = new SensorCalibration();
|
||||
secondObjectDate.CalibrationDate = now.AddDays(-1);
|
||||
var compatibleWithIEPE = sut.CompareTo(secondObjectDate);
|
||||
|
||||
//Assert
|
||||
Assert.That(compatibleWithIEPE, Is.Not.EqualTo(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user