public void ChangeUnionMember() { int empId = 9; AddHourlyEmployee t = new AddHourlyEmployee(empId, "Bill", "Home", 15.25, database); t.Execute(); int memberId = 7743; ChangeMemberTransaction cmt = new ChangeMemberTransaction(empId, memberId, 99.42, database); cmt.Execute(); Employee e = database.GetEmployee(empId); Assert.IsNotNull(e); Affiliation affiliation = e.Affiliation; Assert.IsNotNull(affiliation); Assert.IsTrue(affiliation is UnionAffiliation); UnionAffiliation uf = affiliation as UnionAffiliation; Assert.AreEqual(99.42, uf.Dues, .001); Employee member = database.GetUnionMember(memberId); Assert.IsNotNull(member); Assert.AreEqual(e, member); }
public void ChangeUnaffiliatedMember() { var empId = 10; var t = new AddHourlyEmployee(empId, "Bill", "Home", 15.25, database); t.Execute(); var memberId = 7743; new ChangeMemberTransaction(empId, memberId, 99.42, database).Execute(); var cut = new ChangeUnaffiliatedTransaction(empId, database); cut.Execute(); var e = database.GetEmployee(empId); Assert.IsNotNull(e); var affiliation = e.Affiliation; Assert.IsNotNull(affiliation); Assert.IsTrue(affiliation is NoAffiliation); var member = database.GetUnionMember(memberId); Assert.IsNull(member); }
public void Execute() { Employee e = PayrollDatabase.GetUnionMember(memberId); if (e != null) { UnionAffiliation ua = null; if (e.Affiliation is UnionAffiliation affiliation) { ua = affiliation; } if (ua != null) { ua.AddServiceCharge(new ServiceCharge(time, charge)); } else { throw new InvalidOperationException( "Tries to add service charge to union member " + "without a union affiliation"); } } else { throw new InvalidOperationException("No such union member."); } }