Пример #1
0
        private Employee AddRandomEmployee()
        {
            Employee employee =
                new Employee()
                {
                    Alias = this._random.Next().ToString(),
                    Manager = this._random.Next().ToString(),
                    Name = this._random.Next().ToString(),
                };

            ExpenseService service = new ExpenseService();
            service.SaveEmployee(employee);
            return employee;
        }
Пример #2
0
        private Charge AddRandomCharge(int employeeId)
        {
            Charge charge =
                new Charge()
                {
                    AccountNumber = this._random.Next(),
                    BilledAmount = this._random.Next(1000),
                    Category = this._random.Next(),
                    Description = this._random.Next().ToString(),
                    EmployeeId = employeeId,
                    ExpenseDate = DateTime.Today,
                    ExpenseType = this._random.Next(),
                    Location = this._random.Next().ToString(),
                    Merchant = this._random.Next().ToString(),
                    Notes = this._random.Next().ToString(),
                    ReceiptRequired = false,
                    TransactionAmount = this._random.Next(1000),
                };

            ExpenseService service = new ExpenseService();
            service.SaveCharge(charge);
            return charge;
        }
Пример #3
0
        public void Create_Employee()
        {
            string alias = "rogreen";

            Employee employee =
                new Employee()
                {
                    Alias = alias,
                    Manager = "notrogreen",
                    Name = "Robert Green",
                };

            ExpenseService service = new ExpenseService();

            int employeeId = service.SaveEmployee(employee);
            Assert.AreNotEqual(0, employeeId);
            Assert.AreEqual(employeeId, employee.EmployeeId);

            Employee dbData = service.GetEmployee(alias);
            Assert.AreEqual(alias, dbData.Alias);

            alias = "rogreen2";
            employee.Alias = alias;
            service.SaveEmployee(employee);

            dbData = service.GetEmployee(alias);
            Assert.AreEqual(alias, dbData.Alias);
        }
Пример #4
0
        public void Create_Employee_WithDefaultData()
        {
            string alias = "rogreen";
            ExpenseService service = new ExpenseService();
            Employee employee = service.GetEmployee(alias);

            Assert.IsNotNull(employee);
            Assert.AreEqual(alias, employee.Alias);
            Assert.AreNotEqual(0, service.GetCharges(employee.EmployeeId));
            Assert.AreNotEqual(0, service.GetExpenseReports(employee.EmployeeId));
        }
Пример #5
0
 public void Create_Employee_WithDuplicateAlias()
 {
     Employee employee = this.AddRandomEmployee();
     employee.EmployeeId = 0;
     ExpenseService service = new ExpenseService();
     service.SaveEmployee(employee);
 }
Пример #6
0
        public void Create_ExpenseReport()
        {
            Employee employee = this.AddRandomEmployee();
            Charge charge1 = this.AddRandomCharge(employee.EmployeeId);
            Charge charge2 = this.AddRandomCharge(employee.EmployeeId);
            Charge charge3 = this.AddRandomCharge(employee.EmployeeId);

            ExpenseReport expenseReport =
                new ExpenseReport()
                {
                    Amount = 1,
                    Approver = "2",
                    CostCenter = 3,
                    EmployeeId = employee.EmployeeId,
                    Notes = "4",
                    Purpose = "5",
                    Status = 6,                    
                };

            ExpenseService service = new ExpenseService();
            service.SaveExpenseReport(expenseReport);
            Assert.AreNotEqual(0, expenseReport.ExpenseReportId);

            charge1.ExpenseReportId = expenseReport.ExpenseReportId;
            service.SaveCharge(charge1);
            charge2.ExpenseReportId = expenseReport.ExpenseReportId;
            service.SaveCharge(charge2);
            charge3.ExpenseReportId = expenseReport.ExpenseReportId;
            service.SaveCharge(charge3);

            List<Charge> charges = service.GetCharges(expenseReport.ExpenseReportId);
            Assert.AreEqual(3, charges.Count);
            Assert.AreEqual(charge1.ChargeId, charges[0].ChargeId);
            Assert.AreEqual(charge2.ChargeId, charges[1].ChargeId);
            Assert.AreEqual(charge3.ChargeId, charges[2].ChargeId);
        }
Пример #7
0
        public void Create_Charge()
        {
            Employee employee = this.AddRandomEmployee();

            Charge charge =
                new Charge()
                {
                    AccountNumber = 0,
                    BilledAmount = 1,
                    Category = 2,
                    Description = "3",
                    EmployeeId = employee.EmployeeId,
                    ExpenseDate = new DateTime(2013, 9, 28),
                    ExpenseType = (int) ChargeType.Business,
                    Location = "4",
                    Merchant = "5",
                    Notes = "6",
                    ReceiptRequired = true,
                    TransactionAmount = 7,
                };

            ExpenseService service = new ExpenseService();

            int chargeId = service.SaveCharge(charge);

            Assert.AreNotEqual(0, chargeId);
            Assert.AreEqual(chargeId, charge.ChargeId);
        }