コード例 #1
0
        /// <summary>
        /// Gets the outbound quantity.
        /// </summary>
        /// <param name="entities">The entities.</param>
        /// <param name="parent">The parent.</param>
        /// <param name="start">The start.</param>
        /// <param name="end">The end.</param>
        /// <returns></returns>
        public override decimal GetOutboundQuantity(Entities entities, JSOXLib parent, out DateTime start, out DateTime end)
        {
            decimal _ret = 0;

            SummaryContentList = new List <JSOXCustomsSummaryContent>();
            start = LinqIPRExtensions.DateTimeMaxValue;
            end   = LinqIPRExtensions.DateTimeMinValue;
            foreach (Disposal _dspx in Disposal.GetEntries4JSOX(entities, parent))
            {
                start = LinqIPRExtensions.Min(start, _dspx.SADDate.GetValueOrDefault(LinqIPRExtensions.DateTimeMaxValue));
                end   = LinqIPRExtensions.Max(end, _dspx.SADDate.GetValueOrDefault(LinqIPRExtensions.DateTimeMinValue));
                JSOXCustomsSummaryContent _new = new JSOXCustomsSummaryContent()
                {
                    CompensationGood           = _dspx.Disposal2PCNID == null ? "TBD" : _dspx.Disposal2PCNID.CompensationGood,
                    EntryDocumentNo            = _dspx.Disposal2IPRIndex.DocumentNo,
                    ExportOrFreeCirculationSAD = _dspx.SADDocumentNo,
                    InvoiceNo        = _dspx.InvoiceNo,
                    SADDate          = _dspx.SADDate.GetValueOrDefault(),
                    Quantity         = _dspx.SettledQuantityDec,
                    Balance          = _dspx.RemainingQuantity.Round2DecimalOrDefault(),
                    Procedure        = _dspx.CustomsProcedure,
                    SadConsignmentNo = _dspx.SadConsignmentNo
                };
                _ret += _dspx.SettledQuantityDec;
                _dspx.JSOXReportID = parent.Id.Value;
                SummaryContentList.Add(_new);
            }
            return(_ret);
        }
コード例 #2
0
        public void HasBeenAppliedNoResultStock()
        {
            var mockRepository = new MockRepository(MockBehavior.Strict);

            var stock = new Stock(Guid.NewGuid());

            stock.List("ABC", "ABC Pty Ltd", new Date(1974, 01, 01), false, AssetCategory.AustralianStocks);

            var resultStocks   = new Transformation.ResultingStock[] { };
            var transformation = new Transformation(Guid.NewGuid(), stock, new Date(2020, 01, 01), "Test Transformation", new Date(2020, 02, 01), 10.00m, true, resultStocks);

            var transaction = new Disposal()
            {
                Id                    = Guid.NewGuid(),
                Date                  = new Date(2020, 02, 01),
                Stock                 = stock,
                Comment               = "Test Disposal",
                Units                 = 100,
                AveragePrice          = 10.00m,
                TransactionCosts      = 0.00m,
                CgtMethod             = CgtCalculationMethod.FirstInFirstOut,
                CreateCashTransaction = true
            };

            var transactions = mockRepository.Create <IPortfolioTransactionList>();

            transactions.Setup(x => x.ForHolding(stock.Id, transformation.ImplementationDate)).Returns(new IPortfolioTransaction[] { transaction });

            var result = transformation.HasBeenApplied(transactions.Object);

            result.Should().BeTrue();

            mockRepository.Verify();
        }
コード例 #3
0
        private void lstTree_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e)
        {
            var dtDate = new DateTimePickerEx
            {
                CustomFormat = "MM/dd/yyyy",
                Value        = DateTime.Now
            };
            DateTime dtCurrent = ConvertDate.DateConverter(dtDate.Text);
            var      dr        = (DataRowView)lstTree.GetDataRecordByNode(lstTree.FocusedNode);

            if (dr == null)
            {
                return;
            }

            var       adj = new Disposal();
            DataTable dtRec;

            if (dr["ParentID"] == DBNull.Value)
            {
                int      yr  = ((dtCurrent.Month > 10) ? dtCurrent.Year : dtCurrent.Year - 1);
                DateTime dt1 = new DateTime(Convert.ToInt32(dr["ID"]) - 1, 11, 1);
                DateTime dt2 = new DateTime(Convert.ToInt32(dr["ID"]), 11, 1);
                dtRec           = adj.GetTransactionByDateRange(Convert.ToInt32(cboStores.EditValue), dt1, dt2);
                lblAdjDate.Text = dr["RefNo"].ToString();
            }
            else
            {
                dtRec           = adj.GetDocumentByRefNo(dr["RefNo"].ToString(), Convert.ToInt32(cboStores.EditValue), dr["Date"].ToString());
                lblAdjDate.Text = Convert.ToDateTime(dr["Date"]).ToString("MM dd,yyyy");
            }

            gridAdjustments.DataSource = dtRec;
        }
コード例 #4
0
        /// <summary>
        ///     Create a new test-suite.
        /// </summary>
        /// <param name="testOutput">
        ///     Output for the current test.
        /// </param>
        protected TestBase(ITestOutputHelper testOutput)
        {
            if (testOutput == null)
            {
                throw new ArgumentNullException(nameof(testOutput));
            }

            // We *must* have a synchronisation context for the test, or we'll see random deadlocks.
            if (SynchronizationContext.Current == null)
            {
                SynchronizationContext.SetSynchronizationContext(
                    new SynchronizationContext()
                    );
            }

            Disposal.Add(TestCancellationSource);

            TestOutput    = testOutput;
            LoggerFactory = new LoggerFactory().AddTestOutput(TestOutput, MinLogLevel);
            Log           = LoggerFactory.CreateLogger("CurrentTest");

            // Ugly hack to get access to the current test.
            CurrentTest = (ITest)
                          TestOutput.GetType()
                          .GetField("test", BindingFlags.NonPublic | BindingFlags.Instance)
                          .GetValue(TestOutput);

            Assert.True(CurrentTest != null, "Cannot retrieve current test from ITestOutputHelper.");

            Disposal.Add(
                Log.BeginScope("CurrentTest", CurrentTest.DisplayName)
                );
        }
コード例 #5
0
        public void HighRating()
        {
            using (var rhetos = new BookstoreRhetos())
            {
                var repository = rhetos.Resolve <Common.DomRepository>();

                var book1 = new Book {
                    Title = "Simple book"
                };
                var book2 = new Book {
                    Title = "Super great book"
                };
                repository.Bookstore.Book.Insert(book1, book2);

                var ratings = repository.Bookstore.BookRating.Query(new[] { book1.ID, book2.ID })
                              .OrderBy(r => r.Base.Code)
                              .ToSimple().ToList();
                Assert.AreEqual("0.00, 150.00", TestUtility.Dump(ratings, r => r.Rating?.ToString("0.00", CultureInfo.InvariantCulture)));

                var disposal1 = new Disposal {
                    BookID = book1.ID, Explanation = "damaged"
                };
                repository.Bookstore.Disposal.Insert(disposal1);

                var disposal2 = new Disposal {
                    BookID = book2.ID, Explanation = "damaged"
                };
                TestUtility.ShouldFail <UserException>(
                    () => repository.Bookstore.Disposal.Insert(disposal2),
                    "rating above 100");
            }
        }
コード例 #6
0
        /// <summary>
        /// Create a <see cref="LanguageClient" /> connected to the test's <see cref="PipeServerProcess" />.
        /// </summary>
        /// <returns>
        /// The <see cref="LanguageClient" />.
        /// </returns>
        protected async Task<(ILanguageClient client, ILanguageServer server)> Initialize(
            Action<LanguageClientOptions> clientOptionsAction,
            Action<LanguageServerOptions> serverOptionsAction
        )
        {
            var clientPipe = new Pipe();
            var serverPipe = new Pipe();
            _client = LanguageClient.PreInit(
                options => {
                    options.WithServices(services => services.AddSingleton(LoggerFactory));
                    options.WithInput(serverPipe.Reader).WithOutput(clientPipe.Writer);
                    options.WithRootPath(WorkspaceRoot);
                    clientOptionsAction(options);
                }
            );
            Disposal.Add(_client);

            _server = Server.LanguageServer.PreInit(
                options => {
                    options.WithServices(services => services.AddSingleton(LoggerFactory));
                    options.WithInput(clientPipe.Reader).WithOutput(serverPipe.Writer);
                    serverOptionsAction(options);
                }
            );
            Disposal.Add(_server);

            await Task.WhenAll(
                _client.Initialize(CancellationToken),
                _server.Initialize(CancellationToken)
            );

            return ( _client, _server );
        }
コード例 #7
0
        private void deleteToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            var us     = new User();
            var userID = MainWindow.LoggedinId;

            us.LoadByPrimaryKey(userID);

            var dr = (DataRowView)lstTree.GetDataRecordByNode(lstTree.FocusedNode);

            if (dr == null)
            {
                return;
            }
            if (us.UserName != "admin")
            {
                XtraMessageBox.Show("You don't have the privilege to update reference number!", "Caution");
                return;
            }
            if (XtraMessageBox.Show("Are You Sure, You want to delete this?", "Confirmation", MessageBoxButtons.YesNo,
                                    MessageBoxIcon.Question) == DialogResult.Yes)
            {
                var       dis  = new Disposal();
                DataTable dtbl = dis.GetTransactionByRefNo((string)dr["RefNo"]);
                foreach (DataRow dataRow in dtbl.Rows)
                {
                    AddlossDeleted(dataRow);
                    dataRow.Delete();
                }
                dis.MarkAsDeleted();
                dis.Save();
                XtraMessageBox.Show("Item successfully deleted.", "Success");
            }
        }
コード例 #8
0
        private void Update()
        {
            if (CurrentClearance == null)
            {
                throw GenericStateMachineEngine.ActionResult.Exception(null, "Internal error - ClearanceID is null or empty at Update");
            }
            Entities _edc = m_DataContextManagement.DataContext;

            CurrentClearance.UpdateClerance(_edc, m_SelectGroupRadioButtonList.SelectedValue, SelectedClearenceProcedure);
            //remove from clearance
            foreach (Selection.SelectionTableRow _row in m_ControlState.AvailableItems.SelectionTable.OnlyAdded)
            {
                Disposal _dspsl = Element.GetAtIndex <Disposal>(_edc.Disposal, _row.Id);
                RemoveDisposalFromClearance(_edc, _dspsl);
            }
            //add to clearance
            foreach (Selection.SelectionTableRow _row in m_ControlState.AssignedItems.SelectionTable.OnlyAdded)
            {
                if (_row.Disposal)
                {
                    Disposal _dspsl = Element.GetAtIndex <Disposal>(_edc.Disposal, _row.Id);
                    _dspsl.Disposal2ClearenceIndex = CurrentClearance;
                }
                else
                {
                    IPRClass _ipr = Element.GetAtIndex <IPRClass>(_edc.IPR, _row.Id);
                    _ipr.AddDisposal(_edc, Convert.ToDecimal(_row.Quantity), CurrentClearance);
                }
            }
            CurrentClearance.UpdateTitle(_edc);
            m_DataContextManagement.DataContext.SubmitChanges();
        }
コード例 #9
0
        public void NoSharesOwned()
        {
            var stock = new Stock(Guid.NewGuid());

            stock.List("ABC", "ABC Pty Ltd", new Date(1974, 01, 01), false, AssetCategory.AustralianStocks);

            var transaction = new Disposal()
            {
                Id                    = Guid.NewGuid(),
                Date                  = new Date(2020, 02, 01),
                Stock                 = stock,
                Comment               = "Test Disposal",
                Units                 = 100,
                AveragePrice          = 10.00m,
                TransactionCosts      = 19.95m,
                CgtMethod             = CgtCalculationMethod.FirstInFirstOut,
                CreateCashTransaction = true
            };

            var mockRepository = new MockRepository(MockBehavior.Strict);

            var holding = mockRepository.Create <IHolding>();

            holding.Setup(x => x.IsEffectiveAt(new Date(2020, 02, 01))).Returns(false);

            var cashAccount = mockRepository.Create <ICashAccount>();

            var handler = new DisposalHandler();

            Action a = () => handler.Apply(transaction, holding.Object, cashAccount.Object);

            a.Should().Throw <NoSharesOwnedException>();

            mockRepository.Verify();
        }
コード例 #10
0
        public override void Dispose()
        {
            // Save the changes to the file
            Save();

            Disposal.Dispose();
        }
コード例 #11
0
        /// <summary>
        /// Create a new test-suite.
        /// </summary>
        /// <param name="testOutput">
        /// Output for the current test.
        /// </param>
        protected TestBase(ITestOutputHelper testOutput)
        {
            if (testOutput == null)
            {
                throw new ArgumentNullException(nameof(testOutput));
            }

            // We *must* have a synchronisation context for the test, or we'll see random deadlocks.
            SynchronizationContext.SetSynchronizationContext(
                new SynchronizationContext()
                );

            TestOutput = testOutput;

            // Redirect component logging to Serilog.
            LoggerFactory = new LoggerFactory();
            Disposal.Add(LoggerFactory);

            // LoggerFactory.AddDebug(LogLevel);
            // ReSharper disable once VirtualMemberCallInConstructor
            LoggerFactory.AddTestOutput(TestOutput, LogLevel);

            // Ugly hack to get access to the current test.
            CurrentTest = (ITest)
                          TestOutput.GetType()
                          .GetField("test", BindingFlags.NonPublic | BindingFlags.Instance) !
                          .GetValue(TestOutput) !;

            Assert.True(CurrentTest != null, "Cannot retrieve current test from ITestOutputHelper.");

            Log = LoggerFactory.CreateLogger("CurrentTest");

            Disposal.Add(Log.BeginScope("TestDisplayName='{TestName}'", CurrentTest !.DisplayName));
        }
コード例 #12
0
        internal static IPRIngredient GetIPRIngredient(Disposal disposal)
        {
            IPRIngredient _ret = new IPRIngredient(disposal.Disposal2IPRIndex.Batch, disposal.Disposal2IPRIndex.SKU, disposal.SettledQuantity.Value);

            CAS.SmartFactory.IPR.WebsiteModel.Linq.IPR _ipr = disposal.Disposal2IPRIndex;
            _ret.Currency        = _ipr.Currency;
            _ret.Date            = _ipr.CustomsDebtDate.Value;
            _ret.DocumentNoumber = _ipr.DocumentNo;
            _ret.Duty            = disposal.DutyPerSettledAmount.Value;
            switch (disposal.ClearingType.Value)
            {
            case CAS.SmartFactory.IPR.WebsiteModel.Linq.ClearingType.PartialWindingUp:
                _ret.ItemClearingType = xml.DocumentsFactory.CigaretteExportForm.ClearingType.PartialWindingUp;
                break;

            case CAS.SmartFactory.IPR.WebsiteModel.Linq.ClearingType.TotalWindingUp:
                _ret.ItemClearingType = xml.DocumentsFactory.CigaretteExportForm.ClearingType.PartialWindingUp;
                break;

            default:
                throw new ApplicationError("InvoiceLib.IPRIngredient", "ItemClearingType", "Wrong Clearing Type", null);
            }
            _ret.TobaccoUnitPrice = _ipr.IPRUnitPrice.Value;
            _ret.TobaccoValue     = disposal.TobaccoValue.Value;
            _ret.VAT = disposal.VATPerSettledAmount.Value;
            return(_ret);
        }
コード例 #13
0
        public void UncertainWords()
        {
            using (var rhetos = new BookstoreRhetos())
            {
                var repository = rhetos.Resolve <Common.DomRepository>();

                // Removing old data to make this test independent.
                var old = repository.Bookstore.UncertainWord.Load();
                repository.Bookstore.UncertainWord.Delete(old);

                var uncertain = new[] { "sometimes", "maybe", "someone" };
                repository.Bookstore.UncertainWord.Insert(
                    uncertain.Select(word => new UncertainWord {
                    Word = word
                }));

                var book = new Book {
                    Title = "Some book title"
                };
                repository.Bookstore.Book.Insert(book);

                var disposal1 = new Disposal {
                    BookID = book.ID, Explanation = "It was damaged"
                };
                repository.Bookstore.Disposal.Insert(disposal1);

                var disposal2 = new Disposal {
                    BookID = book.ID, Explanation = "Maybe it was damaged"
                };
                TestUtility.ShouldFail <UserException>(
                    () => repository.Bookstore.Disposal.Insert(disposal2),
                    @"The explanation ""Maybe it w..."" should not contain word ""maybe"". Book: Some book title.");
            }
        }
コード例 #14
0
        public void Apply(DisposalOccurredEvent @event)
        {
            var holding = _Holdings[@event.Stock];

            if (holding == null)
            {
                throw new NoSharesOwnedException("No shares owned");
            }

            var disposal = new Disposal
            {
                Id                    = @event.TransactionId,
                Date                  = @event.Date,
                Stock                 = holding.Stock,
                Comment               = @event.Comment,
                Units                 = @event.Units,
                AveragePrice          = @event.AveragePrice,
                TransactionCosts      = @event.TransactionCosts,
                CreateCashTransaction = @event.CreateCashTransaction
            };

            var handler = _TransactionHandlers.GetService <Disposal>();

            handler.Apply(disposal, holding, _CashAccount);
            _Transactions.Add(disposal);
        }
コード例 #15
0
ファイル: Connection.cs プロジェクト: snickroger/Totem
        //
        // Open
        //

        public IDisposable Connect(CancellationToken cancellationToken = default(CancellationToken))
        {
            State.OnConnecting(cancellationToken);

            TryOpen();

            return(Disposal.Of(Disconnect));
        }
コード例 #16
0
ファイル: Selection.cs プロジェクト: CASMPostol/SmartFactory
 internal SelectionTableRowWraper(Disposal _dspslx)
 {
     InitializeDisposal(_dspslx.Disposal2IPRIndex);
     Disposal = true;
     Quantity = _dspslx.SettledQuantity.Value;
     Status   = _dspslx.DisposalStatus.Value.ToString();
     Created  = _dspslx.Created.Value;
     ID       = (-_dspslx.Id.Value).ToString();
 }
コード例 #17
0
 private static void RemoveDisposalFromClearance(Entities edc, Disposal dspsl)
 {
     dspsl.Disposal2ClearenceIndex = null;
     if (dspsl.DisposalStatus.Value == DisposalStatus.Tobacco)
     {
         dspsl.Disposal2IPRIndex.RevertWithdraw(dspsl.SettledQuantity.Value);
         edc.Disposal.DeleteOnSubmit(dspsl);
     }
 }
コード例 #18
0
 private void cboReasons_EditValueChanged(object sender, EventArgs e)
 {
     if (cboStores.EditValue != null && cboReasons.EditValue != null)
     {
         var adj = new Disposal();
         dtRec = adj.GetTransactionByReason(Convert.ToInt32(cboStores.EditValue), Convert.ToInt32(cboReasons.EditValue));
         //PopulateDocuments(dtRec);
         gridAdjustments.DataSource = dtRec;
     }
 }
コード例 #19
0
 /// <summary>
 /// Create LRU cache
 /// </summary>
 /// <param name='measure'>
 /// Resource measurement delegate applied to each element
 /// </param>
 /// <param name='maxresource'>
 /// Maximum resource utilization allowed, after which will trim back on an LRU basis
 /// </param>
 public LRUCache(
     ResourceUsage <T> measure,
     long maxresource,
     Disposal <T> disposal = null)
 {
     _measure     = measure;
     _maxresource = maxresource;
     _disposal    = disposal;
     _mru         = new LinkedQueue <Pair <K, T> > ();;
 }
コード例 #20
0
        private bool Disposal2ClearenceIndexIsNull(Disposal dspsl)
        {
            bool _ret = true;

            try
            {
                _ret = !(dspsl.Disposal2ClearenceIndex != null && dspsl.Disposal2ClearenceIndex.Id.HasValue);
            }
            catch (Exception) { }
            return(_ret);
        }
コード例 #21
0
 public void ShowObject(object keyValue)
 {
     _disposal = (Disposal)keyValue;
     _asset    = _context.Assets.FirstOrDefault(a => a.AssetId == _disposal.AssetId);
     if (_disposal.DisposalId != 0)//if the user needs to see the disposal information.
     {
         btnSave.Enabled = false;
     }
     disposalBindingSource.DataSource     = _disposal;
     disposalTypeBindingSource.DataSource =
         _context.LookupItems.Where(li => li.LookupId == (int)LookupItems.DisposalType);
 }
        /// <summary>
        ///     Create a <see cref="LspConnection"/> that uses the client ends of the the test's <see cref="PipeServerProcess"/> streams.
        /// </summary>
        /// <returns>
        ///     The <see cref="LspConnection"/>.
        /// </returns>
        protected async Task <LspConnection> CreateClientConnection()
        {
            if (!_serverProcess.IsRunning)
            {
                await StartServer();
            }

            await _serverProcess.HasStarted;

            LspConnection connection = new LspConnection(LoggerFactory, input: ServerOutputStream, output: ServerInputStream);

            Disposal.Add(connection);

            return(connection);
        }
コード例 #23
0
        private void EditLossAndAdjustment_Load(object sender, EventArgs e)
        {
            dtRecDate.Value        = DateTime.Now;
            dtRecDate.CustomFormat = "MM/dd/yyyy";
            var dis = new Disposal();

            if (_refno != null)
            {
                dis.GetTransactionByRefNo(_refno);
                txtRefNo.Text = dis.RefNo;
                DateTime dtDate = Convert.ToDateTime(dis.Date.ToString("MM/dd/yyyy"));
                txtDate.Text = dtDate.ToShortDateString();
                // dtLossDate.Value = dis.Date;
            }
        }
コード例 #24
0
        private void dtTo_ValueChanged(object sender, EventArgs e)
        {
            //CALENDAR:
            Disposal  adj = new Disposal();
            DataTable dtRec;

            dtFrom.CustomFormat = "MM/dd/yyyy";
            dtTo.CustomFormat   = "MM/dd/yyyy";
            DateTime dteFrom = ConvertDate.DateConverter(dtFrom.Text);
            DateTime dteTo   = ConvertDate.DateConverter(dtTo.Text);

            dtRec = dteFrom < dteTo?adj.GetTransactionByDateRange(Convert.ToInt32(cboStores.EditValue), dteFrom, dteTo) : adj.GetAllTransaction(Convert.ToInt32(cboStores.EditValue));

            gridAdjustments.DataSource = dtRec;
        }
コード例 #25
0
        public void DisposeOfParcelPartialSale()
        {
            var mockRepository = new MockRepository(MockBehavior.Strict);

            var stock = new Stock(Guid.NewGuid());

            stock.List("ABC", "ABC Pty Ltd", new Date(1974, 01, 01), false, AssetCategory.AustralianStocks);

            var          eventSink = mockRepository.Create <ICgtEventSink>();
            CgtEventArgs cgtEvent  = null;

            eventSink.Setup(x => x.OnCgtEventOccured(It.IsAny <Holding>(), It.IsAny <CgtEventArgs>()))
            .Callback <object, CgtEventArgs>((o, e) => cgtEvent = e)
            .Verifiable();

            var holding = new Holding(stock, new Date(2000, 01, 01));

            holding.CgtEventOccurred += eventSink.Object.OnCgtEventOccured;

            var parcel = holding.AddParcel(new Date(2000, 01, 01), new Date(2000, 01, 01), 100, 1000.00m, 1200.00m, null);

            holding.AddParcel(new Date(2000, 01, 01), new Date(2000, 01, 01), 200, 2000.00m, 2200.00m, null);

            var transaction = new Disposal();

            holding.DisposeOfParcel(parcel.Id, new Date(2001, 01, 01), 99, 500.00m, 10.00m, CgtMethod.Discount, transaction);

            using (new AssertionScope())
            {
                holding[new Date(2000, 12, 31)].Should().Be(new HoldingProperties(300, 3000.00m, 3400.00m));
                holding[new Date(2001, 01, 01)].Should().Be(new HoldingProperties(201, 2010.00m, 2212.00m));

                parcel.Properties[new Date(2000, 12, 31)].Should().Be(new ParcelProperties(100, 1000.00m, 1200.00m));
                parcel.Properties[new Date(2001, 01, 01)].Should().Be(new ParcelProperties(1, 10.00m, 12.00m));

                cgtEvent.Should().BeEquivalentTo(new
                {
                    EventDate      = new Date(2001, 01, 01),
                    Stock          = stock,
                    AmountReceived = 500.00m,
                    CapitalGain    = 10.00m,
                    CgtMethod      = CgtMethod.Discount,
                    Transaction    = transaction
                });
            }

            mockRepository.Verify();
        }
コード例 #26
0
        public void DisposeOfShares()
        {
            var mockRepository = new MockRepository(MockBehavior.Strict);

            var stock = new Stock(Guid.NewGuid());

            stock.List("ABC", "ABC Pty Ltd", new Date(1974, 01, 01), false, AssetCategory.AustralianStocks);

            var stockResolver = mockRepository.Create <IStockResolver>();

            stockResolver.Setup(x => x.GetStock(stock.Id)).Returns(stock);

            var      handler     = mockRepository.Create <ITransactionHandler>();
            Disposal transaction = null;

            handler.Setup(x => x.Apply(It.IsAny <IPortfolioTransaction>(), It.IsAny <IHolding>(), It.IsAny <ICashAccount>()))
            .Callback <IPortfolioTransaction, IHolding, ICashAccount>((t, h, c) => transaction = (Disposal)t)
            .Verifiable();

            var transactionHandlers = mockRepository.Create <IServiceFactory <ITransactionHandler> >();

            transactionHandlers.Setup(x => x.GetService <Disposal>()).Returns(handler.Object);
            transactionHandlers.Setup(x => x.GetService <OpeningBalance>()).Returns(new OpeningBalanceHandler());

            var portfolio = new Portfolio(Guid.NewGuid(), stockResolver.Object, transactionHandlers.Object);

            portfolio.AddOpeningBalance(stock.Id, new Date(1999, 01, 01), new Date(1999, 01, 01), 100, 100.00m, "", Guid.Empty);

            var transactionId = Guid.NewGuid();

            portfolio.DisposeOfShares(stock.Id, new Date(2000, 01, 01), 100, 10.00m, 19.95m, CgtCalculationMethod.MinimizeGain, true, "Comment", transactionId);

            transaction.Should().BeEquivalentTo(new
            {
                Id                    = transaction.Id,
                Date                  = new Date(2000, 01, 01),
                Stock                 = stock,
                Comment               = "Comment",
                Units                 = 100,
                AveragePrice          = 10.00m,
                TransactionCosts      = 19.95m,
                CreateCashTransaction = true,
                CgtMethod             = CgtCalculationMethod.MinimizeGain
            });

            mockRepository.Verify();
        }
コード例 #27
0
        public void SingleParcelPartiallySold()
        {
            var stock = new Stock(Guid.NewGuid());

            stock.List("ABC", "ABC Pty Ltd", new Date(1974, 01, 01), false, AssetCategory.AustralianStocks);

            var transaction = new Disposal()
            {
                Id                    = Guid.NewGuid(),
                Date                  = new Date(2020, 02, 01),
                Stock                 = stock,
                Comment               = "Test Disposal",
                Units                 = 100,
                AveragePrice          = 20.00m,
                TransactionCosts      = 19.95m,
                CgtMethod             = CgtCalculationMethod.FirstInFirstOut,
                CreateCashTransaction = true
            };

            var mockRepository = new MockRepository(MockBehavior.Strict);

            var parcelId = Guid.NewGuid();
            var parcel   = mockRepository.Create <IParcel>();

            parcel.Setup(x => x.Id).Returns(parcelId);
            parcel.Setup(x => x.EffectivePeriod).Returns(new DateRange(new Date(2007, 01, 01), Date.MaxValue));
            parcel.Setup(x => x.AquisitionDate).Returns(new Date(2007, 01, 01));
            parcel.Setup(x => x.Properties[new Date(2020, 02, 01)]).Returns(new ParcelProperties(200, 1000.00m, 1500.00m));

            var holding = mockRepository.Create <IHolding>();

            holding.Setup(x => x.IsEffectiveAt(new Date(2020, 02, 01))).Returns(true);
            holding.Setup(x => x.Properties[new Date(2020, 02, 01)]).Returns(new HoldingProperties(200, 1000.00m, 1000.00m));
            holding.Setup(x => x.Parcels(new Date(2020, 02, 01))).Returns(new IParcel[] { parcel.Object });
            holding.Setup(x => x.DisposeOfParcel(parcelId, new Date(2020, 02, 01), 100, 1980.05m, 1230.05m, CgtMethod.Discount, transaction)).Verifiable();

            var cashAccount = mockRepository.Create <ICashAccount>();

            cashAccount.Setup(x => x.Transfer(new Date(2020, 02, 01), 2000.00m, "Sale of ABC")).Verifiable();
            cashAccount.Setup(x => x.FeeDeducted(new Date(2020, 02, 01), 19.95m, "Brokerage for sale of ABC")).Verifiable();

            var handler = new DisposalHandler();

            handler.Apply(transaction, holding.Object, cashAccount.Object);

            mockRepository.Verify();
        }
コード例 #28
0
 /// <summary>
 ///     Dispose of resources being used by the test suite.
 /// </summary>
 /// <param name="disposing">
 ///     Explicit disposal?
 /// </param>
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         try
         {
             Disposal.Dispose();
         }
         finally
         {
             if (Log is IDisposable logDisposal)
             {
                 logDisposal.Dispose();
             }
         }
     }
 }
コード例 #29
0
            /// <summary>
            ///     Create a new <see cref="WebSocketTestBase"/>.
            /// </summary>
            /// <param name="testOutput">
            ///     Output for the current test.
            /// </param>
            protected WebSocketTestBase(ITestOutputHelper testOutput)
                : base(testOutput)
            {
                int port = Interlocked.Increment(ref NextPort);

                BaseAddress = new Uri($"http://localhost:{port}");
                WebSocketBaseAddress = new Uri($"ws://localhost:{port}");

                Host = WebHost.CreateDefaultBuilder()
                    .UseStartup<Startup>()
                    .ConfigureServices(ConfigureTestServerServices)
                    .ConfigureLogging(ConfigureTestServerLogging)
                    .UseUrls(BaseAddress.AbsoluteUri)
                    .Build();

                Disposal.Add(Host);
            }
コード例 #30
0
 /// <summary>
 /// Dispose of resources being used by the test suite.
 /// </summary>
 /// <param name="disposing">
 /// Explicit disposal?
 /// </param>
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         try
         {
             Disposal.Dispose();
         }
         finally
         {
             // ReSharper disable once SuspiciousTypeConversion.Global
             if (Log is IDisposable logDisposal)
             {
                 logDisposal.Dispose();
             }
         }
     }
 }
コード例 #31
0
ファイル: ExtendedSource.cs プロジェクト: Zoumaho/Backload
 internal MethodProfiler(TraceSource source, params object[] data)
 {
     source.TraceData(TraceEventType.Start, 0, data);
     _disposal = delegate() { source.TraceData(TraceEventType.Stop, 0, data); };
 }
コード例 #32
0
ファイル: GD.cs プロジェクト: zer0x304/gd-sharp
 public void GifAnimAdd(Stream sout, int localCm, int leftOfs, int topOfs, int delay, Disposal disposal, GD previm)
 {
     int size;
     IntPtr prevhandle = previm == null ? IntPtr.Zero : previm.handle.Handle;
     using (GDIntPtr rawdata = GDImport.gdImageGifAnimAddPtr(this.Handle, out size, localCm, leftOfs, topOfs, delay, (int)disposal, prevhandle))
     {
         if( rawdata .IsNull )
             throw new ApplicationException( "Function GifAnimAdd failed" );
         byte[] data = new byte[size];
         Marshal.Copy(rawdata, data, 0, size);
         sout.Write(data, 0, size);
     }
 }
コード例 #33
0
ファイル: ExtendedSource.cs プロジェクト: Zoumaho/Backload
 internal MethodProfiler(TraceSource source, string message)
 {
     source.TraceEvent(TraceEventType.Start, 0, message);
     _disposal = delegate() { source.TraceEvent(TraceEventType.Stop, 0, message); };
 }
コード例 #34
0
ファイル: ExtendedSource.cs プロジェクト: Zoumaho/Backload
 internal MethodProfiler(TraceSource source, string format, params object[] args)
 {
     source.TraceEvent(TraceEventType.Start, 0, format, args);
     _disposal = delegate() { source.TraceEvent(TraceEventType.Stop, 0, format, args); };
 }