public void TestAddServiceCharge() { #region Arrange int employeeId = 9; AddSalariedEmployee asd = new AddSalariedEmployee(employeeId, "user", "home", 1000.0); asd.Execute(); Employee e = PayrollRepository.GetEmployee(employeeId); e.Should().NotBeNull(); UnionAffiliation af = new UnionAffiliation(); e.Affiliation = af; int memberId = 886; PayrollRepository.AddUnionMember(memberId, e); ServiceChargeTransaction sct = new ServiceChargeTransaction( memberId, new DateTime(2019, 10, 10), 10.0); #endregion #region Action sct.Execute(); #endregion #region Assert ServiceCharge sc = af.GetServiceCharge(new DateTime(2019, 10, 10)); sc.Should().NotBeNull(); sc.Date.Should().Be(new DateTime(2019, 10, 10)); sc.Amount.Should().Be(10.0); #endregion }
public void AddServiceCharge() { int empId = 2; app.ExexcuteTransaction("addHourlyEmployee", RequestFactory.rf.MakeHourlyEmployeeRequest(empId, "Bob", "Home", 50)); Employee e = PayrollDb.GetEmployee(empId); Assert.IsNotNull(e); UnionAffiliation af = new UnionAffiliation(50, 100.50); e.Affiliation = af; int memeberId = 86; PayrollDb.AddUnionMember(memeberId, e); app.ExexcuteTransaction("addServiceCharge", RequestFactory.rf.MakeServiceChargeRequest(memeberId, new DateTime(2005, 8, 8), 12.95)); ServiceCharge sc = af.GetServiceCharge(new DateTime(2005, 8, 8)); Assert.IsNotNull(sc); Assert.AreEqual(12.95, sc.Amount, .001); }
public void AddServiceChargeTests() { int empId = 2; var name = "Bartosz"; var hourlyRate = 15.25; AddHourlyEmployee t = new AddHourlyEmployee(empId, name, "Home", hourlyRate); t.Execute(); Employee e = PayrollDatabase.GetEmployee(empId); Assert.IsNotNull(e); var memberId = 86; var dues = 88.12; UnionAffiliation af = new UnionAffiliation(memberId, dues); e.Affiliation = af; var date = new DateTime(2005, 8, 8); var charge = 12.95; PayrollDatabase.AddUnionMember(memberId, e); ServiceChargeTransaction sct = new ServiceChargeTransaction(memberId, date, charge); sct.Execute(); ServiceCharge sc = af.GetServiceCharge(date); Assert.IsNotNull(sc); Assert.AreEqual(charge, sc.Amount, .001); }
public void AddServiceCharge() { int empId = 2; AddHourlyEmployee t = new AddHourlyEmployee( empId, "Bill", "Home", 15.25, database); t.Execute(); Employee e = database.GetEmployee(empId); Assert.IsNotNull(e); UnionAffiliation af = new UnionAffiliation(); e.Affiliation = af; int memberId = 86; // Maxwell Smart database.AddUnionMember(memberId, e); ServiceChargeTransaction sct = new ServiceChargeTransaction( memberId, new DateTime(2005, 8, 8), 12.95, database); sct.Execute(); ServiceCharge sc = af.GetServiceCharge(new DateTime(2005, 8, 8)); Assert.IsNotNull(sc); Assert.AreEqual(12.95, sc.Amount, .001); }
public void TestAddServiceCharge() { int empId = 2; AddHourlyEmployee t = new AddHourlyEmployee(empId, "Kubing", "Home", 15.25, database); t.Execute(); Employee e = database.GetEmployee(empId); Assert.IsNotNull(e); int memberId = 86; database.AddUnionMember(memberId, e); UnionAffiliation ua = new UnionAffiliation(memberId, 99.52); e.Affiliation = ua; var date = new DateTime(2005, 8, 8); ServiceChargeTransaction sct = new ServiceChargeTransaction(memberId, date, 12.95, database); sct.Execute(); var serviceCharges = database.GetServiceCharges(memberId); ServiceCharge sc = serviceCharges.FirstOrDefault(x => x.Date == date); Assert.IsNotNull(sc); Assert.AreEqual(12.95, sc.Amount, 0.001); }
public void AddServiceCharge() { int empId = SetupHourlyEmployee(); Employee e = PayrollDatabase.GetEmployee(empId); Assert.NotNull(e); const int memberId = 86; // Maxwell Smart var af = new UnionAffiliation(memberId, 12.95); e.Affiliation = af; PayrollDatabase.AddUnionMember(memberId, e); var sct = new ServiceChargeTransaction(memberId, new DateTime(2005, 8, 8), 12.95); sct.Execute(); ServiceCharge sc = af.GetServiceCharge(new DateTime(2005, 8, 8)); Assert.NotNull(sc); Assert.Equal(12.95, sc.Amount); }
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 ExecuteTest() { int empId = 33; int memberId = 987; double dues = 98.6; AddSalariedEmployee addSalEmp = new AddSalariedEmployee(empId, "Masa", "Faav Street", 5000, database); addSalEmp.Execute(); ChangeAffiliationTransaction changeAffTrans = new ChangeMemberTransaction(empId, memberId, dues, database); changeAffTrans.Execute(); Employee emp = database.GetEmployee(empId); Assert.IsNotNull(emp); Assert.IsTrue(emp.Affiliation is UnionAffiliation); UnionAffiliation ua = emp.Affiliation as UnionAffiliation; Assert.IsNotNull(ua); Assert.AreEqual(ua.Dues, dues); Employee member = database.GetUnionMember(memberId); Assert.IsNotNull(member); Assert.AreEqual(emp, member); }
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); }
public void TestAddServiceCharge() { int empId = 2; int memberId = 7734; var addTx = new AddHourlyEmployee(empId, "Bill", "Home", 15.25M); addTx.Execute(); var employee = Database.GetEmployee(empId); var unionAffiliation = new UnionAffiliation(memberId, 12.5M); employee.Affiliation = unionAffiliation; Database.AddUnionMember(memberId, employee); var serviceChargeTransaction = new ServiceChargeTransaction(memberId, new Date(11, 01, 2001), 12.95M); serviceChargeTransaction.Execute(); var serviceCharge = unionAffiliation.GetServiceCharge(new Date(11, 01, 2001)); Assert.IsNotNull(serviceCharge); Assert.AreEqual(12.95M, serviceCharge.Amount); }
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 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 ChangeUnionMember() { int employeeId = 18; AddEmployTransaction aet = new AddHourlyEmployee(employeeId, "Bill", "home", 19.1); aet.Execute(); int memberId = 8591; ChangeMemberTransaction cmt = new ChangeMemberTransaction(employeeId, memberId, 99.42); cmt.Execute(); Employee e = PayrollRepository.GetEmployee(employeeId); e.Should().NotBeNull(); e.Affiliation.Should().NotBeNull(); e.Affiliation.Should().BeOfType <UnionAffiliation>(); UnionAffiliation uf = e.Affiliation as UnionAffiliation; uf.Dues.Should().Be(99.42); Employee member = PayrollRepository.GetUnionMember(memberId); member.Should().NotBeNull(); member.Should().Be(e); }
public override void RecordMemberShip(Employee employee) { UnionAffiliation ua = employee.Affiliation as UnionAffiliation; if (ua != null) { int memberId = ua.MemberId; PayrollRepository.RemoveUnionMember(memberId); } }
protected override void RecordMembership(Employee e) { Affiliation affiliation = e.Affiliation; if (affiliation is UnionAffiliation) { UnionAffiliation unionAffiliation = affiliation as UnionAffiliation; int memberId = unionAffiliation.MemberId; database.RemoveUnionMember(memberId); } }
public void Execute() { Employee e = PayrollRepository.GetUnionMember(_memberId); bool isExistingMember = e != null; if (isExistingMember) { UnionAffiliation ua = e.Affiliation as UnionAffiliation; ServiceCharge sc = new ServiceCharge(_date, _amount); ua.AddServiceCharge(sc); } else { throw new InvalidOperationException("No such union member."); } }
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 AddserviceCharge() { int empid = 8; AddHourlyEmployee t = new AddHourlyEmployee(empid, "Bob", "Home", 23.41); t.Execute(); Employee e = PayrollDatabase.GetEmployee_Static(empid); Assert.IsNotNull(e); UnionAffiliation af = new UnionAffiliation(); e.Affiliation = af; int memberId = 86; PayrollDatabase.AddUnionMember_Static(memberId, e); ServiceChargeTransaction sct = new ServiceChargeTransaction(memberId, new DateTime(2015, 11, 8), 12.95); sct.Execute(); ServiceCharge sc = af.GetServiceCharge(new DateTime(2015, 11, 8)); Assert.IsNotNull(sc); Assert.AreEqual(12.95, sc.Charge, .001); }
public void TestAddServiceCharge() { const int empId = 7; var t = new AddHourlyEmployee(empId, "Bill", "Home", 15.25); t.Execute(); var e = PayrollDatabase.GetEmployee(empId); Assert.IsNotNull(e); var af = new UnionAffiliation(); e.Affiliation = af; const int memberId = 86; PayrollDatabase.AddUnionMember(memberId, e); var sct = new ServiceChargeTransaction(memberId, new DateTime(2020, 8, 8), 12.95); sct.Execute(); var sc = af.GetServiceCharge(new DateTime(2020, 8, 8)); Assert.IsNotNull(sc); Assert.AreEqual(12.95, sc.Amount, 0.001); }
public async Task AddServiceCharge() { int empId = 4; AddHourlyEmployee t = new AddHourlyEmployee(empId, "Bill", "Home", 15.25); await t.ExecuteAsync(); Employee e = await PayrollDatabase.GetEmployeeAsync(empId); Assert.NotNull(e); UnionAffiliation af = new UnionAffiliation(); e.Affiliation = af; int memberId = 86; // Maxwell Smart await PayrollDatabase.AddUnionMemberAsync(memberId, e); ServiceChargeTransaction sct = new ServiceChargeTransaction(memberId, new DateTime(2005, 8, 8), 12.95); await sct.ExecuteAsync(); ServiceCharge sc = af.GetServiceCharge(new DateTime(2005, 8, 8)); Assert.NotNull(sc); Assert.Equal(12.95, sc.Amount); }
public void ExecuteTest() { int empId = 15; int memberId = 86; double unionDues = 90.8; double chargeAmount = 12; DateTime chargeDate = new DateTime(2014, 6, 7); //增加并获取雇员 AddCommissionedEmployee addComEmp = new AddCommissionedEmployee(empId, "Muma", "shanghai", 12.3, 1.56, database); addComEmp.Execute(); Employee emp = database.GetEmployee(empId); Assert.IsNotNull(emp); //设置并保存公会会员 Affiliation unionAffiliation = new UnionAffiliation(memberId, unionDues); emp.Affiliation = unionAffiliation; database.AddUnionMember(memberId, emp); //将会费信息添加到会员上 ServiceChargeTransaction sct = new ServiceChargeTransaction(memberId, chargeAmount, chargeDate, database); sct.Execute(); //检查会费 UnionAffiliation ua = emp.Affiliation as UnionAffiliation; Assert.IsNotNull(ua); ServiceCharge sc = ua.GetServiceCharge(chargeDate); Assert.IsNotNull(sc); Assert.AreEqual(sc.Amount, chargeAmount, 0.001); }
public void NumberOfFridaysTest() { NUnitHelper nHelper = new NUnitHelper(); UnionAffiliation ua = new UnionAffiliation(12, 34); int fridays = (int)nHelper.InvokePMethod(typeof(UnionAffiliation), "NumberOfFridays", ua, new object[2] { new DateTime(2014, 3, 1), new DateTime(2014, 3, 31) }); Assert.AreEqual(4, fridays); fridays = (int)nHelper.InvokePMethod(typeof(UnionAffiliation), "NumberOfFridays", ua, new object[2] { new DateTime(2014, 3, 1), new DateTime(2014, 4, 18) }); Assert.AreEqual(7, fridays); fridays = (int)nHelper.InvokePMethod(typeof(UnionAffiliation), "NumberOfFridays", ua, new object[2] { new DateTime(2014, 4, 18), new DateTime(2014, 4, 30) }); Assert.AreEqual(2, fridays); }
public void Execute() { var e = PayrollDatabase.GetUnionMember(memberId); if (e is null) { throw new InvalidOperationException("No such union member."); } UnionAffiliation ua = null; if (e.Affiliation is UnionAffiliation) { ua = e.Affiliation as UnionAffiliation; } if (ua is null) { throw new InvalidOperationException( "Tries to add service charge to union member without a union affiliation."); } ua.AddServiceCharge(new ServiceCharge(time, charge)); }
public void ChangeUnionMember() { int empid = 16; AddHourlyEmployee t = new AddHourlyEmployee(empid, "Bob", "Home", 256.1); t.Execute(); int memberId = 7743; ChangeMemberTransaction cmt = new ChangeMemberTransaction(empid, memberId, 99.42); cmt.Execute(); Employee e = PayrollDatabase.GetEmployee_Static(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.Charge, .001); Employee member = PayrollDatabase.GetUnionMember_Static(memberId); Assert.AreEqual(e, member); }
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); }