public INettingWeightResult GetUnnettingResult(INettingTarget primary, IEnumerable <INettingSource> unnetted)
        {
            var result = new NettingWeightResult(primary);

            unnetted.ForEach(transfer => result.Unnet(transfer));
            return(result);
        }
 public NettingWeightResult(INettingTarget primary)
 {
     _primary          = primary;
     _primaryDirection = primary.Type.IsExternalBuy() ? 1 : -1;
     ResultWeight      = OriginalWeight = _primaryDirection * primary.AccountingWeight;
     ResultImbalance   = OriginalImbalance = primary.ImbalanceWeight;
 }
        public void TestFixtureSetup()
        {
            _calculator = new NettingWeightCalculator();

            var unit = new Unit {
                Name = "ozt"
            };

            var primaryBuyMock = new Mock <INettingTarget>();

            primaryBuyMock.Setup(transfer => transfer.Type).Returns(TransferType.TransferBuyType1);
            primaryBuyMock.Setup(transfer => transfer.AccountingWeight).Returns(1000m);
            primaryBuyMock.Setup(transfer => transfer.ImbalanceWeight).Returns(-100m);
            primaryBuyMock.Setup(transfer => transfer.AdjustmentWeight).Returns(0m);
            primaryBuyMock.Setup(transfer => transfer.AccountingUnit).Returns(unit);
            _primaryBuy = primaryBuyMock.Object;

            var primarySellMock = new Mock <INettingTarget>();

            primarySellMock.Setup(transfer => transfer.Type).Returns(TransferType.TransferSellType1);
            primarySellMock.Setup(transfer => transfer.AccountingWeight).Returns(1000m);
            primarySellMock.Setup(transfer => transfer.ImbalanceWeight).Returns(-100m);
            primarySellMock.Setup(transfer => transfer.AdjustmentWeight).Returns(0m);
            primarySellMock.Setup(transfer => transfer.AccountingUnit).Returns(unit);
            _primarySell = primarySellMock.Object;

            var qpBuyMock = new Mock <INettingSource>();

            qpBuyMock.Setup(transfer => transfer.Type).Returns(TransferType.TransferBuyType1);
            qpBuyMock.Setup(transfer => transfer.AccountingWeight).Returns(100m);
            qpBuyMock.Setup(transfer => transfer.AdjustmentWeight).Returns(0m);
            _secondaryBuy = qpBuyMock.Object;

            var qpBuyDirectionChangingMock = new Mock <INettingSource>();

            qpBuyDirectionChangingMock.Setup(transfer => transfer.Type).Returns(TransferType.TransferBuyType1);
            qpBuyDirectionChangingMock.Setup(transfer => transfer.AccountingWeight).Returns(1500m);
            qpBuyDirectionChangingMock.Setup(transfer => transfer.AdjustmentWeight).Returns(0m);
            _secondaryBuyDirectionChanging = qpBuyDirectionChangingMock.Object;

            var qpSellMock = new Mock <INettingSource>();

            qpSellMock.Setup(transfer => transfer.Type).Returns(TransferType.TransferSellType1);
            qpSellMock.Setup(transfer => transfer.AccountingWeight).Returns(100m);
            qpSellMock.Setup(transfer => transfer.AdjustmentWeight).Returns(0m);
            _secondarySell = qpSellMock.Object;

            var qpSellDirectionChangingMock = new Mock <INettingSource>();

            qpSellDirectionChangingMock.Setup(transfer => transfer.Type).Returns(TransferType.TransferSellType1);
            qpSellDirectionChangingMock.Setup(transfer => transfer.AccountingWeight).Returns(1500m);
            qpSellDirectionChangingMock.Setup(transfer => transfer.AdjustmentWeight).Returns(0m);
            _secondarySellDirectionChanging = qpSellDirectionChangingMock.Object;

            var qpAdjustmentMock = new Mock <INettingSource>();

            qpAdjustmentMock.Setup(transfer => transfer.Type).Returns(TransferType.TransferAdjustmentType);
            qpAdjustmentMock.Setup(transfer => transfer.AccountingWeight).Returns(0m);
            qpAdjustmentMock.Setup(transfer => transfer.AdjustmentWeight).Returns(100m);
            _adjustment = qpAdjustmentMock.Object;
        }
 public INettingWeightResult GetInitialResult(INettingTarget primary)
 {
     return(new NettingWeightResult(primary));
 }