Example #1
0
        public void ChangeUnaffiliatedMember()
        {
            int empId           = 10;
            AddHourlyEmployee t =
                new AddHourlyEmployee(empId, "Bill", "Home", 15.25, database);

            t.Execute();
            int memberId = 7743;

            new ChangeMemberTransaction(empId, memberId, 99.42, database).Execute();
            ChangeUnaffiliatedTransaction cut =
                new ChangeUnaffiliatedTransaction(empId, database);

            cut.Execute();
            Employee e = database.GetEmployee(empId);

            Assert.IsNotNull(e);
            Affiliation affiliation = e.Affiliation;

            Assert.IsNotNull(affiliation);
            Assert.IsTrue(affiliation is NoAffiliation);
            Employee member = database.GetUnionMember(memberId);

            Assert.IsNull(member);
        }
Example #2
0
        public void ChangeUnaffiliatedTransaction()
        {
            var empId = SetupHourlyEmployee();
            // Make sure the employee is union affiliated
            const int memberId = 7743;
            var       cmt      = new ChangeMemberTransaction(empId, memberId, 99.42);

            cmt.Execute();

            var cut = new ChangeUnaffiliatedTransaction(empId);

            cut.Execute();

            Employee e = PayrollDatabase.GetEmployee(empId);

            Assert.NotNull(e);

            Affiliation affiliation = e.Affiliation;

            Assert.NotNull(affiliation);

            Assert.IsType <NoAffiliation>(affiliation);
            Employee member = PayrollDatabase.GetUnionMember(memberId);

            Assert.Null(member);
        }
        public void RemoveMembership()
        {
            int empId           = 8;
            AddHourlyEmployee t = new AddHourlyEmployee(empId, "Bill", "Home", 15.25);

            t.Execute();

            int memberId = 7743; // Some Union
            ChangeMemberTransaction cmt = new ChangeMemberTransaction(empId, memberId, 99.42);

            cmt.Execute();

            ChangeUnaffiliatedTransaction cut = new ChangeUnaffiliatedTransaction(empId);

            cut.Execute();

            Employee e = PayrollDatabase.GetEmployee(empId);

            Assert.IsNotNull(e);

            Affiliation affiliation = e.Affiliation;

            Assert.IsNotNull(affiliation);
            Assert.IsTrue(affiliation is NoAffiliation);

            Employee member = PayrollDatabase.GetUnionMember(memberId);

            Assert.IsNull(member);
        }
Example #4
0
        public void TestUnaffiliatedTransaction()
        {
            int empId    = 2;
            int memberId = 7734;

            var addTx = new AddHourlyEmployee(empId, "Bill", "Home", 15.25M);

            addTx.Execute();
            var changeMemberTx = new ChangeMemberTransaction(empId, memberId, 99.42M);

            changeMemberTx.Execute();


            var changeUnaffiliatedTx = new ChangeUnaffiliatedTransaction(empId);

            changeUnaffiliatedTx.Execute();

            var employee = Database.GetEmployee(empId);

            Assert.IsNotNull(employee, "Employee not found");

            var affiliation = employee.Affiliation;

            Assert.IsInstanceOfType(affiliation, typeof(NoAffiliation), "Has a union affiliation");

            var member = Database.GetUnionMember(memberId);

            Assert.IsNull(member, "Membership was not removed from database");
        }
        public void ChangeUnaffiliatedTransaction()
        {
            int employeeId           = 19;
            AddEmployTransaction aet = new AddHourlyEmployee(employeeId, "Bill", "home", 19.1);

            aet.Execute();
            int memberId = 8592;
            ChangeMemberTransaction cmt = new ChangeMemberTransaction(employeeId, memberId, 99.42);

            cmt.Execute();
            Employee um = PayrollRepository.GetUnionMember(memberId);

            um.Should().NotBeNull();
            ChangeUnaffiliatedTransaction cut = new ChangeUnaffiliatedTransaction(employeeId);

            cut.Execute();

            Employee e = PayrollRepository.GetEmployee(employeeId);

            e.Should().NotBeNull();
            e.Affiliation.Should().NotBeNull();
            e.Affiliation.Should().BeOfType <NoAffiliaction>();

            Employee member = PayrollRepository.GetUnionMember(memberId);

            member.Should().BeNull();
        }
        public void RemoveUnionMember()
        {
            database.AddEmployee(employee);

            int memberId = 7783;
            ChangeMemberTransaction cmt = new ChangeMemberTransaction(employee.EmpId, memberId, 99.42, database);

            cmt.Execute();

            ChangeUnaffiliatedTransaction cut = new ChangeUnaffiliatedTransaction(employee.EmpId, database);

            cut.Execute();

            var unionMember = database.GetUnionMember(memberId);

            Assert.IsNull(unionMember);
        }
Example #7
0
        public void TestChangeUnaffiliatedTransaction()
        {
            int empId           = 10;
            AddHourlyEmployee t = new AddHourlyEmployee(empId, "Kubing", "Home", 25.32, database);

            t.Execute();

            int memberId = 7783;
            ChangeMemberTransaction cmt = new ChangeMemberTransaction(empId, memberId, 99.42, database);

            cmt.Execute();

            ChangeUnaffiliatedTransaction cut = new ChangeUnaffiliatedTransaction(empId, database);

            cut.Execute();

            Employee    e           = database.GetEmployee(empId);
            Affiliation affiliation = e.Affiliation;

            Assert.IsNotNull(e);
            Assert.IsNotNull(affiliation);
            Assert.IsTrue(affiliation is NoAffiliation);
        }
Example #8
0
        public void ExecuteTest()
        {
            int    empId    = 33;
            int    memberId = 98;
            double dues     = 98.9;

            database.DeleteEmployee(empId);
            database.RemoveUnionMember(memberId);

            AddSalariedEmployee addSalEmp = new AddSalariedEmployee(empId, "Masa", "Faav Street", 5000, database);

            addSalEmp.Execute();
            ChangeAffiliationTransaction changeMemberTrans = new ChangeMemberTransaction(empId, memberId, dues, database);

            changeMemberTrans.Execute();
            Employee empAff = database.GetEmployee(empId);

            Assert.IsNotNull(empAff);
            Assert.IsTrue(empAff.Affiliation is UnionAffiliation);


            ChangeAffiliationTransaction changeAffTrans = new ChangeUnaffiliatedTransaction(empId, database);

            changeAffTrans.Execute();
            Employee empNoAff = database.GetEmployee(empId);

            Assert.IsNotNull(empNoAff);
            Assert.IsTrue(empNoAff.Affiliation is NoAffiliation);
            NoAffiliation ua = empNoAff.Affiliation as NoAffiliation;

            Assert.IsNotNull(ua);

            Employee member = database.GetUnionMember(memberId);

            Assert.IsNull(member);
        }