Exemple #1
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 #2
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 #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);
        }
Exemple #6
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 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 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);
        }
Exemple #10
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 #11
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 #12
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);
        }