本文整理汇总了C#中HFM.Core.DataTypes.UnitInfo类的典型用法代码示例。如果您正苦于以下问题:C# UnitInfo类的具体用法?C# UnitInfo怎么用?C# UnitInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UnitInfo类属于HFM.Core.DataTypes命名空间,在下文中一共展示了UnitInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DuplicateTestMixed
public void DuplicateTestMixed()
{
var instance1 = new SlotModel { UserId = "1" };
var unitInfo1 = new UnitInfo { ProjectID = 1 };
var logic1 = CreateUnitInfoLogic(unitInfo1);
instance1.UnitInfoLogic = logic1;
var instance2 = new SlotModel { UserId = "1" };
var unitInfo2 = new UnitInfo { ProjectID = 2 };
var logic2 = CreateUnitInfoLogic(unitInfo2);
instance2.UnitInfoLogic = logic2;
var instance3 = new SlotModel { UserId = "2" };
var unitInfo3 = new UnitInfo { ProjectID = 1 };
var logic3 = CreateUnitInfoLogic(unitInfo3);
instance3.UnitInfoLogic = logic3;
(new[] { instance1, instance2, instance3 }).FindDuplicates();
Assert.IsTrue(instance1.UserIdIsDuplicate);
Assert.IsTrue(instance1.ProjectIsDuplicate);
Assert.IsTrue(instance2.UserIdIsDuplicate);
Assert.IsFalse(instance2.ProjectIsDuplicate);
Assert.IsFalse(instance3.UserIdIsDuplicate);
Assert.IsTrue(instance3.ProjectIsDuplicate);
}
示例2: CurrentFrameTest4
public void CurrentFrameTest4()
{
var unitInfo = new UnitInfo();
var unitFrame = new UnitFrame { FrameID = -1 };
unitInfo.SetUnitFrame(unitFrame);
Assert.IsNull(unitInfo.CurrentFrame);
}
示例3: GetUnitFrameTest2
public void GetUnitFrameTest2()
{
var unitInfo = new UnitInfo();
unitInfo.SetUnitFrame(new UnitFrame { FrameID = 0 });
Assert.IsNotNull(unitInfo.GetUnitFrame(0));
Assert.IsNull(unitInfo.GetUnitFrame(1));
}
示例4: UnitInfo_CurrentFrame_Test1
public void UnitInfo_CurrentFrame_Test1()
{
// Arrange
var unitInfo = new UnitInfo();
// Act & Assert
Assert.IsNull(unitInfo.CurrentFrame);
}
示例5: CurrentFrameTest2
public void CurrentFrameTest2()
{
var unitInfo = new UnitInfo();
var unitFrame = new UnitFrame { FrameID = 0 };
unitInfo.SetUnitFrame(unitFrame);
Assert.AreSame(unitFrame, unitInfo.CurrentFrame);
}
示例6: UnitInfo_CurrentFrame_Test2
public void UnitInfo_CurrentFrame_Test2()
{
// Arrange
var unitInfo = new UnitInfo();
var unitFrame = new UnitFrame { FrameID = 0 };
var logLine = new LogLine { LineType = LogLineType.WorkUnitFrame, LineData = unitFrame };
unitInfo.LogLines = new List<LogLine>(new[] { logLine });
// Act & Assert
Assert.AreSame(unitFrame, unitInfo.CurrentFrame);
}
示例7: AllFramesCompleted1
public void AllFramesCompleted1()
{
var unitInfo = new UnitInfo();
unitInfo.SetUnitFrame(MakeUnitFrame("00:00:00", 100));
var unitInfoLogic = CreateUnitInfoLogic(null, unitInfo);
unitInfoLogic.UtcOffsetIsZero = false;
unitInfoLogic.ClientTimeOffset = 0;
Assert.IsTrue(unitInfoLogic.AllFramesCompleted);
}
示例8: DownloadTimeTest3
public void DownloadTimeTest3()
{
var unitInfo = new UnitInfo { DownloadTime = DateTime.UtcNow };
var unitInfoLogic = CreateUnitInfoLogic(new Protein(), unitInfo);
unitInfoLogic.UtcOffsetIsZero = true;
unitInfoLogic.ClientTimeOffset = 0;
Assert.AreEqual(unitInfo.DownloadTime,
unitInfoLogic.DownloadTime);
}
示例9: DownloadTimeTest4
public void DownloadTimeTest4()
{
var unitInfo = new UnitInfo { DownloadTime = DateTime.UtcNow };
var unitInfoLogic = CreateUnitInfoLogic(new Protein(), unitInfo);
unitInfoLogic.UtcOffsetIsZero = true;
unitInfoLogic.ClientTimeOffset = -60;
Assert.AreEqual(unitInfo.DownloadTime
.Add(TimeSpan.FromMinutes(60)),
unitInfoLogic.DownloadTime);
}
示例10: DownloadTimeTest2
public void DownloadTimeTest2()
{
var unitInfo = new UnitInfo { DownloadTime = DateTime.UtcNow };
var unitInfoLogic = CreateUnitInfoLogic(new Protein(), unitInfo);
unitInfoLogic.UtcOffsetIsZero = false;
unitInfoLogic.ClientTimeOffset = 60;
Assert.AreEqual(unitInfo.DownloadTime.ToLocalTime()
.Subtract(TimeSpan.FromMinutes(60)),
unitInfoLogic.DownloadTime);
}
示例11: UnitInfo_CurrentFrame_Test3
public void UnitInfo_CurrentFrame_Test3()
{
// Arrange
var unitInfo = new UnitInfo();
var logLine0 = new LogLine { LineType = LogLineType.WorkUnitFrame, LineData = new UnitFrame { FrameID = 0 } };
var logLine1 = new LogLine { LineType = LogLineType.WorkUnitFrame, LineData = new UnitFrame { FrameID = 1 } };
var unitFrame5 = new UnitFrame { FrameID = 5 };
var logLine5 = new LogLine { LineType = LogLineType.WorkUnitFrame, LineData = unitFrame5 };
unitInfo.LogLines = new List<LogLine>(new[] { logLine0, logLine1, logLine5 });
// Act & Assert
Assert.AreSame(unitFrame5, unitInfo.CurrentFrame);
}
示例12: UpdateBenchmarkDataTest
public void UpdateBenchmarkDataTest()
{
// setup
var benchmarkCollection = new ProteinBenchmarkCollection();
var database = MockRepository.GenerateMock<IUnitInfoDatabase>();
var fahClient = new FahClient(MockRepository.GenerateStub<IMessageConnection>()) { BenchmarkCollection = benchmarkCollection, UnitInfoDatabase = database };
var unitInfo1 = new UnitInfo();
unitInfo1.OwningClientName = "Owner";
unitInfo1.OwningClientPath = "Path";
unitInfo1.OwningSlotId = 0;
unitInfo1.ProjectID = 2669;
unitInfo1.ProjectRun = 1;
unitInfo1.ProjectClone = 2;
unitInfo1.ProjectGen = 3;
unitInfo1.FinishedTime = new DateTime(2010, 1, 1);
unitInfo1.QueueIndex = 0;
var currentUnitInfo = new UnitInfoModel { CurrentProtein = new Protein(), UnitInfoData = unitInfo1 };
var unitInfo1Clone = unitInfo1.DeepClone();
unitInfo1Clone.FramesObserved = 4;
unitInfo1Clone.SetUnitFrame(new UnitFrame { TimeOfFrame = TimeSpan.FromMinutes(0), FrameID = 0 });
unitInfo1Clone.SetUnitFrame(new UnitFrame { TimeOfFrame = TimeSpan.FromMinutes(5), FrameID = 1 });
unitInfo1Clone.SetUnitFrame(new UnitFrame { TimeOfFrame = TimeSpan.FromMinutes(10), FrameID = 2 });
unitInfo1Clone.SetUnitFrame(new UnitFrame { TimeOfFrame = TimeSpan.FromMinutes(15), FrameID = 3 });
unitInfo1Clone.UnitResult = WorkUnitResult.FinishedUnit;
var unitInfoLogic1 = new UnitInfoModel { CurrentProtein = new Protein(), UnitInfoData = unitInfo1Clone };
var parsedUnits = new[] { unitInfoLogic1 };
// arrange
database.Stub(x => x.Connected).Return(true);
database.Expect(x => x.Insert(null)).IgnoreArguments().Repeat.Times(1);
var benchmarkClient = new BenchmarkClient("Owner Slot 00", "Path");
// assert before act
Assert.AreEqual(false, benchmarkCollection.Contains(benchmarkClient));
Assert.AreEqual(false, new List<int>(benchmarkCollection.GetBenchmarkProjects(benchmarkClient)).Contains(2669));
Assert.IsNull(benchmarkCollection.GetBenchmark(currentUnitInfo.UnitInfoData));
// act
fahClient.UpdateBenchmarkData(currentUnitInfo, parsedUnits, 0);
// assert after act
Assert.AreEqual(true, benchmarkCollection.Contains(benchmarkClient));
Assert.AreEqual(true, new List<int>(benchmarkCollection.GetBenchmarkProjects(benchmarkClient)).Contains(2669));
Assert.AreEqual(TimeSpan.FromMinutes(5), benchmarkCollection.GetBenchmark(currentUnitInfo.UnitInfoData).AverageFrameTime);
database.VerifyAllExpectations();
}
示例13: AggregateData
/// <summary>
/// Aggregate Data and return UnitInfo Dictionary.
/// </summary>
public DataAggregatorResult AggregateData(ClientRun clientRun, UnitCollection unitCollection, Info info, Options options,
SlotOptions slotOptions, UnitInfo currentUnitInfo, int slotId)
{
if (clientRun == null) throw new ArgumentNullException("clientRun");
if (unitCollection == null) throw new ArgumentNullException("unitCollection");
if (options == null) throw new ArgumentNullException("options");
if (slotOptions == null) throw new ArgumentNullException("slotOptions");
if (currentUnitInfo == null) throw new ArgumentNullException("currentUnitInfo");
var result = new DataAggregatorResult();
result.CurrentUnitIndex = -1;
SlotRun slotRun = null;
if (clientRun.SlotRuns.ContainsKey(slotId))
{
slotRun = clientRun.SlotRuns[slotId];
}
result.StartTime = clientRun.Data.StartTime;
result.Arguments = clientRun.Data.Arguments;
result.ClientVersion = clientRun.Data.ClientVersion;
result.UserID = clientRun.Data.UserID;
result.MachineID = clientRun.Data.MachineID;
result.Status = slotRun != null ? slotRun.Data.Status : SlotStatus.Unknown;
if (Logger.IsDebugEnabled)
{
foreach (var s in clientRun.Where(x => x.LineType == LogLineType.Error))
{
Logger.DebugFormat(Constants.ClientNameFormat, ClientName, String.Format("Failed to parse log line: {0}", s));
}
}
GenerateUnitInfoDataFromQueue(result, slotRun, unitCollection, options, slotOptions, currentUnitInfo, slotId);
result.Queue = BuildClientQueue(unitCollection, info, slotOptions, slotId);
if (result.UnitInfos.ContainsKey(result.CurrentUnitIndex) && result.UnitInfos[result.CurrentUnitIndex].LogLines != null)
{
result.CurrentLogLines = result.UnitInfos[result.CurrentUnitIndex].LogLines;
}
else if (slotRun != null)
{
result.CurrentLogLines = slotRun.ToList();
}
else
{
result.CurrentLogLines = clientRun.ToList();
}
return result;
}
示例14: UnitInfo_DefaultPropertyValues_Test
public void UnitInfo_DefaultPropertyValues_Test()
{
var unitInfo = new UnitInfo();
Assert.AreEqual(SlotType.Unknown, unitInfo.SlotType);
Assert.IsTrue(unitInfo.DownloadTime.IsUnknown());
Assert.IsTrue(unitInfo.DueTime.IsUnknown());
Assert.IsTrue(unitInfo.UnitStartTimeStamp.IsZero());
Assert.IsTrue(unitInfo.FinishedTime.IsUnknown());
Assert.IsTrue(unitInfo.CoreVersion == 0);
Assert.IsTrue(unitInfo.ProteinName.Length == 0);
Assert.IsTrue(unitInfo.ProteinTag.Length == 0);
Assert.AreEqual(WorkUnitResult.Unknown, unitInfo.UnitResult);
Assert.IsNull(unitInfo.LogLines);
Assert.IsNull(unitInfo.UnitFrames);
Assert.AreEqual(Constants.DefaultCoreID, unitInfo.CoreID);
}
示例15: GenerateUnitInfoDataFromLogs
private UnitInfo[] GenerateUnitInfoDataFromLogs()
{
var parsedUnits = new UnitInfo[2];
_unitLogLines = new IList<LogLine>[2];
if (_logInterpreterLegacy.PreviousWorkUnitLogLines != null)
{
_unitLogLines[0] = _logInterpreterLegacy.PreviousWorkUnitLogLines;
parsedUnits[0] = BuildUnitInfo(null, LogReader.GetFahLogDataFromLogLines(_logInterpreterLegacy.PreviousWorkUnitLogLines), null);
}
bool matchOverride = false;
_unitLogLines[1] = _logInterpreterLegacy.CurrentWorkUnitLogLines;
if (_unitLogLines[1] == null)
{
matchOverride = true;
_unitLogLines[1] = _logInterpreterLegacy.CurrentClientRunLogLines;
}
parsedUnits[1] = BuildUnitInfo(null, LogReader.GetFahLogDataFromLogLines(_unitLogLines[1]), GetUnitInfoLogData(), matchOverride);
return parsedUnits;
}