Files
DP44/DataPRO/SensorDB.Test/.svn/pristine/0d/0d54783c8a968010e050f2f41256f0861c3e1c02.svn-base
2026-04-17 14:55:32 -04:00

131 lines
3.8 KiB
Plaintext

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));
}
}
}