Exemplo n.º 1
0
        public void ExportCryptos()
        {
            var crypto = new OwnedCrypto("btc", Guid.NewGuid());

            crypto.Purchase(quantity: 1.2m, dollarAmountSpent: 200, date: DateTimeOffset.UtcNow);
            crypto.Sell(quantity: 0.2m, dollarAmountReceived: 100, date: DateTimeOffset.UtcNow);

            var report = CSVExport.Generate(new[] { crypto });

            Assert.Contains(CSVExport.CRYPTOS_HEADER, report);
            Assert.Contains("BTC", report);
            Assert.Contains("buy", report);
            Assert.Contains("sell", report);
        }
Exemplo n.º 2
0
        public void Btc_EndToEnd()
        {
            var btc = new OwnedCrypto(
                new Token("BTC"), System.Guid.NewGuid()
                );

            btc.Purchase(
                quantity: 0.05437703m,
                dollarAmountSpent: 985.32m,
                date: System.DateTimeOffset.Parse("2017-12-19T15:05:38Z")
                );

            Assert.Equal(0.05437703m, btc.State.Quantity);
            Assert.Equal(985.32m, btc.State.Cost);

            btc.Sell(0.004m, dollarAmountReceived: 74, DateTimeOffset.UtcNow, notes: null);

            Assert.Equal(0.05037703m, btc.State.Quantity);

            Assert.Equal(2, btc.State.Transactions.Count);
            Assert.Single(btc.State.PositionInstances);
        }