public void Insert_InMiddle() { var baseTime = DateTime.UtcNow; var span = new TRexSpan <CellPass>(new CellPass[3], TRexSpan <CellPass> .NO_SLAB_INDEX, 0, 3, false); var cp1 = new CellPass { Time = baseTime }; var cp2 = new CellPass { Time = baseTime.AddMinutes(1) }; span.Add(cp1); span.Add(cp1); span.Insert(cp2, 1); span.Count.Should().Be(3); span.First().Should().BeEquivalentTo(cp1); span.Last().Should().BeEquivalentTo(cp1); span.GetElement(0).Should().BeEquivalentTo(cp1); span.GetElement(1).Should().BeEquivalentTo(cp2); span.OffsetPlusCount.Should().Be(3); }
public void Test_ServerSubGridTreeLeaf_ComputeLatestPassInformation() { var leaf = CreateADefaultEmptyLeaf(); Assert.True(leaf.Directory.GlobalLatestCells != null && leaf.Directory.GlobalLatestCells.PassDataExistenceMap != null, "Pass data existence map is not instantiated"); Assert.False(leaf.CellHasValue(0, 0), "Cell already has a value"); // Add three passes them compute the latest pass information and ensure it matches with the cell passes CellPass pass = CreateTestCellPass(); leaf.AddPass(0, 0, pass); pass.Time = pass.Time.AddMinutes(1); leaf.AddPass(0, 0, pass); pass.Time = pass.Time.AddMinutes(1); leaf.AddPass(0, 0, pass); leaf.ComputeLatestPassInformation(true, StorageProxy.Instance(StorageMutability.Mutable)); Assert.True(leaf.CellHasValue(0, 0), "Cell does not have value"); CellPass latestPass = leaf.Directory.GlobalLatestCells[0, 0]; Assert.True(latestPass.Equals(pass), "Latest cell pass does not match pass"); }
public async Task CSVExportRequest_Execute_ExceedsLimit() { DILoggingFixture.SetMaxExportRowsConfig(1); AddApplicationGridRouting(); AddClusterComputeGridRouting(); var tempFileName = MockS3FileTransfer_UploadToBucket(); var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel(); var request = new CSVExportRequest(); var baseDate = DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 0, 0, 0), DateTimeKind.Utc); var cellPasses = new CellPass[SubGridTreeConsts.SubGridTreeDimension, SubGridTreeConsts.SubGridTreeDimension][]; SubGridUtilities.SubGridDimensionalIterator((x, y) => { cellPasses[x, y] = new[] { new CellPass { Time = baseDate, Height = 1.0f } }; }); DITAGFileAndSubGridRequestsFixture.AddSingleSubGridWithPasses(siteModel, SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset, cellPasses); var response = await request.ExecuteAsync(SimpleCSVExportRequestArgument(siteModel.ID)); response.Should().NotBeNull(); response.ResultStatus.Should().Be(RequestErrorStatus.ExportExceededRowLimit); CleanupMockedFile(tempFileName, siteModel.ID); }
private ISiteModel BuildModelForSubGridRequest() { var baseTime = DateTime.UtcNow; var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel(); var bulldozerMachineIndex = siteModel.Machines.Locate("Bulldozer", false).InternalSiteModelMachineIndex; CellPass[, ][] cellPasses = new CellPass[SubGridTreeConsts.SubGridTreeDimension, SubGridTreeConsts.SubGridTreeDimension][]; SubGridUtilities.SubGridDimensionalIterator((x, y) => { cellPasses[x, y] = Enumerable.Range(0, 1).Select(p => new CellPass { Height = 1 + x + y, InternalSiteModelMachineIndex = bulldozerMachineIndex, Time = baseTime.AddMinutes(p), PassType = PassType.Front }).ToArray(); }); DITAGFileAndSubGridRequestsFixture.AddSingleSubGridWithPasses(siteModel, SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset, cellPasses); return(siteModel); }
public void Test_ServerSubGridTreeLeaf_AddPass() { var leaf = CreateADefaultEmptyLeaf(); Assert.True(leaf.Cells != null && leaf.Directory.SegmentDirectory.First().Segment != null && leaf.Directory.SegmentDirectory.First().Segment.PassesData != null, "Segment passes data not created correctly for AddPass()"); var pass = CreateTestCellPass(); leaf.AddPass(0, 0, pass); // Check the cell passes in the segment records the cell pass Assert.Equal(1, leaf.Directory.SegmentDirectory.First().Segment.PassesData.SegmentPassCount); Assert.Equal(1, leaf.Directory.SegmentDirectory.First().Segment.PassesData.PassCount(0, 0)); Assert.Equal(leaf.Directory.SegmentDirectory.First().Segment.PassesData.PassTime(0, 0, 0), DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 1, 1), DateTimeKind.Utc)); // Pull the pass a compare it to what was added CellPass pass2 = leaf.Directory.SegmentDirectory.First().Segment.PassesData.Pass(0, 0, 0); Assert.True(pass2.Equals(pass), "Pass retrieved is not the same as the pass asses"); // Check that the start and end time for the leaf was updated when the cell pass was added. Assert.True(leaf.LeafStartTime == leaf.LeafEndTime && leaf.LeafStartTime == DateTime.SpecifyKind(new DateTime(2000, 1, 1, 1, 1, 1), DateTimeKind.Utc), "Leaf start and time was not updated"); }
private ISiteModel BuildModelForCellsElevation(float elevationIncrement) { var baseTime = DateTime.UtcNow; var baseElevation = 1.0F; var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel(); var bulldozerMachineIndex = siteModel.Machines.Locate("Bulldozer", false).InternalSiteModelMachineIndex; CellPass[, ][] cellPasses = new CellPass[32, 32][]; SubGridUtilities.SubGridDimensionalIterator((x, y) => { cellPasses[x, y] = Enumerable.Range(0, 1).Select(p => new CellPass { InternalSiteModelMachineIndex = bulldozerMachineIndex, Time = baseTime.AddMinutes(p), Height = baseElevation + (x + y) * elevationIncrement, // incrementally increase height across the sub grid PassType = PassType.Front }).ToArray(); }); DITAGFileAndSubGridRequestsFixture.AddSingleSubGridWithPasses(siteModel, SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset, cellPasses); return(siteModel); }
public void SubGridCellSegmentPassesDataWrapper_NonStatic_Cell_Test() { CellPass pass1 = TestCellPass(); pass1.Time = DateTime.SpecifyKind(new DateTime(2000, 1, 1, 0, 0, 0), DateTimeKind.Utc); CellPass pass2 = TestCellPass(); pass2.Time = DateTime.SpecifyKind(new DateTime(2000, 1, 2, 0, 0, 0), DateTimeKind.Utc); CellPass pass3 = TestCellPass(); pass3.Time = DateTime.SpecifyKind(new DateTime(2000, 1, 3, 0, 0, 0), DateTimeKind.Utc); CellPass[] passes = new CellPass[] { pass1, pass2, pass3 }; using (var item = new SubGridCellSegmentPassesDataWrapper_NonStatic()) { item.AddPass(1, 1, pass1); item.AddPass(1, 1, pass2); item.AddPass(1, 1, pass3); Assert.Equal(3, item.PassCount(1, 1)); Cell_NonStatic cell = item.ExtractCellPasses(1, 1); for (int i = 0; i < cell.PassCount; i++) { Assert.True(cell.Passes.GetElement(i).Equals(passes[i]), "Extracted cell does not contain the same cell passes added to it"); } } }
/// <summary> /// Adds a pass to the set of passes beign constructed as a result of the filtering operation. /// </summary> /// <param name="pass"></param> /// <param name="passesOrderedInIncreasingTime"></param> public void AddPass(CellPass pass /*, bool passesOrderedInIncreasingTime = true*/) { /*TODO convert when C# equivalent of IFOPT C+ is understood * {$IFOPT C+} * if PassesOrderedInIncreasingTime then * begin * if (FPassCount > 0) and(FilteredPassData[FPassCount - 1].FilteredPass.Time > (Pass.Time + OneSecond)) then * Assert(False, Format('Passes not added to filtered pass list in increasing time order (1) (Time1 vs Time2 = %.6f (%s) vs %.6f (%s)', * [FilteredPassData[FPassCount - 1].FilteredPass.Time, * FormatCellPassTimeValue(FilteredPassData[FPassCount - 1].FilteredPass.Time, cpftWithMilliseconds, False), * Pass.Time, * FormatCellPassTimeValue(Pass.Time, cpftWithMilliseconds, False)])); {SKIP} * end * else * begin * Assert(((FPassCount = 0) or * (FilteredPassData[FPassCount - 1].FilteredPass.Time > (Pass.Time - OneSecond))), * 'Passes not added to filtered pass list in decreasing time order'); {SKIP} * end; * {$ENDIF} */ CheckArrayCapacity(); // Add the pass to the list FilteredPassData[PassCount].FilteredPass = pass; PassCount++; }
private ISiteModel BuildModelForCellsCMV(short cmvIncrement, short targetCMV = CellPassConsts.NullCCV) { var baseTime = DateTime.UtcNow; short baseCMV = 10; var siteModel = DITAGFileAndSubGridRequestsWithIgniteFixture.NewEmptyModel(); var bulldozerMachineIndex = siteModel.Machines.Locate("Bulldozer", false).InternalSiteModelMachineIndex; if (targetCMV != CellPassConsts.NullCCV) { siteModel.MachinesTargetValues[bulldozerMachineIndex].TargetCCVStateEvents.PutValueAtDate(TRex.Common.Consts.MIN_DATETIME_AS_UTC, targetCMV); } CellPass[, ][] cellPasses = new CellPass[SubGridTreeConsts.SubGridTreeDimension, SubGridTreeConsts.SubGridTreeDimension][]; SubGridUtilities.SubGridDimensionalIterator((x, y) => { cellPasses[x, y] = Enumerable.Range(0, 1).Select(p => new CellPass { InternalSiteModelMachineIndex = bulldozerMachineIndex, Time = baseTime.AddMinutes(p), CCV = (short)(baseCMV + x * cmvIncrement), // incrementally increase CCV across the sub grid PassType = PassType.Front }).ToArray(); }); DITAGFileAndSubGridRequestsFixture.AddSingleSubGridWithPasses(siteModel, SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset, cellPasses); return(siteModel); }
public void Add_CentralSpanTwo(int poolSize, ushort spanOffset, int spanCapacity) { var baseTime = DateTime.UtcNow; var span = new TRexSpan <CellPass>(new CellPass[poolSize], TRexSpan <CellPass> .NO_SLAB_INDEX, spanOffset, spanCapacity, false); var cp1 = new CellPass { Time = baseTime }; var cp2 = new CellPass { Time = baseTime.AddMinutes(1) }; span.Add(cp1); span.Add(cp2); span.Count.Should().Be(2); span.First().Should().BeEquivalentTo(cp1); span.Last().Should().BeEquivalentTo(cp2); span.GetElement(0).Should().BeEquivalentTo(cp1); span.GetElement(1).Should().BeEquivalentTo(cp2); span.OffsetPlusCount.Should().Be(spanOffset + span.Count); }
public void Add_SimpleSpanTwo() { var baseTime = DateTime.UtcNow; var span = new TRexSpan <CellPass>(new CellPass[2], TRexSpan <CellPass> .NO_SLAB_INDEX, 0, 2, false); var cp1 = new CellPass { Time = baseTime }; var cp2 = new CellPass { Time = baseTime.AddMinutes(1) }; span.Add(cp1); span.Add(cp2); span.Count.Should().Be(2); span.First().Should().BeEquivalentTo(cp1); span.Last().Should().BeEquivalentTo(cp2); span.GetElement(0).Should().BeEquivalentTo(cp1); span.GetElement(1).Should().BeEquivalentTo(cp2); span.OffsetPlusCount.Should().Be(2); }
public void Test_CellPass_BinaryReadWrite() { CellPass cp1 = ATestCellPass(); MemoryStream ms = new MemoryStream(Consts.TREX_DEFAULT_MEMORY_STREAM_CAPACITY_ON_CREATION); BinaryWriter bw = new BinaryWriter(ms, Encoding.UTF8, true); cp1.Write(bw); ms.Position = 0; BinaryReader br = new BinaryReader(ms, Encoding.UTF8, true); CellPass cp2 = new CellPass(); cp2.Read(br); Assert.True(cp1.Equals(cp2), "Equality check on same cell passes failed after write then read (returned true)"); // Check negative condition by writing and reading a second different cell pass then comparing the results of reading the two cell passes // to ensure they are different cp2 = ATestCellPass2(); MemoryStream ms2 = new MemoryStream(Consts.TREX_DEFAULT_MEMORY_STREAM_CAPACITY_ON_CREATION); BinaryWriter bw2 = new BinaryWriter(ms2, Encoding.UTF8, true); cp2.Write(bw2); ms2.Position = 0; BinaryReader br2 = new BinaryReader(ms2, Encoding.UTF8, true); cp2.Read(br2); Assert.False(cp1.Equals(cp2), "Equality check on different cell passes failed after write then read (returned true)"); }
/// <summary> /// Initialise all state to null /// </summary> public void Clear() { MachineType = MachineType.Unknown; FilteredPass = CellPass.CLEARED_CELL_PASS; TargetValues.Clear(); EventValues.Clear(); }
public void MasksOutValues_WithoutSurveyedSurfaces() { SetupTestIgniteRouting(); var(siteModel, filter) = CreateSiteModelWithSimpleDesign(); // Create a sub grid at the Northwest origin so that it covers the small TIN design surrounding the // [CellSize / 2, CellSize / 2] point var baseTime = DateTime.UtcNow; var cellPasses = new CellPass[32, 32][]; SubGridUtilities.SubGridDimensionalIterator((x, y) => { cellPasses[x, y] = Enumerable.Range(0, 1).Select(p => new CellPass { Height = 1.0f, InternalSiteModelMachineIndex = siteModel.Machines[0].InternalSiteModelMachineIndex, Time = baseTime.AddMinutes(p), PassType = PassType.Front }).ToArray(); }); DITAGFileAndSubGridRequestsFixture.AddSingleSubGridWithPasses(siteModel, SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset, cellPasses); // Construct a requestor and ask it to retrieve the sub grid from the site model, using the filter // with the surface design mask var utilities = DIContext.Obtain <IRequestorUtilities>(); var requestors = utilities.ConstructRequestors(null, siteModel, new OverrideParameters(), new LiftParameters(), utilities.ConstructRequestorIntermediaries(siteModel, new FilterSet(filter), false, GridDataType.Height), AreaControlSet.CreateAreaControlSet(), siteModel.ExistenceMap); requestors.Length.Should().Be(1); var response = requestors[0].RequestSubGridInternal (new SubGridCellAddress(SubGridTreeConsts.DefaultIndexOriginOffset, SubGridTreeConsts.DefaultIndexOriginOffset), true, false); response.requestResult.Should().Be(ServerRequestResult.NoError); response.clientGrid.Should().NotBeNull(); // Ensure the filtered cell has data response.clientGrid.FilterMap[0, 0].Should().BeTrue(); (response.clientGrid as IClientHeightLeafSubGrid).Cells[0, 0].Should().Be(1.0f); // Ensure no other cells have data response.clientGrid.FilterMap.CountBits().Should().Be(1); var subGrid = response.clientGrid as IClientHeightLeafSubGrid; var count = 0; subGrid.ForEach((x, y) => count += subGrid.Cells[x, y] == 1.0f ? 1 : 0); count.Should().Be(1); }
public void Insert_FailOutOfRange_High() { var span = new TRexSpan <CellPass>(new CellPass[10], TRexSpan <CellPass> .NO_SLAB_INDEX, 5, 6, false); var cp = new CellPass(); Action act = () => span.Insert(cp, 7); act.Should().Throw <ArgumentException>().WithMessage("Index out of range"); }
public void SubGridCellSegmentPassesDataWrapper_NonStatic_ExtractCellPass_Test() { using (var item = new SubGridCellSegmentPassesDataWrapper_NonStatic()) { CellPass pass = TestCellPass(); item.AddPass(1, 1, pass); Assert.True(item.ExtractCellPass(1, 1, 0).Equals(pass), "Cell added is not as expected when retrieved"); } }
public void SubGridCellSegmentPassesDataWrapper_NonStatic_Pass_Test() { using (var item = new SubGridCellSegmentPassesDataWrapper_NonStatic()) { CellPass pass = TestCellPass(); item.AddPass(1, 1, pass); Assert.True(item.Pass(1, 1, 0).Equals(pass), "Cell pass not same as value added"); } }
public void Test_CellPass_AssignCellPasses() { CellPass cp1 = ATestCellPass(); CellPass cp2 = ATestCellPass2(); Assert.False(cp1.Equals(cp2), "Equality check on different cell passes failed (returned true)"); cp1.Assign(cp2); Assert.True(cp1.Equals(cp2), "Equality check on assigned cell passes failed (returned false)"); }
public void ReplacePass(int X, int Y, int position, CellPass pass) { MutationHook?.ReplacePass(X, Y, _passData[X, Y], position, pass); _passData[X, Y].Passes.SetElement(pass, position); #if CELLDEBUG _passData[X, Y].CheckPassesAreInCorrectTimeOrder("ReplacePass"); #endif }
public void Add_Fail_ExceedsCapacity() { var span = new TRexSpan <CellPass>(new CellPass[1], TRexSpan <CellPass> .NO_SLAB_INDEX, 0, 1, false); var cp = new CellPass(); span.Add(cp); Action act = () => span.Add(cp); act.Should().Throw <ArgumentException>() .WithMessage($"No spare capacity to add new element, capacity = 1, element count = 1"); }
public bool FilterPassUsingElevationRange(ref CellPass passValue) { if (!ElevationRangeIsInitialized) { throw new TRexFilterProcessingException("Elevation range filter being used without the elevation range data being initialized"); } // ReSharper disable once CompareOfFloatsByEqualityOperator return(ElevationRangeBottomElevationForCell != Consts.NullDouble && Range.InRange(passValue.Height, ElevationRangeBottomElevationForCell, ElevationRangeTopElevationForCell)); }
public void Test_ServerSubGridTreeLeaf_AddPass_FailWithNonUTCTime() { var leaf = CreateADefaultEmptyLeaf(); var pass = new CellPass { Time = DateTime.Now }; Action act = () => leaf.AddPass(0, 0, pass); act.Should().Throw <TRexSubGridTreeException>().WithMessage("Cell passes added to cell pass stacks must have a non-null, UTC, cell pass time"); }
public void AddPass(int X, int Y, CellPass pass) { if (pass.Time == Consts.MIN_DATETIME_AS_UTC || pass.Time.Kind != DateTimeKind.Utc) { throw new ArgumentException("Cell passes added to cell pass stacks must have a non-null, UTC, cell pass time", nameof(pass.Time)); } MutationHook?.AddPass(X, Y, _passData[X, Y], pass); _passData[X, Y].AddPass(pass); segmentPassCount++; }
/// <summary> /// Gets the next cell pass in the iteration /// </summary> /// <param name="cellPass"></param> /// <returns></returns> public bool GetNextCellPass(ref CellPass cellPass) { if (SegmentIterator.CurrentSubGridSegment == null) { return(false); } DateTime cellPassTime; do { cellInSegmentIndex += cellPassIterationDirectionIncrement; while (cellInSegmentIndex == finishCellInSegmentIndex && SegmentIterator.CurrentSubGridSegment != null) { MoveToNextSegment(); cellInSegmentIndex += cellPassIterationDirectionIncrement; } if (SegmentIterator.CurrentSubGridSegment == null) { return(false); // No more segments to process } cellPass = ExtractCellPass(); cellPassTime = cellPass.Time; if (cellPassTime == Consts.MIN_DATETIME_AS_UTC) { throw new TRexSubGridProcessingException($"Cell pass with null time returned from {nameof(GetNextCellPass)}"); } if (SegmentIterator.IterationDirection == IterationDirection.Forwards) { if (cellPassTime > IteratorEndTime) { return(false); } } else { if (cellPassTime < IteratorStartTime) { return(false); } } } while (cellPassTime < IteratorStartTime || cellPassTime > IteratorEndTime); lastReturnedCellPassTime = cellPassTime; return(true); }
/// <summary> /// Performs extraction of specific attributes from a GlobalLatestCells structure depending on the type of /// grid being retrieved /// </summary> /// <param name="cellPass"></param> /// <param name="x"></param> /// <param name="y"></param> protected void AssignRequiredFilteredPassAttributesFromGlobalLatestCells(ref CellPass cellPass, int x, int y) { switch (_gridDataType) { case GridDataType.Height: cellPass.Height = _globalLatestCells.ReadHeight(x, y); break; case GridDataType.HeightAndTime: case GridDataType.CutFill: cellPass.Height = _globalLatestCells.ReadHeight(x, y); cellPass.Time = _globalLatestCells.ReadTime(x, y); break; case GridDataType.CCV: cellPass.CCV = _globalLatestCells.ReadCCV(x, y); break; case GridDataType.RMV: cellPass.RMV = _globalLatestCells.ReadRMV(x, y); break; case GridDataType.Frequency: cellPass.Frequency = _globalLatestCells.ReadFrequency(x, y); break; case GridDataType.Amplitude: cellPass.Amplitude = _globalLatestCells.ReadAmplitude(x, y); break; case GridDataType.GPSMode: cellPass.gpsMode = _globalLatestCells.ReadGPSMode(x, y); break; case GridDataType.MDP: cellPass.MDP = _globalLatestCells.ReadMDP(x, y); break; case GridDataType.CCA: cellPass.CCA = _globalLatestCells.ReadCCA(x, y); break; case GridDataType.Temperature: cellPass.MaterialTemperature = _globalLatestCells.ReadTemperature(x, y); break; default: throw new TRexSubGridProcessingException($"Unsupported grid data type in AssignRequiredFilteredPassAttributesFromGlobalLatestCells: {_gridDataType}"); } }
public void Test_CellPass_FromToBinary() { var cp1 = ATestCellPass(); var writer = new TestBinaryWriter(); cp1.ToBinary(writer); var cp2 = new CellPass(); cp2.FromBinary(new TestBinaryReader(writer._stream.BaseStream as MemoryStream)); cp1.Should().BeEquivalentTo(cp2); }
public void GetElement_SingleElement_Success() { var baseTime = DateTime.UtcNow; var span = new TRexSpan <CellPass>(new CellPass[3], TRexSpan <CellPass> .NO_SLAB_INDEX, 0, 3, false); var cp = new CellPass { Time = baseTime }; span.Add(cp); span.GetElement(0).Should().BeEquivalentTo(cp); }
public void Test_ServerSubGridTreeLeaf_Clear() { var leaf = CreateADefaultEmptyLeaf(); CellPass pass = CreateTestCellPass(); leaf.AddPass(0, 0, pass); leaf.ComputeLatestPassInformation(true, StorageProxy.Instance(StorageMutability.Mutable)); leaf.Clear(); Assert.False(leaf.CellHasValue(0, 0), "Cell has a value"); // Assert.IsTrue(leaf.Directory.SegmentDirectory.First().Segment.PassesData.PassData[0,0].PassCount == 0, "cell pass count is not 0"); Assert.Null(leaf.Directory.SegmentDirectory.First().Segment); }
public void Test_CellPass_MachineIDAndTime() { CellPass cp = ATestCellPass(); DateTime testTime = DateTime.Now; cp.InternalSiteModelMachineIndex = 100; cp.Time = testTime; //cp.MachineIDAndTime(out long InternalSiteModelMachineIndex, out DateTime Time); // Assert.True(InternalSiteModelMachineIndex == 100 && Time == testTime, "Machine ID and time are not the expected values"); cp.MachineIDAndTime(out short internalSiteModelMachineIndex, out DateTime Time); Assert.True(internalSiteModelMachineIndex == 100 && Time == testTime, "Machine ID and time are not the expected values"); }
public void SubGridCellSegmentPassesDataWrapper_NonStatic_LocateTime_Test() { CellPass pass1 = TestCellPass(); pass1.Time = DateTime.SpecifyKind(new DateTime(2000, 1, 1, 0, 0, 0), DateTimeKind.Utc); CellPass pass2 = TestCellPass(); pass2.Time = DateTime.SpecifyKind(new DateTime(2000, 1, 2, 0, 0, 0), DateTimeKind.Utc); CellPass pass3 = TestCellPass(); pass3.Time = DateTime.SpecifyKind(new DateTime(2000, 1, 3, 0, 0, 0), DateTimeKind.Utc); using (var item = new SubGridCellSegmentPassesDataWrapper_NonStatic()) { item.AddPass(1, 1, pass1); item.AddPass(1, 1, pass2); item.AddPass(1, 1, pass3); Assert.Equal(3, item.PassCount(1, 1)); bool exactMatch = item.LocateTime(1, 1, DateTime.SpecifyKind(new DateTime(1999, 12, 31, 0, 0, 0), DateTimeKind.Utc), out int index); Assert.False(exactMatch, "Exact match found!!!"); Assert.Equal(0, index); exactMatch = item.LocateTime(1, 1, DateTime.SpecifyKind(new DateTime(2000, 1, 1, 0, 0, 0), DateTimeKind.Utc), out index); Assert.True(exactMatch && index > -1 && item.Pass(1, 1, (int)index).Equals(pass1), $"Failed to locate pass at DateTime(2000, 1, 1, 0, 0, 0), located pass is {item.Pass(1, 1, (int) index)}"); exactMatch = item.LocateTime(1, 1, DateTime.SpecifyKind(new DateTime(2000, 1, 1, 0, 0, 1), DateTimeKind.Utc), out index); Assert.True(exactMatch == false && item.Pass(1, 1, (int)index - 1).Equals(pass1), $"Failed to locate pass at DateTime(2000, 1, 1, 0, 0, 1), index = {index}"); exactMatch = item.LocateTime(1, 1, DateTime.SpecifyKind(new DateTime(2000, 1, 2, 10, 0, 0), DateTimeKind.Utc), out index); Assert.True(!exactMatch && index > -1 && item.Pass(1, 1, (int)index - 1).Equals(pass2), $"Failed to locate pass at DateTime(2001, 1, 2, 10, 0, 0), index = {index}"); exactMatch = item.LocateTime(1, 1, DateTime.SpecifyKind(new DateTime(2001, 1, 1, 0, 0, 0), DateTimeKind.Utc), out index); Assert.True(!exactMatch && index > -1 && item.Pass(1, 1, (int)index - 1).Equals(pass3), $"Failed to locate pass at DateTime(2001, 1, 1, 0, 0, 0), index = {index}"); } }