Exemplo n.º 1
0
        public void IncomeRepository_GetById_Returns_Object_If_Found()
        {
            var testDataWithId = _baseTestData.Copy();

            testDataWithId.Id = 1;
            var mock = RepositoryMocks.GetMockIncomeRepository(new List <Income> {
                testDataWithId
            });

            var actual = mock.GetById(1);

            Assert.AreEqual(testDataWithId, actual);
        }
Exemplo n.º 2
0
        public void Income_Copy()
        {
            var first = new Income
            {
                Amount   = 120,
                Category = new IncomeCategory
                {
                    Id   = 0,
                    Name = "Category"
                },
                Comments = "Stuff",
                Date     = DateTime.Today,
                Id       = 0,
                Method   = new PaymentMethod
                {
                    Id   = 0,
                    Name = "Method"
                }
            };

            var second = first.Copy();

            Assert.AreNotSame(first, second);
            Assert.IsTrue(first.Equals(second));
            Assert.IsTrue(second.Equals(first));
        }
Exemplo n.º 3
0
        public void Income_Copy()
        {
            var first = new Income
            {
                Amount = 120,
                Category = new IncomeCategory
                {
                    Id = 0,
                    Name = "Category"
                },
                Comments = "Stuff",
                Date = DateTime.Today,
                Id = 0,
                Method = new PaymentMethod
                {
                    Id = 0,
                    Name = "Method"
                }
            };

            var second = first.Copy();

            Assert.AreNotSame(first, second);
            Assert.IsTrue(first.Equals(second));
            Assert.IsTrue(second.Equals(first));
        }
Exemplo n.º 4
0
        public void MonthService_GetIncomesForMonth_No_Matching_Data_Returns_Empty_List()
        {
            var data = Enumerable.Range(1, 5)
                       .Select(i =>
            {
                var c    = incomeBaseTestData.Copy();
                c.Id     = i;
                c.Date   = new DateTime(2015, 3, 3);
                c.Amount = (decimal)Math.Pow(i, i);
                return(c);
            })
                       .ToList();
            var mock = ServiceMocks.GetMockMonthService(incomeData: data);

            var actual = mock.GetIncomesForMonth(new DateTime(2010, 1, 1));

            CollectionAssert.AreEquivalent(new List <Income>(), actual.ToList());
        }
Exemplo n.º 5
0
        /// <summary>
        ///     Sets the intial state and current state expense properties of the form
        /// </summary>
        /// <param name="income">The income the form was opened for</param>
        public IncomeViewer(Income income)
        {
            InitializeComponent();

            currentIncome  = income;
            originalIncome = currentIncome.Copy();

            _dataContext           = new AccountingDataContext();
            _incomeService         = new IncomeService(new IncomeRepository(_dataContext));
            _incomeCategoryService = new IncomeCategoryService(new IncomeCategoryRepository(_dataContext));
            _paymentMethodService  = new PaymentMethodService(new PaymentMethodRepository(_dataContext));
        }
Exemplo n.º 6
0
        /// <summary>
        ///     Cancels the edit and leaves the form open
        ///     -clears any changes made
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnCancel_Click(object sender, EventArgs e)
        {
            // Enables the controls for editing and updates which buttons are visible
            ToggleEnableControls(txtAmount, txtDetail, cmbCategory,
                                 cmbPayment, dtPick, btnSave, btnEdit, btnCancel, btnDelete);
            ToggleVisibility(btnSave, btnCancel, btnEdit, btnDelete);

            // Makes sure that the expense of the binding has the origional values
            currentIncome = originalIncome.Copy();

            // Resets the data bindings
            SetDataBindings();
        }
Exemplo n.º 7
0
        public void IncomeService_GetAll_Returns_Data()
        {
            var data = Enumerable.Range(1, 5)
                       .Select(i => { var c = _baseTestData.Copy(); c.Id = i; c.Amount = (decimal)Math.Pow(i, i); return(c); })
                       .ToList();
            var mock = ServiceMocks.GetMockIncomeService(data);

            var actual = mock.LoadAll();

            CollectionAssert.AreEquivalent(data, actual.ToList());
        }