Exemplo n.º 1
0
        public void Test_Expenses_CreditCardStatementFileTests_CreateItem()
        {
            try
            {
                using (var db = new Context())
                {
                    db.Database.EnsureCreated();

                    var owner = Factories.NewAccount("mr bean");
                    db.Accounts.Add(owner);
                    db.SaveChanges();

                    var card = new Financier.Common.Expenses.Models.Card
                    {
                        Owner      = owner,
                        Id         = Guid.NewGuid(),
                        Number     = "1234",
                        Statements = new List <Statement>()
                    };
                    db.Cards.Add(card);
                    db.SaveChanges();

                    var newStatement = new Statement
                    {
                        Card     = card,
                        Id       = Guid.NewGuid(),
                        PostedAt = new DateTime(2019, 2, 1),
                        Items    = new List <Item>()
                    };
                    db.Statements.Add(newStatement);
                    db.SaveChanges();

                    var record = new CreditCardStatementRecord
                    {
                        Amount       = "10.00",
                        Number       = "1234",
                        Description  = "Some new item",
                        ItemId       = "123",
                        PostedAt     = "20181103",
                        TransactedAt = "20181104"
                    };
                    record.CreateItem(newStatement.Id);

                    var dbItem = db.Items.First(i => i.Amount == 10.00M);
                    Assert.That(dbItem.Statement, Is.EqualTo(newStatement));
                }
            }
            catch (Exception exception)
            {
                Assert.Fail(exception.StackTrace);
                Assert.Fail(exception.Message);
            }
        }
Exemplo n.º 2
0
        public void Test_Expenses_CreditCardStatementFileTests_SaveCard()
        {
            using (var db = new Context())
            {
                db.Database.EnsureCreated();

                var mrBean = Factories.NewAccount("mrbean");
                db.Accounts.Add(mrBean);

                var card = new Financier.Common.Expenses.Models.Card
                {
                    Owner      = mrBean,
                    Id         = Guid.NewGuid(),
                    Number     = "1234",
                    Statements = new List <Statement>()
                };
                db.Cards.Add(card);
                db.SaveChanges();

                {
                    var newStatement = new Statement
                    {
                        Card     = card,
                        Id       = Guid.NewGuid(),
                        PostedAt = new DateTime(2019, 2, 1),
                        Items    = new List <Item>()
                    };
                    db.Statements.Add(newStatement);
                    db.SaveChanges();
                }

                {
                    var newStatement = new Statement
                    {
                        Card     = card,
                        Id       = Guid.NewGuid(),
                        PostedAt = new DateTime(2019, 2, 2),
                        Items    = new List <Item>()
                    };
                    db.Statements.Add(newStatement);
                    db.SaveChanges();
                }
            }
        }