Beispiel #1
0
        public async Task ChangeUnionMember()
        {
            int empId           = 9;
            AddHourlyEmployee t = new AddHourlyEmployee(empId, "Bill", "Home", 15.25);
            await t.ExecuteAsync();

            int memberId = 7743;
            ChangeMemberTransaction cmt = new ChangeMemberTransaction(empId, memberId, 99.42);
            await cmt.ExecuteAsync();

            Employee e = await PayrollDatabase.GetEmployeeAsync(empId);

            Assert.NotNull(e);
            IAffiliation affiliation = e.Affiliation;

            Assert.NotNull(affiliation);
            Assert.True(affiliation is UnionAffiliation);
            UnionAffiliation uf = affiliation as UnionAffiliation;

            Assert.Equal(99.42, uf.Dues);
            Employee member = await PayrollDatabase.GetUnionMemberAsync(memberId);

            Assert.NotNull(member);
            Assert.Equal(e, member);
        }
Beispiel #2
0
        protected override async Task ChangeAsync(Employee e)
        {
            await RecordMembershipAsync(e);

            IAffiliation affiliation = Affiliation;

            e.Affiliation = affiliation;
        }
Beispiel #3
0
        protected override Task RecordMembershipAsync(Employee e)
        {
            IAffiliation affiliation = e.Affiliation;

            if (!(affiliation is UnionAffiliation))
            {
                return(Task.CompletedTask);
            }

            UnionAffiliation unionAffiliation = affiliation as UnionAffiliation;
            int memeberId = unionAffiliation.MemberId;

            PayrollDatabase.RemoveUnionMember(memeberId);
            return(Task.CompletedTask);
        }
Beispiel #4
0
        public void ChangeUnionMemberTest()
        {
            AddHourlyEmployee he = new AddHourlyEmployee(base.EmpId, base.Name, base.Address, base.HourlyRate);

            he.Execute();
            int    memberId             = 7743;
            double dues                 = 99.42;
            ChangeMemberTransaction cmt = new ChangeMemberTransaction(base.EmpId, memberId, dues);

            cmt.Execute();
            Employee e = PayrollDatabase.GetEmployee(base.EmpId);

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

            Assert.IsNotNull(affiliation);
            Assert.IsTrue(affiliation is UnionAffiliation);
            UnionAffiliation uf = affiliation as UnionAffiliation;

            Assert.AreEqual(dues, uf.Dues, .001);
            Employee member = PayrollDatabase.GetUnionMember(memberId);

            Assert.AreEqual(e, member);
        }