90 lines
2.8 KiB
C#
90 lines
2.8 KiB
C#
using DTS.DASLib.Service.StateMachine;
|
|
using NUnit.Framework;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace StateMachine.Tests
|
|
{
|
|
[TestFixture]
|
|
public class DiagnoseShould
|
|
{
|
|
[Test]
|
|
public void State_ShouldBeRealtime()
|
|
{
|
|
//Arrange
|
|
var sut = new Realtime();
|
|
|
|
//Act & Assert
|
|
Assert.That(State.Realtime, Is.EqualTo(sut.State));
|
|
}
|
|
|
|
[Test]
|
|
public void StateSelector_ShouldReturnRealtime_WhenRequireAllUnitsPassDiagnosticIsFalse()
|
|
{
|
|
//Arrange
|
|
var sut = new Diagnose();
|
|
var status = sut.Status;
|
|
status.DiagnoseParams.ProceedToRealtimeWhenDone = true;
|
|
status.DiagnoseParams.RequireAllUnitsPassDiagnostic = false;
|
|
|
|
//Act
|
|
var dasState = sut.StateSelector();
|
|
|
|
// Assert
|
|
Assert.That(dasState.State, Is.EqualTo(State.RealtimeStart));
|
|
}
|
|
|
|
[Test]
|
|
public void StateSelector_ShouldReturnRealtime_WhenAllUnitsPassedDiagnostic()
|
|
{
|
|
//Arrange
|
|
var sut = new Diagnose();
|
|
var status = sut.Status;
|
|
status.DiagnoseParams.ProceedToRealtimeWhenDone = true;
|
|
status.DiagnoseParams.AllUnitsPassedDiagnostic = true;
|
|
|
|
//Act
|
|
var dasState = sut.StateSelector();
|
|
|
|
// Assert
|
|
Assert.That(dasState.State, Is.EqualTo(State.RealtimeStart));
|
|
}
|
|
[Test]
|
|
public void StateSelector_ShouldReturnDiagnose_ProceedToRealtimeWhenDoneIsFalse()
|
|
{
|
|
//Arrange
|
|
var sut = new Diagnose();
|
|
var status = sut.Status;
|
|
status.DiagnoseParams.ProceedToRealtimeWhenDone = false;
|
|
status.DiagnoseParams.AllUnitsPassedDiagnostic = true;
|
|
status.DiagnoseParams.RequireAllUnitsPassDiagnostic = false;
|
|
|
|
//Act
|
|
var dasState = sut.StateSelector();
|
|
|
|
// Assert
|
|
Assert.That(dasState.State, Is.EqualTo(State.Diagnose));
|
|
}
|
|
|
|
[Test]
|
|
public void StateSelector_ShouldReturnDiagnose_WhenAllUnitsPassedDiagnosticIsFalseAndRequireAllUnitsPassDiagnostic()
|
|
{
|
|
//Arrange
|
|
var sut = new Diagnose();
|
|
var status = sut.Status;
|
|
status.DiagnoseParams.ProceedToRealtimeWhenDone = true;
|
|
status.DiagnoseParams.RequireAllUnitsPassDiagnostic = true;
|
|
status.DiagnoseParams.AllUnitsPassedDiagnostic = false;
|
|
|
|
//Act
|
|
var dasState = sut.StateSelector();
|
|
|
|
// Assert
|
|
Assert.That(dasState.State, Is.EqualTo(State.Diagnose));
|
|
}
|
|
}
|
|
}
|