public async Task Save_WhenEllCoachDto_AddsEllCoachToDb() { //Given DbContextOptions <PeopleContext> options = this.GetCosmosDbToEmulatorOptions <PeopleContext>(); using PeopleContext context = new PeopleContext(options, GetConfig()); string coachId = GetId(); string coachEmail = "*****@*****.**"; string instructor1Id = GetId(); string instructor1Email = "*****@*****.**"; string instructor2Id = GetId(); string instructor2Email = "*****@*****.**"; InstructorShortDto instructor1 = new InstructorShortDto() { Id = instructor1Id, Email = instructor1Email }; InstructorShortDto instructor2 = new InstructorShortDto() { Id = instructor2Id, Email = instructor2Email }; EllCoachDto coach = new EllCoachDto() { Id = coachId, Email = coachEmail, Type = DataAccessConstants.noSqlEllCoachType, Instructors = new List <InstructorShortDto>() { instructor1, instructor2 } }; //When context.Add(coach); await context.SaveChangesAsync(); coach = await context.FindAsync <EllCoachDto>(coachId); //Then Assert.Equal(coachId, coach.Id); Assert.Equal(coachEmail, coach.Email); Assert.Equal(instructor1Id, coach.Instructors[0].Id); Assert.Equal(instructor1Email, coach.Instructors[0].Email); Assert.Equal(instructor2Id, coach.Instructors[1].Id); Assert.Equal(instructor2Email, coach.Instructors[1].Email); }
public async Task Save_WhenAssistantDto_AddsAssistantsToDb() { //Given DbContextOptions <PeopleContext> options = this.GetCosmosDbToEmulatorOptions <PeopleContext>(); using PeopleContext context = new PeopleContext(options, GetConfig()); string assistantId = GetId(); string assistantEmail = "*****@*****.**"; string instructorId = GetId(); string instructorEmail = "*****@*****.**"; InstructorShortDto instructor = new InstructorShortDto() { Id = instructorId, Email = instructorEmail }; AssistantDto assistant = new AssistantDto() { Id = assistantId, Email = assistantEmail, Instructor = instructor }; //When await context.Database.EnsureDeletedAsync(); await context.Database.EnsureCreatedAsync(); context.Add(assistant); await context.SaveChangesAsync(); assistant = await context.FindAsync <AssistantDto>(assistantId); //Then Assert.Equal(assistantId, assistant.Id); Assert.Equal(assistantEmail, assistant.Email); Assert.Equal(instructorId, assistant.Instructor.Id); Assert.Equal(instructorEmail, assistant.Instructor.Email); }