public void Should_Calculate_ThrowException_WhenSlotsAreSmallerThenSessions() { // Given var trackBuilder = Substitute.For <ITrackBuilder>(); trackBuilder.Build(Arg.Any <int>()).Returns(new List <Track>()); var optionAccessor = Substitute.For <IOptions <SchedulingOptions> >(); optionAccessor.Value.Returns(new SchedulingOptions { ConcurrentTracks = 1 }); var strategy = Substitute.For <ITrackSlotAllocationStrategy>(); var allocationResult = new AllocationResult(new List <TrackSlot>(), new List <SessionDefinition> { new SessionDefinition("Session", 30) }); strategy.Allocate(Arg.Any <IReadOnlyList <TrackSlot> >(), Arg.Any <IReadOnlyList <SessionDefinition> >()) .Returns(allocationResult); var sut = new TrackSchedulingEngine(trackBuilder, strategy, optionAccessor); // When Action action = () => sut.Calculate(_fixture.SessionDefinitions); // Then action.ShouldThrow <UnallocatedSessionsException>(); }
public CentroidDailyAnalysisMethod(ILocalityQuerySetup querySetup) { this.querySetup = querySetup; this.resultsByLocality = new List <LocalityResult>(); this.allocationResult = new AllocationResult(); this.allDistances = new List <double>(); }
public void SetUp() { this.allocationResult = new AllocationResult(2934762); this.resource = new AllocationOptionsResource { AccountId = 111, ArticleNumber = "article", StockPoolCode = "st", DespatchLocationCode = "d", ExcludeOnHold = true, ExcludeOverCreditLimit = true, ExcludeUnsuppliableLines = true }; this.AllocationFacadeService.StartAllocation(Arg.Any <AllocationOptionsResource>()) .Returns(new SuccessResult <AllocationResult>(this.allocationResult)); this.Response = this.Browser.Post( "/logistics/allocations", with => { with.Header("Accept", "application/json"); with.Header("Content-Type", "application/json"); with.JsonBody(this.resource); }).Result; }
public void Should_Calculate_ReturnTheCorrectAllocation_WhenSlotsAreAllocatedCorrectly() { // Given var trackBuilder = Substitute.For <ITrackBuilder>(); var tracks = new List <Track> { _fixture.EqualSlotsTrack }; trackBuilder.Build(Arg.Any <int>()).Returns(tracks); var optionAccessor = Substitute.For <IOptions <SchedulingOptions> >(); optionAccessor.Value.Returns(new SchedulingOptions { ConcurrentTracks = 1 }); var strategy = Substitute.For <ITrackSlotAllocationStrategy>(); var allocationResult = new AllocationResult(new List <TrackSlot>(), new List <SessionDefinition>()); strategy.Allocate(Arg.Any <IReadOnlyList <TrackSlot> >(), Arg.Any <IReadOnlyList <SessionDefinition> >()) .Returns(allocationResult); var sut = new TrackSchedulingEngine(trackBuilder, strategy, optionAccessor); // When var result = sut.Calculate(_fixture.SessionDefinitions); // Then result.ShouldBeEquivalentTo(tracks); }
public void SetUp() { this.AllocPack.StartAllocation( this.stockPoolCode, this.despatchLocation, this.accountId, null, this.articleNumber, this.accountingCompany, this.cutOffDate, this.countryCode, this.excludeUnsuppliable, this.excludeHold, this.excludeOverCredit, this.excludeNorthAmerica, this.excludeEuropeanUnion, out _, out _).Returns(808); this.result = this.Sut.StartAllocation( this.stockPoolCode, this.despatchLocation, this.accountId, this.articleNumber, this.accountingCompany, this.countryCode, this.cutOffDate, this.excludeUnsuppliable, this.excludeHold, this.excludeOverCredit, this.excludeNorthAmerica, this.excludeEuropeanUnion); }
public TravelingSalesmanAnalyser(ILocalityQuerySetup querySetup, ITSPOptions options) { this.querySetup = querySetup; this.options = options; this.resultsByLocality = new List <LocalityResult>(); this.allocationResult = new AllocationResult(); this.allTourLengths = new List <double>(); }
public void SetUp() { this.jobId = 1234; this.allocationResult = new AllocationResult(this.jobId); this.AllocationService.FinishAllocation(this.jobId) .Returns(this.allocationResult); this.result = this.Sut.FinishAllocation(this.jobId); }
public CodeGenContext(AllocationResult allocResult, int maxCallArgs, int blocksCount, bool relocatable) { _stream = new MemoryStream(); _blockLabels = new Operand[blocksCount]; AllocResult = allocResult; Assembler = new Assembler(_stream, relocatable); CallArgsRegionSize = GetCallArgsRegionSize(allocResult, maxCallArgs, out int xmmSaveRegionSize); XmmSaveRegionSize = xmmSaveRegionSize; }
private void RecordAllocationResult() { BasicStatistics stats = new BasicStatistics(this.allDistances); var CI = new ConfidenceIntervalStandardNormal(stats); this.allocationResult = new AllocationResult() { Mean = stats.Mean, LCI = CI.LowerBound, UCI = CI.UpperBound, Stats = stats, }; }
public CodeGenContext(Stream stream, AllocationResult allocResult, int maxCallArgs, int blocksCount) { _stream = stream; AllocResult = allocResult; Assembler = new Assembler(stream); CallArgsRegionSize = GetCallArgsRegionSize(allocResult, maxCallArgs, out int xmmSaveRegionSize); XmmSaveRegionSize = xmmSaveRegionSize; _blockOffsets = new long[blocksCount]; _jumps = new List <Jump>(); }
public void SetUp() { this.jobId = 283476; this.allocationResult = new AllocationResult(this.jobId); this.resource = new JobIdRequestResource { JobId = this.jobId }; this.AllocationFacadeService.FinishAllocation(this.jobId) .Returns(new SuccessResult <AllocationResult>(this.allocationResult)); this.Response = this.Browser.Post( $"/logistics/allocations/finish", with => { with.Header("Accept", "application/json"); with.Header("Content-Type", "application/json"); with.JsonBody(this.resource); }).Result; }
private static int GetCallArgsRegionSize(AllocationResult allocResult, int maxCallArgs, out int xmmSaveRegionSize) { // We need to add 8 bytes to the total size, as the call to this function already pushed 8 bytes (the // return address). int intMask = CallingConvention.GetIntCalleeSavedRegisters() & allocResult.IntUsedRegisters; int vecMask = CallingConvention.GetVecCalleeSavedRegisters() & allocResult.VecUsedRegisters; xmmSaveRegionSize = BitOperations.PopCount((uint)vecMask) * 16; int calleeSaveRegionSize = BitOperations.PopCount((uint)intMask) * 8 + xmmSaveRegionSize + 8; int argsCount = maxCallArgs; if (argsCount < 0) { // When the function has no calls, argsCount is -1. In this case, we don't need to allocate the shadow // space. argsCount = 0; } else if (argsCount < 4) { // The ABI mandates that the space for at least 4 arguments is reserved on the stack (this is called // shadow space). argsCount = 4; } // TODO: Align XMM save region to 16 bytes because unwinding on Windows requires it. int frameSize = calleeSaveRegionSize + allocResult.SpillRegionSize; // TODO: Instead of always multiplying by 16 (the largest possible size of a variable, since a V128 has 16 // bytes), we should calculate the exact size consumed by the arguments passed to the called functions on // the stack. int callArgsAndFrameSize = frameSize + argsCount * 16; // Ensure that the Stack Pointer will be aligned to 16 bytes. callArgsAndFrameSize = (callArgsAndFrameSize + 0xf) & ~0xf; return(callArgsAndFrameSize - frameSize); }
public void Should_Calculate_ReturnTheCorrectAllocation_WhenSlotsAreEqual() { // Given var trackBuilder = Substitute.For <ITrackBuilder>(); trackBuilder.Build(Arg.Any <int>()).Returns(new List <Track> { _fixture.EqualSlotsTrack }); var optionAccessor = Substitute.For <IOptions <SchedulingOptions> >(); optionAccessor.Value.Returns(new SchedulingOptions { ConcurrentTracks = 1 }); var strategy = Substitute.For <ITrackSlotAllocationStrategy>(); var allocationResult = new AllocationResult(new List <TrackSlot>(), new List <SessionDefinition>()); strategy.Allocate(Arg.Any <IReadOnlyList <TrackSlot> >(), Arg.Any <IReadOnlyList <SessionDefinition> >()) .Returns(allocationResult); var sut = new TrackSchedulingEngine(trackBuilder, strategy, optionAccessor); // When var result = sut.Calculate(_fixture.SessionDefinitions); // Then result[0].Slots[0].TrackSessions.Should() .HaveCount(2) .And.Contain(m => m.Title == "Session #2") .And.Contain(m => m.Title == "Session #3"); result[0].Slots[1].TrackSessions.Should() .HaveCount(3) .And.Contain(m => m.Title == "Session #5") .And.Contain(m => m.Title == "Session #1") .And.Contain(m => m.Title == "Session #4"); }
public void SetUp() { this.startDetails = new AllocationResult(234); this.resource = new AllocationOptionsResource { StockPoolCode = "LINN", AccountId = 24, ArticleNumber = "article", DespatchLocationCode = "dispatch", AccountingCompany = "LINN", CutOffDate = 1.July(2021).ToString("o"), CountryCode = null, ExcludeOverCreditLimit = true, ExcludeUnsuppliableLines = true, ExcludeOnHold = true, ExcludeNorthAmerica = true, ExcludeEuropeanUnion = true }; this.AllocationService.StartAllocation( Arg.Any <string>(), Arg.Any <string>(), Arg.Any <int>(), Arg.Any <string>(), Arg.Any <string>(), Arg.Any <string>(), Arg.Any <DateTime?>(), Arg.Any <bool>(), Arg.Any <bool>(), Arg.Any <bool>(), Arg.Any <bool>(), Arg.Any <bool>()) .Returns(this.startDetails); this.result = this.Sut.StartAllocation(this.resource); }
public void SetUp() { this.AllocPack.When(a => a.FinishAllocation(JobId, out Arg.Any <string>(), out Arg.Any <string>())) .Do(x => { x[2] = "Y"; }); this.result = this.Sut.FinishAllocation(JobId); }