public static TestCase <Data.Schedule, S.PrincipalClaim, S.Appointment[]> GetSchedule(string s) { switch (s) { case "NotOnRecord": return(new TestCase <Data.Schedule, S.PrincipalClaim, S.Appointment[]> { Given = new Data.Schedule[0], Arguments = new S.PrincipalClaim( Guid.NewGuid(), Guid.NewGuid().ToString() ), Expect = new S.Appointment[0] }); case "OnRecord": var claim = new S.PrincipalClaim( Guid.NewGuid(), Guid.NewGuid().ToString() ); var seed = Arbitrary.Appointments( DateTimeOffset.Now.ToUnixTimeSeconds(), 1800, 2, claim.Schedule ).Take(10).ToList(); return(new TestCase <Data.Schedule, S.PrincipalClaim, S.Appointment[]> { Given = new[] { new Data.Schedule { PrincipalId = claim.Id, Name = claim.Schedule, Appointments = seed } }, Arguments = claim, Expect = seed .Select(x => new S.Appointment { Start = x.Start, Participants = x.Participants .Select(p => new S.Participation { SubjectId = p.SubjectId, Name = p.Name }).ToList() }).OrderBy(x => x.Start).ToArray() }); default: throw new ArgumentException(nameof(s)); } }
public static TestCase <Data.Schedule, Guid, IEnumerable <S.PrincipalClaim> > ListSchedule(string s) { switch (s) { case "NotOnRecord": return(new TestCase <Data.Schedule, Guid, IEnumerable <S.PrincipalClaim> > { Given = new Data.Schedule[0], Arguments = Guid.NewGuid(), Expect = new S.PrincipalClaim[0] }); case "OnRecord": var principal = Guid.NewGuid(); var names = new[] { "adam", "bertil", "ceasar" }; return(new TestCase <Data.Schedule, Guid, IEnumerable <S.PrincipalClaim> > { Given = names .Select(x => new Data.Schedule { PrincipalId = principal, Name = x, Appointments = Arbitrary.Appointments( DateTimeOffset.Now.ToUnixTimeSeconds(), 1800, 2, x).Take(3).ToList() }).ToArray(), Arguments = principal, Expect = names .Select(x => new S.PrincipalClaim(principal, x)) }); default: throw new ArgumentException(nameof(s)); } }