public async Task DeleteAppointment(string key) { var testCase = ScheduleCases.DeleteAppointment(key); using (var db = Db.dbConn()) { db.AddRange(testCase.Given); await db.SaveChangesAsync(); } using (var sut = SutFactory()) { var r = await sut.DeleteAppointment( testCase.Arguments.Item1, testCase.Arguments.Item2); Assert.AreEqual(testCase.Expect.ToString(), r.ToString()); } using (var db = Db.dbConn()) { var onRecord = await(from a in db.Appointments where a.Schedule.PrincipalId == testCase.Arguments.Item1.Id && a.ScheduleName == testCase.Arguments.Item1.Schedule && a.Start == testCase.Arguments.Item2 select a).AnyAsync(); Assert.IsFalse(onRecord); } }
public async Task GetSchedule(string key) { var testCase = ScheduleCases.GetSchedule(key); using (var db = Db.dbConn()) { db.AddRange(testCase.Given); await db.SaveChangesAsync(); } using (var sut = SutFactory()) { var r = await sut.Get(testCase.Arguments); Assert.IsTrue(testCase.Expect.SequenceEqual(r)); } }
public async Task ListMyAppointments(string key) { var testCase = AppointmentCases.ListAppointment(key); using (var db = Db.dbConn()) { db.AddRange(testCase.Given); await db.SaveChangesAsync(); } using (var sut = SutFactory()) { var r = await sut.List(testCase.Arguments); Assert.IsTrue(testCase.Expect.SequenceEqual(r)); } }
public async Task PutSchedule(string key) { var testCase = ScheduleCases.PutAppointment(key); using (var db = Db.dbConn()) { db.AddRange(testCase.Given); await db.SaveChangesAsync(); } using (var sut = SutFactory()) { var r = await sut.PostAppointment( testCase.Arguments.Item1, testCase.Arguments.Item2); Assert.AreEqual(testCase.Expect, r); } }
public async Task GetMyAppointment(string key) { var testCase = AppointmentCases.GetAppointment(key); using (var db = Db.dbConn()) { db.AddRange(testCase.Given); await db.SaveChangesAsync(); } using (var sut = SutFactory()) { var r = await sut.Get(testCase.Arguments); Assert.IsTrue(testCase.Expect.SequenceEqual(r), Lines(new [] { $"expect: {Lines(testCase.Expect.Select(x => x.ToString()))}", "---", $"actual: {Lines(r.Select(x => x.ToString()))}" })); } }
public S.IScheduleRepository SutFactory() => new PgresRepo(Db.dbConn());
public P.IParticipantRepository SutFactory() => new ParticipantRepo(Db.dbConn());