public void Should_Be_Right_Submissions_When_Find_By_Challenge_And_Acceleration(int challengeId, int accelerationId)
        {
            var fakeContext = new FakeContext("SubmissionByChallengeAndAcceleration");

            fakeContext.FillWithAll();

            using (var context = new CodenationContext(fakeContext.FakeOptions))
            {
                var expected = fakeContext.GetFakeData <Candidate>().
                               Where(candidate => candidate.AccelerationId == accelerationId).
                               Join(fakeContext.GetFakeData <User>(),
                                    candidate => candidate.UserId,
                                    user => user.Id,
                                    (candidate, user) => user).
                               Join(fakeContext.GetFakeData <Submission>(),
                                    user => user.Id,
                                    submission => submission.UserId,
                                    (user, submission) => submission).
                               Where(submission => submission.ChallengeId == challengeId).
                               Distinct().
                               ToList();

                var service = new SubmissionService(context);
                var actual  = service.FindByChallengeIdAndAccelerationId(accelerationId, challengeId);

                Assert.Equal(expected, actual, new SubmissionIdComparer());
            }
        }
        public void FindByAccelerationIdTest_Return_Right(int challengeId, int accelerationId, params string[] idSubmissionsExpected)
        {
            var fakeContext = new FakeContext("FindByChallengeIdAndAccelerationId");
            fakeContext.FillWith<Acceleration>();
            fakeContext.FillWith<Candidate>();
            fakeContext.FillWith<User>();
            fakeContext.FillWith<Submission>();
            fakeContext.FillWith <Models.Challenge>();

            using (var context = new CodenationContext(fakeContext.FakeOptions))
            {
                List<Submission> expected = new List<Submission>();
                foreach (var idCandidate in idSubmissionsExpected)
                {
                    var idSubmissionInt = idCandidate.Split(',').Select(x => int.Parse(x)).ToList();
                    expected.Add(fakeContext
                        .GetFakeData<Submission>()
                        .Find(x => x.UserId == idSubmissionInt[0]
                                && x.ChallengeId == idSubmissionInt[1]));
                }

                var service = new SubmissionService(context);
                var actual = service.FindByChallengeIdAndAccelerationId(challengeId, accelerationId)
                                    .OrderBy(s => s.UserId)
                                    .ThenBy(s => s.ChallengeId);

                Assert.Equal(expected, actual, new SubmissionIdComparer());
            }
        }
        public void Should_Return_Right_Submission_When_Find_By_Id(int challengeId, int accelerationId)
        {
            _contextoFake.FillWithAll();

            var submissionEsperado = _contextoFake.GetFakeData <Submission>()
                                     .Find(x => x.ChallengeId == challengeId);

            var accelerationEsperado = _contextoFake.GetFakeData <Acceleration>()
                                       .Find(x => x.Id == accelerationId);


            var submissionReal = _submissionService.FindByChallengeIdAndAccelerationId(submissionEsperado.ChallengeId, accelerationEsperado.Id);

            Assert.Equal(submissionEsperado.ChallengeId, submissionReal.FirstOrDefault().ChallengeId);
        }