Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        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));
            }
        }
Exemplo n.º 3
0
        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));
            }
        }
Exemplo n.º 4
0
        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);
            }
        }
Exemplo n.º 5
0
        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()))}"
                }));
            }
        }
Exemplo n.º 6
0
 public S.IScheduleRepository SutFactory() => new PgresRepo(Db.dbConn());
Exemplo n.º 7
0
 public P.IParticipantRepository SutFactory() => new ParticipantRepo(Db.dbConn());