Пример #1
0
        public void Should_Update_The_Candidate_When_Save()
        {
            var fakeContext = new FakeContext("SaveNewCandidate");

            fakeContext.FillWithAll();

            var fakeCandidate = new Candidate();

            fakeCandidate.UserId         = 7;
            fakeCandidate.AccelerationId = 3;
            fakeCandidate.CompanyId      = 7;
            fakeCandidate.Status         = 2;
            fakeCandidate.CreatedAt      = DateTime.Today;

            using (var context = new CodenationContext(fakeContext.FakeOptions))
            {
                var service = new CandidateService(context);
                var actual  = service.Save(fakeCandidate);

                Assert.NotEqual(0, 1);
            }
        }
Пример #2
0
        public void Should_Be_Right_Candidates_When_Find_By_Accelaration_Id(int accelerationId)
        {
            var fakeContext = new FakeContext("CandidateByAcceleration");

            fakeContext.FillWithAll();

            using (var context = new CodenationContext(fakeContext.FakeOptions))
            {
                var expected = fakeContext.GetFakeData <Acceleration>().
                               Where(acceleration => acceleration.Id == accelerationId).
                               Join(fakeContext.GetFakeData <Candidate>(),
                                    acceleration => acceleration.Id,
                                    candidate => candidate.AccelerationId,
                                    (acceleration, candidate) => candidate).
                               ToList();

                var service = new CandidateService(context);
                var actual  = service.FindByAccelerationId(accelerationId);

                Assert.Equal(expected, actual, new CandidateIdComparer());
            }
        }
        public void FindByUserIdTest_Return_Right(int userId, params int[] idCompanysExpected)
        {
            var fakeContext = new FakeContext("FindByAccelerationName");

            fakeContext.FillWith <Company>();
            fakeContext.FillWith <User>();
            fakeContext.FillWith <Candidate>();

            using (var context = new CodenationContext(fakeContext.FakeOptions))
            {
                List <Company> expected = new List <Company>();
                foreach (var id in idCompanysExpected)
                {
                    expected.Add(fakeContext.GetFakeData <Company>().Find(x => x.Id == id));
                }

                var service = new CompanyService(context);
                var actual  = service.FindByUserId(userId).OrderBy(c => c.Id);

                Assert.Equal(expected, actual, new CompanyIdComparer());
            }
        }
Пример #4
0
        public void Should_Be_Right_Candidates_When_Find_By_Company_Id(int companyId)
        {
            var fakeContext = new FakeContext("CandidaterByCompany");

            fakeContext.FillWithAll();

            using (var context = new CodenationContext(fakeContext.FakeOptions))
            {
                var expected = fakeContext.GetFakeData <Company>().
                               Where(company => company.Id == companyId).
                               Join(fakeContext.GetFakeData <Candidate>(),
                                    company => company.Id,
                                    candidate => candidate.CompanyId,
                                    (company, candidate) => candidate).
                               ToList();

                var service = new CandidateService(context);
                var actual  = service.FindByCompanyId(companyId);

                Assert.Equal(expected, actual, new CandidateIdComparer());
            }
        }
        public void Should_Return_Right_Candidate_When_Find_By_Id(int userId, int accelerationId, int companyId)
        {
            var fakeContext = new FakeContext("CandidateById");

            fakeContext.FillWith <Candidate>();
            fakeContext.FillWith <User>();
            fakeContext.FillWith <Company>();
            fakeContext.FillWith <Acceleration>();

            using (var context = new CodenationContext(fakeContext.FakeOptions))
            {
                var expected = fakeContext.GetFakeData <Candidate>()
                               .Find(x => x.UserId == userId &&
                                     x.AccelerationId == accelerationId &&
                                     x.CompanyId == companyId);

                var service = new CandidateService(context);
                var actual  = service.FindById(userId, accelerationId, companyId);

                Assert.Equal(expected, actual, new CandidateIdComparer());
            }
        }
        public void SaveTeste_When_Update_Id_Not_Exist()
        {
            var fakeContext = new FakeContext("UpdateChallengeNotExist");

            fakeContext.FillWith <Models.Challenge>();

            using (var context = new CodenationContext(fakeContext.FakeOptions))
            {
                var expected = new Models.Challenge();
                expected.Id        = 999;
                expected.Name      = "name";
                expected.Slug      = "slug";
                expected.CreatedAt = DateTime.Today;

                var service = new ChallengeService(context);
                var actual  = service.Save(expected);

                Assert.NotEqual(0, actual.Id);
                Assert.Equal(expected.Name, actual.Name);
                Assert.Equal(expected.Slug, actual.Slug);
                Assert.Equal(expected.CreatedAt, actual.CreatedAt);
            }
        }
        public void SaveTeste_When_Update()
        {
            var fakeContext       = new FakeContext("UpdateChallenge");
            int idChallengeUpdate = 1;

            fakeContext.FillWith <Models.Challenge>();

            using (var context = new CodenationContext(fakeContext.FakeOptions))
            {
                var expected = fakeContext.GetFakeData <Models.Challenge>().Find(x => x.Id == idChallengeUpdate);
                expected.Name      = "name";
                expected.Slug      = "slug";
                expected.CreatedAt = DateTime.Today;

                var service = new ChallengeService(context);
                var actual  = service.Save(expected);

                Assert.Equal(expected.Id, actual.Id);
                Assert.Equal(expected.Name, actual.Name);
                Assert.Equal(expected.Slug, actual.Slug);
                Assert.Equal(expected.CreatedAt, actual.CreatedAt);
            }
        }
        public void SaveTeste_When_Update_Id_Not_Exist()
        {
            var fakeContext = new FakeContext("UpdateCompany");

            fakeContext.FillWith <Company>();

            using (var context = new CodenationContext(fakeContext.FakeOptions))
            {
                var fakeCompany = new Company();
                fakeCompany.Id        = 999;
                fakeCompany.Name      = "name";
                fakeCompany.Slug      = "slug";
                fakeCompany.CreatedAt = DateTime.Today;

                var service = new CompanyService(context);
                var actual  = service.Save(fakeCompany);

                Assert.NotEqual(0, actual.Id);
                Assert.Equal(fakeCompany.Name, actual.Name);
                Assert.Equal(fakeCompany.Slug, actual.Slug);
                Assert.Equal(fakeCompany.CreatedAt, actual.CreatedAt);
            }
        }
Пример #9
0
        public void FindByAccelerationNameTest_Return_Right(string nameAcceleration, params int[] idUsersExpected)
        {
            var fakeContext = new FakeContext("FindByAccelerationName");

            fakeContext.FillWith <User>();
            fakeContext.FillWith <Candidate>();
            fakeContext.FillWith <Acceleration>();

            using (var context = new CodenationContext(fakeContext.FakeOptions))
            {
                List <User> expected = new List <User>();
                foreach (var id in idUsersExpected)
                {
                    expected.Add(fakeContext.GetFakeData <User>().Find(x => x.Id == id));
                }

                var service = new UserService(context);
                var actual  = service.FindByAccelerationName(nameAcceleration)
                              .OrderBy(u => u.Id);

                Assert.Equal(expected, actual, new UserIdComparer());
            }
        }
        public void Should_Add_New_Submission_When_Save()
        {
            var fakeContext = new FakeContext("SaveNewSubmission");
            fakeContext.FillWith<Submission>();
            fakeContext.FillWith<User>();
            fakeContext.FillWith<Models.Challenge>();

            var fakeCandidate = new Submission();
            fakeCandidate.UserId = 1;
            fakeCandidate.ChallengeId = 1;
            fakeCandidate.Score = 100;
            fakeCandidate.CreatedAt = DateTime.Today;

            using (var context = new CodenationContext(fakeContext.FakeOptions))
            {
                var service = new SubmissionService(context);
                var actual = service.Save(fakeCandidate);

                Assert.Equal(fakeCandidate, actual, new SubmissionIdComparer());
                Assert.Equal(fakeCandidate.Score, actual.Score);
                Assert.Equal(fakeCandidate.CreatedAt, actual.CreatedAt);
            }
        }
        public void SaveTeste_When_Update_Id_Not_Exist(int userId, int challengeId)
        {
            var fakeContext = new FakeContext("UpdateSubmissionNotExist");
            fakeContext.FillWith<Submission>();
            fakeContext.FillWith<User>();
            fakeContext.FillWith<Models.Challenge>();

            using (var context = new CodenationContext(fakeContext.FakeOptions))
            {
                var fakeCandidate = new Submission();
                fakeCandidate.UserId = userId;
                fakeCandidate.ChallengeId = challengeId;
                fakeCandidate.Score = 100;
                fakeCandidate.CreatedAt = DateTime.Today;

                var service = new SubmissionService(context);
                var actual = service.Save(fakeCandidate);

                Assert.Equal(fakeCandidate, actual, new SubmissionIdComparer());
                Assert.Equal(fakeCandidate.Score, actual.Score);
                Assert.Equal(fakeCandidate.CreatedAt, actual.CreatedAt);
            }
        }
        public void FindByAccelerationIdAndUserIdTest_Return_Right(int accelerationId, int userId
                                                                   , params int[] idChallengesExpected)
        {
            var fakeContext = new FakeContext("indByAccelerationIdAndUserIdTest");

            fakeContext.FillWith <User>();
            fakeContext.FillWith <Acceleration>();
            fakeContext.FillWith <Candidate>();
            fakeContext.FillWith <Models.Challenge>();

            using (var context = new CodenationContext(fakeContext.FakeOptions))
            {
                List <Models.Challenge> expected = new List <Models.Challenge>();
                foreach (var id in idChallengesExpected)
                {
                    expected.Add(fakeContext.GetFakeData <Models.Challenge>().Find(x => x.Id == id));
                }

                var service = new ChallengeService(context);
                var actual  = service.FindByAccelerationIdAndUserId(accelerationId, userId);

                Assert.Equal(expected, actual, new ChallengeIdComparer());
            }
        }