init
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
using DTS.Common.Interface.DASFactory;
|
||||
using DTS.DASLib.Service;
|
||||
using DTS.DASLib.Service.StateMachine;
|
||||
using NSubstitute;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace StateMachine.Tests.StatusAndParameters
|
||||
{
|
||||
[TestFixture]
|
||||
class RealtimeStatusInformationShould
|
||||
{
|
||||
[Test]
|
||||
public void StartRealtime_Should_CouldNotStartRealtimeBeTrue()
|
||||
{
|
||||
|
||||
//Arrange
|
||||
var sut = new RealtimeStatusInformation();
|
||||
var das = Substitute.For<IDASCommunication>();
|
||||
|
||||
var dasList = new List<IDASCommunication> { das };
|
||||
|
||||
var indices = new List<int>();
|
||||
indices.Add(0);
|
||||
var moduleIndices = indices;
|
||||
|
||||
var useSingleSampleMode = false;
|
||||
var realtimeSampleRate = 1000;
|
||||
var realtimeDelayBetweenPollsInMilliSecond = 4;
|
||||
var allowMultipleSampleRealtime = true;
|
||||
|
||||
|
||||
var b = new byte[1];
|
||||
b[0] = 0;
|
||||
var idasToActiveChannels = new Dictionary<IDASCommunication, byte[]>();
|
||||
idasToActiveChannels.Add(dasList[0], b);
|
||||
|
||||
|
||||
Action CompleteAction = () =>
|
||||
{
|
||||
Console.WriteLine("Realtime started");
|
||||
};
|
||||
Action<double, double> SetRealtimeSampleRateAAF = (p, q) =>
|
||||
{
|
||||
Console.WriteLine("Set RealtimeSampleRateAAF {0},{1}", p, q);
|
||||
};
|
||||
|
||||
ServiceBase.Callback StartRealtimeCallback = (data) =>
|
||||
{
|
||||
if (data.Status == ServiceBase.CallbackData.CallbackStatus.AllFinished)
|
||||
{
|
||||
Console.WriteLine("Finished receiving data");
|
||||
}
|
||||
|
||||
if (data.Status == ServiceBase.CallbackData.CallbackStatus.NewData)
|
||||
{
|
||||
|
||||
Console.WriteLine("Receiving new data {0}", data.Data[0].SampleNumber.ToString());
|
||||
}
|
||||
};
|
||||
|
||||
//Act
|
||||
sut.StartRealtime(dasList, moduleIndices, useSingleSampleMode, realtimeSampleRate,
|
||||
realtimeDelayBetweenPollsInMilliSecond, allowMultipleSampleRealtime, SetRealtimeSampleRateAAF, CompleteAction,
|
||||
idasToActiveChannels, StartRealtimeCallback);
|
||||
|
||||
//Assert
|
||||
Assert.That(sut.CouldNotStartRealtime, Is.EqualTo(true));
|
||||
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void IsInRealtime_Should_ReturnFalse()
|
||||
{
|
||||
//Arrange
|
||||
var sut = new RealtimeStatusInformation();
|
||||
|
||||
//Act
|
||||
var result = sut.IsInRealtime;
|
||||
|
||||
//Assert
|
||||
Assert.That(result, Is.EqualTo(false));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user