Exemple #1
0
        public async Task GetSectionsBySalonYearSectionTypeIds_GetsFromDb()
        {
            // Arrange
            var salonYear       = EntitiesHelper.GetSalonYear();
            var sectionType1    = EntitiesHelper.GetSectionType();
            var sectionType2    = EntitiesHelper.GetSectionType();
            var lCreatedEntity1 = await sectionRepository.Add(new Entities.SectionEntity {
                SalonYear = salonYear, SectionType = sectionType1
            });

            var lCreatedEntity2 = await sectionRepository.Add(new Entities.SectionEntity {
                SalonYear = salonYear, SectionType = sectionType2
            });

            var lCreatedEntity3 = await sectionRepository.Add(new Entities.SectionEntity {
                SalonYear = EntitiesHelper.GetSalonYear(), SectionType = sectionType2
            });

            var lCreatedEntity4 = await sectionRepository.Add(new Entities.SectionEntity {
                SalonYear = salonYear, SectionType = EntitiesHelper.GetSectionType()
            });


            // Act
            var lResult = await sectionRepository.GetSectionsBySalonYearSectionTypeIds(salonYear.Id, new List <int> {
                sectionType1.Id, sectionType2.Id
            });

            // Assert
            Assert.IsNotNull(lResult);
            Assert.AreEqual(2, lResult.Count);
        }
Exemple #2
0
        public async Task GetSubmissionWithEntries_GetsFromDb()
        {
            // Arrange
            ImageEntity imageEntity = EntitiesHelper.GetImage();

            var lCreatedEntity = await submissionRepository.Add(new Entities.SubmissionEntity {
                Notes   = "test", SalonYear = EntitiesHelper.GetSalonYear(), Person = EntitiesHelper.GetPerson(),
                Entries = new List <CompetitionEntryEntity>
                {
                    new CompetitionEntryEntity
                    {
                        Image      = imageEntity,
                        Section    = EntitiesHelper.GetSection(),
                        IsAccepted = true,
                        IsAwarded  = false,
                        Score      = 50
                    },
                    new CompetitionEntryEntity
                    {
                        Image   = imageEntity,
                        Section = EntitiesHelper.GetSection(),
                    }
                }
            });

            // Act
            var lResult = await submissionRepository.GetSubmissionWithEntries(lCreatedEntity.Id);

            // Assert
            Assert.IsNotNull(lResult);
            Assert.IsTrue(lResult.Id > 0);
            Assert.AreEqual("test", lResult.Notes);
            Assert.AreEqual(2, lResult.Entries.Count);
        }
Exemple #3
0
        public async Task UpdateSubmission_SetsNameAndEntryInDb()
        {
            // Arrange
            ImageEntity imageEntity    = EntitiesHelper.GetImage();
            var         lCreatedEntity = await submissionRepository.Add(new Entities.SubmissionEntity
            {
                Notes     = "test",
                SalonYear = EntitiesHelper.GetSalonYear(),
                Person    = EntitiesHelper.GetPerson(),
                Entries   = new List <CompetitionEntryEntity>
                {
                    new CompetitionEntryEntity
                    {
                        Image      = imageEntity,
                        Section    = EntitiesHelper.GetSection(),
                        IsAccepted = true,
                        IsAwarded  = false,
                        Score      = 50
                    },
                    new CompetitionEntryEntity
                    {
                        Image   = imageEntity,
                        Section = EntitiesHelper.GetSection(),
                    }
                }
            });

            lCreatedEntity.Notes = "fred";
            lCreatedEntity.Entries[0].IsAwarded = true;
            lCreatedEntity.Entries[0].Score     = 100;

            lCreatedEntity.Entries[1].IsAccepted = false;
            lCreatedEntity.Entries[1].IsAwarded  = false;
            lCreatedEntity.Entries[1].Score      = 20;


            // Act
            await submissionRepository.Update(lCreatedEntity);

            // Assert
            var lResult = await submissionRepository.GetSubmissionWithEntries(lCreatedEntity.Id);

            Assert.IsNotNull(lResult);
            Assert.IsTrue(lResult.Id > 0);
            Assert.AreEqual("fred", lResult.Notes);
            Assert.AreEqual(100, lResult.Entries[0].Score);
            Assert.AreEqual(true, lResult.Entries[0].IsAccepted);
            Assert.AreEqual(true, lResult.Entries[0].IsAwarded);

            Assert.AreEqual(20, lResult.Entries[1].Score);
            Assert.AreEqual(false, lResult.Entries[1].IsAccepted);
            Assert.AreEqual(false, lResult.Entries[1].IsAwarded);
        }
Exemple #4
0
        public async Task GetSection_GetsFromDb()
        {
            // Arrange
            var lCreatedEntity = await sectionRepository.Add(new Entities.SectionEntity {
                SalonYear = EntitiesHelper.GetSalonYear(), SectionType = EntitiesHelper.GetSectionType()
            });

            // Act
            var lResult = await sectionRepository.GetById(lCreatedEntity.Id);

            // Assert
            Assert.IsNotNull(lResult);
            Assert.IsTrue(lResult.Id > 0);
        }
Exemple #5
0
        public async Task GetSubmission_GetsFromDb()
        {
            // Arrange
            var lCreatedEntity = await submissionRepository.Add(new Entities.SubmissionEntity {
                Notes = "test", SalonYear = EntitiesHelper.GetSalonYear(), Person = EntitiesHelper.GetPerson()
            });

            // Act
            var lResult = await submissionRepository.GetById(lCreatedEntity.Id);

            // Assert
            Assert.IsNotNull(lResult);
            Assert.IsTrue(lResult.Id > 0);
            Assert.AreEqual("test", lResult.Notes);
        }
        public async Task AddSalonYear_AddsToDb()
        {
            // Act
            var lResult = await salonYearRepository.Add(new Entities.SalonYearEntity {
                Name = "test", Salon = EntitiesHelper.GetSalon()
            });

            // Assert
            Assert.IsTrue(lResult.Id > 0);
            var lCreatedEntity = await salonYearRepository.GetById(lResult.Id);

            Assert.IsNotNull(lCreatedEntity);
            Assert.AreEqual("test", lCreatedEntity.Name);
            Assert.IsTrue(lCreatedEntity.Id > 0);
        }
        public async Task GetSalon_GetsFromDb()
        {
            // Arrange
            var lCreatedEntity = await salonRepository.Add(new Entities.SalonEntity {
                Name = "test", Country = EntitiesHelper.GetCountry()
            });

            // Act
            var lResult = await salonRepository.GetById(lCreatedEntity.Id);

            // Assert
            Assert.IsNotNull(lResult);
            Assert.IsTrue(lResult.Id > 0);
            Assert.AreEqual("test", lResult.Name);
        }
        public async Task GetCompetitionEntry_GetsFromDb()
        {
            // Arrange
            var lCreatedEntity = await competitionEntryRepository.Add(new Entities.CompetitionEntryEntity {
                Score = 50, Image = EntitiesHelper.GetImage(), Section = EntitiesHelper.GetSection()
            });

            // Act
            var lResult = await competitionEntryRepository.GetById(lCreatedEntity.Id);

            // Assert
            Assert.IsNotNull(lResult);
            Assert.IsTrue(lResult.Id > 0);
            Assert.AreEqual(50, lResult.Score);
        }
Exemple #9
0
        public async Task DeleteSubmission_RemovesFromDb()
        {
            // Arrange
            var lCreatedEntity = await submissionRepository.Add(new Entities.SubmissionEntity {
                Notes = "test", SalonYear = EntitiesHelper.GetSalonYear(), Person = EntitiesHelper.GetPerson()
            });

            // Act
            await submissionRepository.Delete(lCreatedEntity);

            // Assert
            var lResult = await submissionRepository.GetById(lCreatedEntity.Id);

            Assert.IsNull(lResult);
            Assert.IsTrue(lCreatedEntity.Id > 0);
        }
        public async Task DeleteCompetitionEntry_RemovesFromDb()
        {
            // Arrange
            var lCreatedEntity = await competitionEntryRepository.Add(new Entities.CompetitionEntryEntity {
                Score = 50, Image = EntitiesHelper.GetImage(), Section = EntitiesHelper.GetSection()
            });

            // Act
            await competitionEntryRepository.Delete(lCreatedEntity);

            // Assert
            var lResult = await competitionEntryRepository.GetById(lCreatedEntity.Id);

            Assert.IsNull(lResult);
            Assert.IsTrue(lCreatedEntity.Id > 0);
        }
Exemple #11
0
        public async Task DeleteSalon_RemovesFromDb()
        {
            // Arrange
            var lCreatedEntity = await salonRepository.Add(new Entities.SalonEntity {
                Name = "test", Country = EntitiesHelper.GetCountry()
            });

            // Act
            await salonRepository.Delete(lCreatedEntity);

            // Assert
            var lResult = await salonRepository.GetById(lCreatedEntity.Id);

            Assert.IsNull(lResult);
            Assert.IsTrue(lCreatedEntity.Id > 0);
        }
        public async Task GetAccreditation_GetsFromDb()
        {
            // Arrange
            var lCreatedEntity = await accreditationRepository.Add(new Entities.AccreditationEntity {
                SalonNumber = "test", SalonYear = EntitiesHelper.GetSalonYear(), PhotoOrganisation = new PhotoOrganisationEntity {
                    Name = "org1"
                }
            });

            // Act
            var lResult = await accreditationRepository.GetById(lCreatedEntity.Id);

            // Assert
            Assert.IsNotNull(lResult);
            Assert.IsTrue(lResult.Id > 0);
            Assert.AreEqual("test", lResult.SalonNumber);
        }
        public async Task DeleteAccreditation_RemovesFromDb()
        {
            // Arrange
            var lCreatedEntity = await accreditationRepository.Add(new Entities.AccreditationEntity {
                SalonNumber = "test", SalonYear = EntitiesHelper.GetSalonYear(), PhotoOrganisation = new PhotoOrganisationEntity {
                    Name = "org1"
                }
            });

            // Act
            await accreditationRepository.Delete(lCreatedEntity);

            // Assert
            var lResult = await accreditationRepository.GetById(lCreatedEntity.Id);

            Assert.IsNull(lResult);
            Assert.IsTrue(lCreatedEntity.Id > 0);
        }
        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);
        }
Exemple #15
0
        public async Task UpdateSalon_SetsNameInDb()
        {
            // Arrange
            var lCreatedEntity = await salonRepository.Add(new Entities.SalonEntity {
                Name = "test", Country = EntitiesHelper.GetCountry()
            });

            lCreatedEntity.Name = "fred";

            // Act
            await salonRepository.Update(lCreatedEntity);

            // Assert
            var lResult = await salonRepository.GetById(lCreatedEntity.Id);

            Assert.IsNotNull(lResult);
            Assert.IsTrue(lResult.Id > 0);
            Assert.AreEqual("fred", lResult.Name);
        }
        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);
        }
        public async Task GetSalonYearsIdsByCircuitId_GetsFromDb()
        {
            // Arrange
            var circuit = new CircuitEntity {
                Name = "circuitName"
            };
            await salonYearRepository.Add(new SalonYearEntity
            {
                Name    = "test1",
                Year    = 2017,
                Salon   = EntitiesHelper.GetSalon(),
                Circuit = circuit
            });

            await salonYearRepository.Add(new SalonYearEntity
            {
                Name    = "test2",
                Year    = 2016,
                Salon   = EntitiesHelper.GetSalon(),
                Circuit = circuit
            });

            await salonYearRepository.Add(new SalonYearEntity
            {
                Name    = "test3",
                Year    = 2017,
                Salon   = EntitiesHelper.GetSalon(),
                Circuit = new CircuitEntity {
                    Name = "circuitName2"
                }
            });

            // Act
            var lResult = await salonYearRepository.GetSalonYearsIdsByCircuitId(circuit.Id);

            // Assert
            Assert.IsNotNull(lResult);
            Assert.AreEqual(2, lResult.Count());
        }
Exemple #18
0
        public async Task UpdateSection_SetsNameInDb()
        {
            // Arrange
            var lCreatedEntity = await sectionRepository.Add(new Entities.SectionEntity {
                SalonYear = EntitiesHelper.GetSalonYear(), SectionType = EntitiesHelper.GetSectionType()
            });

            var lNewSalonYear = EntitiesHelper.GetSalonYear();

            lNewSalonYear.Name       = "new salon year";
            lCreatedEntity.SalonYear = lNewSalonYear;

            // Act
            await sectionRepository.Update(lCreatedEntity);

            // Assert
            var lResult = await sectionRepository.GetById(lCreatedEntity.Id);

            Assert.IsNotNull(lResult);
            Assert.IsTrue(lResult.Id > 0);
            Assert.AreEqual("new salon year", lResult.SalonYear.Name);
        }
Exemple #19
0
        public async Task GetSubmissionResults_GetsFromDb()
        {
            // Arrange
            ImageEntity imageEntity    = EntitiesHelper.GetImage();
            var         lCreatedEntity = await submissionRepository.Add(new SubmissionEntity { Notes   = "test", SalonYear = EntitiesHelper.GetSalonYear(), Person = EntitiesHelper.GetPerson(),
                                                                                               Entries = new List <CompetitionEntryEntity>
                                                                                               {
                                                                                                   new CompetitionEntryEntity
                                                                                                   {
                                                                                                       Image        = imageEntity,
                                                                                                       Section      = EntitiesHelper.GetSection(),
                                                                                                       IsAccepted   = true,
                                                                                                       IsAwarded    = false,
                                                                                                       AwardDetails = "award 1",
                                                                                                       Score        = 50
                                                                                                   },
                                                                                                   new CompetitionEntryEntity
                                                                                                   {
                                                                                                       Image   = imageEntity,
                                                                                                       Section = EntitiesHelper.GetSection(),
                                                                                                   }
                                                                                               } });

            // Act
            var lResult = await submissionRepository.GetSubmissionResults(lCreatedEntity.Id);

            // Assert
            Assert.IsNotNull(lResult);
            Assert.IsTrue(lResult.SubmissionId > 0);
            Assert.IsTrue(lResult.PersonId > 0);
            Assert.IsTrue(!string.IsNullOrWhiteSpace(lResult.DisplayName));
            Assert.IsTrue(!string.IsNullOrWhiteSpace(lResult.Entries.ToList()[0].AwardDetails));
            Assert.IsTrue(lResult.Entries.Any(ent => ent.Id > 0 && ent.Score == 50 && ent.IsAwarded == false && ent.IsAccepted == true));
            Assert.IsTrue(lResult.Entries.Any(ent => ent.Id > 0 && !ent.Score.HasValue && !ent.IsAwarded.HasValue && !ent.IsAccepted.HasValue));
            Assert.IsTrue(lResult.Entries.All(ent => !string.IsNullOrWhiteSpace(ent.ImageName)));
        }
Exemple #20
0
        public async Task GetBasicSubmissionInfoByPersonId_GetsFromDb()
        {
            // Arrange
            ImageEntity imageEntity  = EntitiesHelper.GetImage();
            var         personEntity = EntitiesHelper.GetPerson();
            await submissionRepository.Add(new SubmissionEntity
            {
                Notes     = "test",
                SalonYear = EntitiesHelper.GetSalonYear(),
                Person    = personEntity,
                IsJudged  = true,
                Entries   = new List <CompetitionEntryEntity>
                {
                    new CompetitionEntryEntity
                    {
                        Image      = imageEntity,
                        Section    = EntitiesHelper.GetSection(),
                        IsAccepted = true,
                        IsAwarded  = false,
                        Score      = 50
                    },
                    new CompetitionEntryEntity
                    {
                        Image   = imageEntity,
                        Section = EntitiesHelper.GetSection(),
                    }
                }
            });

            await submissionRepository.Add(new SubmissionEntity
            {
                Notes     = "test",
                SalonYear = EntitiesHelper.GetSalonYear(),
                Person    = personEntity,
                Entries   = new List <CompetitionEntryEntity>
                {
                    new CompetitionEntryEntity
                    {
                        Image      = imageEntity,
                        Section    = EntitiesHelper.GetSection(),
                        IsAccepted = true,
                        IsAwarded  = false,
                        Score      = 50
                    },
                    new CompetitionEntryEntity
                    {
                        Image   = imageEntity,
                        Section = EntitiesHelper.GetSection(),
                    }
                }
            });

            // Act
            var lResult = await submissionRepository.GetBasicSubmissionInfoByPersonId(personEntity.Id);

            // Assert
            Assert.IsNotNull(lResult);
            Assert.AreEqual(2, lResult.Count);
            Assert.IsTrue(lResult[0].SubmissionId > 0);
            Assert.IsTrue(lResult[0].IsJudged);
            Assert.IsTrue(!string.IsNullOrWhiteSpace(lResult[0].DisplayName));
            Assert.AreEqual(2, lResult[0].NumberOfEntries);
        }
Exemple #21
0
        public async Task GetFullSalonInformation_GetsFromDb()
        {
            // Arrange
            var lCreatedEntity1 = await salonRepository.Add(new SalonEntity { Name = "test1", Website = "www.1", Country = EntitiesHelper.GetCountry() });

            var lCreatedEntity2 = await salonRepository.Add(new SalonEntity { Name = "test2", Website = "www.1", Country = EntitiesHelper.GetCountry() });

            // Act
            var lResult = await salonRepository.GetFullSalonInformation();

            // Assert
            Assert.IsNotNull(lResult);
            Assert.IsTrue(lResult.Count > 1);
            Assert.IsTrue(lResult.All(se => se.SalonId > 0));
            Assert.IsTrue(lResult.All(se => se.CountryId > 0));
            Assert.IsTrue(lResult.All(se => !string.IsNullOrEmpty(se.CountryName)));
            Assert.IsTrue(lResult.All(se => !string.IsNullOrEmpty(se.SalonName)));
            Assert.IsTrue(lResult.Where(se => se.SalonName.StartsWith("test")).All(se => !string.IsNullOrEmpty(se.Website)));
        }