public async Task GetSalonYearsWithAccreditations_GetsFromDb()
        {
            // Arrange
            await salonYearRepository.Add(new SalonYearEntity
            {
                Name           = "test1",
                Year           = 2017,
                Salon          = EntitiesHelper.GetSalon(),
                Accreditations = new List <AccreditationEntity> {
                    new AccreditationEntity {
                        SalonNumber = "1", PhotoOrganisation = EntitiesHelper.GetPhotoOrganisation()
                    },
                    new AccreditationEntity {
                        SalonNumber = "1", PhotoOrganisation = EntitiesHelper.GetPhotoOrganisation()
                    }
                }
            });

            await salonYearRepository.Add(new SalonYearEntity
            {
                Name           = "test2",
                Year           = 2016,
                Salon          = EntitiesHelper.GetSalon(),
                Accreditations = new List <AccreditationEntity> {
                }
            });

            await salonYearRepository.Add(new SalonYearEntity
            {
                Name           = "test3",
                Year           = 2017,
                Salon          = EntitiesHelper.GetSalon(),
                Accreditations = new List <AccreditationEntity> {
                }
            });

            // Act
            var lResult = await salonYearRepository.GetSalonYearsWithAccreditations(2017);

            // Assert
            Assert.IsNotNull(lResult);
            Assert.AreEqual(2, lResult.Count(t => t.Name.StartsWith("test")));
            Assert.AreEqual(2, lResult.Where(t => t.Name.StartsWith("test")).ToList()[0].Accreditations.Count);
        }
Example #2
0
        public async Task GetWithSubmissionsSalonsAccreditationSections_GetsFromDb()
        {
            // Arrange
            var lSalonYear = EntitiesHelper.GetSalonYear();

            lSalonYear.Accreditations = new List <AccreditationEntity> {
                new AccreditationEntity {
                    SalonNumber = "test", PhotoOrganisation = EntitiesHelper.GetPhotoOrganisation()
                }
            };
            var lSection = EntitiesHelper.GetSection();

            lSection.SalonYear = lSalonYear;
            var lSubmission = new SubmissionEntity {
                SalonYear = lSalonYear, Entries = new List <CompetitionEntryEntity> {
                    new CompetitionEntryEntity {
                        Image = EntitiesHelper.GetImage(), Section = lSection
                    }
                }
            };
            var lCreatedEntity = await personRepository.Add(new PersonEntity { Name = "test1", Submissions = new List <SubmissionEntity> {
                                                                                   lSubmission
                                                                               } });

            // Act
            var lResult = await personRepository.GetWithSubmissionsSalonsAccreditationSections(lCreatedEntity.Id);

            // Assert
            Assert.IsNotNull(lResult);
            Assert.IsNotNull(lResult.Submissions);
            Assert.IsTrue(lResult.Submissions.Any());
            Assert.IsNotNull(lResult.Submissions[0].Entries);
            Assert.IsTrue(lResult.Submissions[0].Entries.Any());
            Assert.IsNotNull(lResult.Submissions[0].Entries[0].Section);
            Assert.IsNotNull(lResult.Submissions[0].Entries[0].Section.SectionType);
            Assert.IsNotNull(lResult.Submissions[0].Entries[0].Section.SalonYear);
            Assert.IsNotNull(lResult.Submissions[0].Entries[0].Section.SalonYear.Accreditations);
            Assert.IsTrue(lResult.Submissions[0].Entries[0].Section.SalonYear.Accreditations.Any());
            Assert.IsNotNull(lResult.Submissions[0].Entries[0].Section.SalonYear.Salon);
        }