Exemplo n.º 1
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)));
        }