public void When_Transaction_Missing_Security_Then_Transaction_Is_Not_Valid()
        {
            var transaction = new Transaction
            {
                Account = new Account { Name = "blah"},
                Date = DateTime.UtcNow,
                Price = 0M,
                Security = null,
                Shares = 10M,
                Type = TransactionType.Buy
            };

            Assert.That(transaction.Valid(), Is.False);
        }
        public void When_Transaction_Missing_Date_Then_Transaction_Is_Not_Valid()
        {
            var transaction = new Transaction
            {
                Account = new Account { Name = "blah" },
                Date = default(DateTime),
                Price = 0M,
                Security = new Security { Symbol = "goog" },
                Shares = 10M,
                Type = TransactionType.Buy
            };

            Assert.That(transaction.Valid(), Is.False);
        }
        public void When_Transaction_Missing_Account_Then_Transaction_Is_Not_Valid()
        {
            var transaction = new Transaction
            {
                Account = null,
                Date = DateTime.UtcNow,
                Price = 0M,
                Security = new Security { Symbol = "goog" },
                Shares = 10M,
                Type = TransactionType.Buy
            };

            Assert.That(transaction.Valid(), Is.False);
        }
        public void When_Transaction_Has_Complete_Data_Then_Transaction_Is_Valid()
        {
            var transaction = new Transaction
            {
                Account = new Account { Name = "blah" },
                Date = DateTime.UtcNow,
                Price = 0M,
                Security = new Security { Symbol = "goog" },
                Shares = 10M,
                Type = TransactionType.Buy
            };

            Assert.That(transaction.Valid(), Is.True);
        }
        public IEnumerable<Transaction> GetTransactions()
        {
            var transactions = new List<Transaction>();

            while (_csvReader.ReadNextRecord())
            {
                Transaction transaction;
                if (_csvReader.HasHeaders)
                {
                    transaction = new Transaction
                    {
                        Security = new Security { Symbol = _csvReader["Symbol"] },
                        Date = DateTime.Parse(_csvReader["Date"], CultureInfo.CreateSpecificCulture("en-CA")),
                        Price = Decimal.Parse(_csvReader["Price"]),
                        Shares = Decimal.Parse(_csvReader["Shares"]),
                        Type = TransactionType.Buy
                    };
                }
                else
                {
                    transaction = new Transaction
                    {
                        Security = new Security { Symbol = _csvReader[0] },
                        Date = DateTime.Parse(_csvReader[1], CultureInfo.CreateSpecificCulture("en-CA")),
                        Price = Decimal.Parse(_csvReader[3]),
                        Shares = Decimal.Parse(_csvReader[2]),
                        Type = TransactionType.Buy
                    };
                }
                transactions.Add(transaction);
            }

            return transactions;
        }
        public void When_Transaction_With_Invalid_Shares_Then_Transaction_Is_Not_Valid(decimal shares)
        {
            var transaction = new Transaction
            {
                Account = new Account { Name = "blah" },
                Date = default(DateTime),
                Price = 0M,
                Security = new Security { Symbol = "goog" },
                Shares = shares,
                Type = TransactionType.Buy
            };

            Assert.That(transaction.Valid(), Is.False);
        }