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 TestChangeMemberTransaction() { int empId = 9; 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(); Employee e = database.GetEmployee(empId); Affiliation affiliation = e.Affiliation; Assert.IsNotNull(e); Assert.IsNotNull(affiliation); Assert.IsTrue(affiliation is UnionAffiliation); UnionAffiliation ua = e.Affiliation as UnionAffiliation; Assert.AreEqual(99.42, ua.Dues, 0.001); Employee member = database.GetUnionMember(memberId); Assert.IsNotNull(member); Assert.AreEqual(e, member); }
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 ChangeUnionMember() { int empId = SetupHourlyEmployee(); const int memberId = 7743; var cmt = new ChangeMemberTransaction(empId, memberId, 99.42); cmt.Execute(); Employee e = PayrollDatabase.GetEmployee(empId); Assert.NotNull(e); Affiliation affiliation = e.Affiliation; Assert.NotNull(affiliation); var uf = Assert.IsType <UnionAffiliation>(affiliation); Assert.Equal(99.42, uf.Dues); Employee member = PayrollDatabase.GetUnionMember(memberId); Assert.NotNull(member); Assert.Same(e, 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); }
public void Execute() { var e = PayrollDatabase.GetUnionMember(memberId); if (e != null) { UnionAffiliation ua = null; if (e.Affiliation is UnionAffiliation) { ua = e.Affiliation as UnionAffiliation; } if (ua != null) { ua.AddServiceCharge(new ServiceCharge(time, charge)); } else { throw new InvalidOperationException("Попытка добавить плату за услуги для члена профсоюза с незарегистрированным членством"); } } else { throw new InvalidOperationException("Член профсоюза не найден."); } }
public void ChangeUnionMember() { int empId = 8; AddHourlyEmployee t = new AddHourlyEmployee(empId, "Билл", "Домашний", 15.25); t.Execute(); int memberId = 7743; ChangeMemberTransaction cmt = new ChangeMemberTransaction(empId, memberId, 99.42); cmt.Execute(); Employee e = PayrollDatabase.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); Employee member = PayrollDatabase.GetUnionMember(memberId); Assert.IsNotNull(member); Assert.AreEqual(e, member); }
public void LoadUnionMember() { database.AddEmployee(employee); int memberId = 7783; ChangeMemberTransaction cmt = new ChangeMemberTransaction(employee.EmpId, memberId, 99.42, database); cmt.Execute(); var unionMember = database.GetUnionMember(memberId); Assert.AreEqual(employee.EmpId, unionMember.EmpId); Assert.AreEqual(employee.Name, unionMember.Name); Assert.AreEqual(employee.Address, unionMember.Address); var unionAffiliation = unionMember.Affiliation as UnionAffiliation; Assert.AreEqual(memberId, unionAffiliation.MemberId); Assert.AreEqual(99.42, unionAffiliation.Dues, .01); }
public void Execute() { var e = PayrollDatabase.GetUnionMember(_memberId); if (e == null) { throw new InvalidOperationException("Nie ma takiego członka związku."); } UnionAffiliation ua = null; if (e.Affiliation is UnionAffiliation) { ua = e.Affiliation as UnionAffiliation; } if (ua == null) { throw new InvalidOperationException("Próa obciążenia skłądką związkową pracownika, " + "który nie należy do związku zawodowego."); } ua.AddServiceCharge(new ServiceCharge(_date, _charge)); }
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); }