public void Creation() { var mockRepository = new MockRepository(MockBehavior.Strict); var id = Guid.NewGuid(); var transaction = mockRepository.Create <IPortfolioTransaction>(); var properties = new ParcelProperties(100, 1000.00m, 2000.00m); var parcel = new Parcel(id, new Date(2000, 01, 01), new Date(1999, 01, 01), properties, transaction.Object); using (new AssertionScope()) { parcel.Should().BeEquivalentTo(new { Id = id, EffectivePeriod = new DateRange(new Date(2000, 01, 01), Date.MaxValue), AquisitionDate = new Date(1999, 01, 01) }); parcel.Properties[new Date(2000, 01, 01)].Should().Be(properties); parcel.Audit.Should().ContainSingle().Which.Should().BeEquivalentTo(new { Date = new Date(2000, 01, 01), UnitCountChange = 100, CostBaseChange = 2000.00m, AmountChange = 1000.00m, Transaction = transaction.Object }); } mockRepository.Verify(); }
public void ChangeReduceUnitCountToZero() { var mockRepository = new MockRepository(MockBehavior.Strict); var id = Guid.NewGuid(); var transaction = mockRepository.Create <IPortfolioTransaction>(); var properties = new ParcelProperties(100, 1000.00m, 2000.00m); var parcel = new Parcel(id, new Date(2000, 01, 01), new Date(1999, 01, 01), properties, transaction.Object); var transaction2 = mockRepository.Create <IPortfolioTransaction>(); parcel.Change(new Date(2010, 06, 30), -100, 200.00m, 300.00m, transaction2.Object); using (new AssertionScope()) { parcel.EffectivePeriod.Should().Be(new DateRange(new Date(2000, 01, 01), new Date(2010, 06, 30))); parcel.Properties[new Date(2010, 06, 29)].Should().Be(properties); parcel.Properties[new Date(2010, 06, 30)].Should().Be(new ParcelProperties(0, 0.00m, 0.00m)); parcel.Audit.Should().BeEquivalentTo(new[] { new ParcelAudit(new Date(2000, 01, 01), 100, 2000.00m, 1000.00m, transaction.Object), new ParcelAudit(new Date(2010, 06, 30), -100, 300.00m, 200.00m, transaction2.Object) }); } mockRepository.Verify(); }
public void ChangeTwiceOnSameDay() { var mockRepository = new MockRepository(MockBehavior.Strict); var id = Guid.NewGuid(); var transaction = mockRepository.Create <IPortfolioTransaction>(); var properties = new ParcelProperties(100, 1000.00m, 2000.00m); var parcel = new Parcel(id, new Date(2000, 01, 01), new Date(1999, 01, 01), properties, transaction.Object); var transaction2 = mockRepository.Create <IPortfolioTransaction>(); parcel.Change(new Date(2010, 06, 30), 100, 200.00m, 300.00m, transaction2.Object); var transaction3 = mockRepository.Create <IPortfolioTransaction>(); parcel.Change(new Date(2010, 06, 30), 200, 300.00m, 400.00m, transaction3.Object); using (new AssertionScope()) { parcel.Properties[new Date(2010, 06, 29)].Should().Be(properties); parcel.Properties[new Date(2010, 06, 30)].Should().Be(new ParcelProperties(400, 1500.00m, 2700.00m)); parcel.Audit.Should().BeEquivalentTo(new[] { new ParcelAudit(new Date(2000, 01, 01), 100, 2000.00m, 1000.00m, transaction.Object), new ParcelAudit(new Date(2010, 06, 30), 100, 300.00m, 200.00m, transaction2.Object), new ParcelAudit(new Date(2010, 06, 30), 200, 400.00m, 300.00m, transaction3.Object) }); } mockRepository.Verify(); }
public void ChangeUnitsToLessThanZero() { var mockRepository = new MockRepository(MockBehavior.Strict); var id = Guid.NewGuid(); var transaction = mockRepository.Create <IPortfolioTransaction>(); var properties = new ParcelProperties(100, 1000.00m, 2000.00m); var parcel = new Parcel(id, new Date(2000, 01, 01), new Date(1999, 01, 01), properties, transaction.Object); Action a = () => parcel.Change(new Date(2010, 06, 30), -200, 0.00m, 0.00m, transaction.Object); a.Should().Throw <ArgumentException>(); mockRepository.Verify(); }
public void ChangeBeforeEffectivePeriod() { var mockRepository = new MockRepository(MockBehavior.Strict); var id = Guid.NewGuid(); var transaction = mockRepository.Create <IPortfolioTransaction>(); var properties = new ParcelProperties(100, 1000.00m, 2000.00m); var parcel = new Parcel(id, new Date(2000, 01, 01), new Date(1999, 01, 01), properties, transaction.Object); Action a = () => parcel.Change(new Date(1999, 06, 30), 10, 10.00m, 10.00m, transaction.Object); a.Should().Throw <EffectiveDateException>(); mockRepository.Verify(); }
public void HandleParcelPropertiesRequestByID(Message m) { var req = (ParcelPropertiesRequestByID)m; if (req.CircuitSessionID != req.SessionID || req.CircuitAgentID != req.AgentID) { return; } ParcelInfo pinfo; if (Parcels.TryGetValue(req.LocalID, out pinfo)) { ParcelProperties props = ParcelInfo2ParcelProperties(req.AgentID, pinfo, req.SequenceID, ParcelProperties.RequestResultType.Single); Agents[req.AgentID].SendMessageAlways(props, ID); } }
public void CalculateParcelCgt(Date disposalDate, int unitsSold, decimal saleAmount, decimal expectedCostBase, decimal expectedCapitalGain, decimal expectedDiscountedGain, CgtMethod expectedCgtMethod, string because) { var aquisitionDate = new Date(2017, 01, 01); var properties = new ParcelProperties(1000, 1000.00m, 2000.00m); var parcel = new Parcel(Guid.NewGuid(), aquisitionDate, aquisitionDate, properties, null); parcel.Change(new Date(2017, 08, 01), 1000, 2000.00m, 2000.00m, null); var calculator = new CgtCalculator(); var parcelSold = calculator.CalculateParcelCgt(parcel, disposalDate, unitsSold, saleAmount); parcelSold.Should().BeEquivalentTo(new { AmountReceived = saleAmount, CostBase = expectedCostBase, CapitalGain = expectedCapitalGain, DiscountedGain = expectedDiscountedGain, CgtMethod = expectedCgtMethod }, because); }
public JsonResult GetParcelCost(RequestData RequestData) { var parcelDimension = new ParcelProperties(); foreach (var item in RequestData.RequestParams) { if (item.key == "Height") { parcelDimension.Height = item.value; } if (item.key == "Length") { parcelDimension.Length = item.value; } if (item.key == "Breadth") { parcelDimension.Breadth = item.value; } if (item.key == "Weight") { parcelDimension.Weight = item.value; } } var returnedObject = _parcelHelper.GetCost(Map.MapParcelDimensions(parcelDimension)); if (returnedObject == null) { return(Json(new { message = "Sorry we do not provide any packaging solution for the dimensions or weight you have provided." })); } var returnMessage = "You can send a " + returnedObject.Type + " for the dimensions you have provided at a cost of $" + returnedObject.Cost; return(Json(new { message = returnMessage })); }
public void HandleParcelPropertiesRequest(Message m) { var results = new Dictionary <UUID, ParcelInfo>(); var req = (ParcelPropertiesRequest)m; if (req.CircuitSessionID != req.SessionID || req.CircuitAgentID != req.AgentID) { return; } var start_x = (int)(req.West + 0.5); var start_y = (int)(req.South + 0.5); var end_x = (int)(req.East + 0.5); var end_y = (int)(req.North + 0.5); if (start_x < 0) { start_x = 0; } if (start_y < 0) { start_y = 0; } if (end_x >= SizeX) { end_x = (int)SizeX - 1; } if (end_y >= SizeY) { end_y = (int)SizeY - 1; } for (int x = start_x; x <= end_x; ++x) { for (int y = start_y; y <= end_y; ++y) { ParcelInfo pinfo; try { pinfo = Parcels[new Vector3(x, y, 0)]; } catch { continue; } if (!results.ContainsKey(pinfo.ID)) { results.Add(pinfo.ID, pinfo); } } } IAgent agent; if (!Agents.TryGetValue(req.AgentID, out agent)) { return; } foreach (ParcelInfo pinfo in results.Values) { ParcelProperties props = ParcelInfo2ParcelProperties(req.AgentID, pinfo, req.SequenceID, (results.Count > 1) ? ParcelProperties.RequestResultType.Multiple : ParcelProperties.RequestResultType.Single); props.SnapSelection = req.SnapSelection; agent.SendMessageAlways(props, ID); } }