public void Should_Be_Right_Users_When_Find_By_Accelaration_Name(string accelerationName) { var fakeContext = new FakeContext("UserByAcceleration"); fakeContext.FillWithAll(); using (var context = new CodenationContext(fakeContext.FakeOptions)) { var expected = fakeContext.GetFakeData <Acceleration>(). Where(acceleration => acceleration.Name == accelerationName). Join(fakeContext.GetFakeData <Candidate>(), acceleration => acceleration.Id, candidate => candidate.AccelerationId, (acceleration, candidate) => candidate). Join(fakeContext.GetFakeData <User>(), candidate => candidate.UserId, user => user.Id, (candidate, user) => user). Distinct(). ToList(); var service = new UserService(context); var actual = service.FindByAccelerationName(accelerationName); Assert.Equal(expected, actual, new UserIdComparer()); } }
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 Should_Be_Right_Users_When_Find_By_Company_Id(int companyId) { var fakeContext = new FakeContext("UserByCompany"); 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). Join(fakeContext.GetFakeData <User>(), candidate => candidate.UserId, user => user.Id, (candidate, user) => user). Distinct(). ToList(); var service = new UserService(context); var actual = service.FindByCompanyId(companyId); Assert.Equal(expected, actual, new UserIdComparer()); } }
public void Should_Be_Right_Companies_When_Find_By_Accelaration_Id(int accelerationId) { var fakeContext = new FakeContext("CompanyByAcceleration"); 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). Join(fakeContext.GetFakeData <Company>(), candidate => candidate.CompanyId, company => company.Id, (candidate, company) => company). Distinct(). ToList(); var service = new CompanyService(context); var actual = service.FindByAccelerationId(accelerationId); Assert.Equal(expected, actual, new CompanyIdComparer()); } }
public void Should_Update_The_User_When_Save() { var fakeContext = new FakeContext("SaveUser"); fakeContext.FillWithAll(); var expected = fakeContext.GetFakeData <User>().First(); expected.FullName = "new value"; expected.Email = "new value"; expected.Nickname = "new value"; expected.Password = "******"; using (var context = new CodenationContext(fakeContext.FakeOptions)) { var service = new UserService(context); var actual = service.Save(expected); Assert.Equal(expected.Id, actual.Id); Assert.Equal(expected.FullName, actual.FullName); Assert.Equal(expected.Nickname, actual.Nickname); Assert.Equal(expected.Email, actual.Email); Assert.Equal(expected.Password, actual.Password); } }
public void Should_Be_Right_Challenges_When_Find_By_Accelartion_And_User(int accelerationId, int userId) { var fakeContext = new FakeContext("ChallengeByAccelerationAndUser"); fakeContext.FillWithAll(); using (var context = new CodenationContext(fakeContext.FakeOptions)) { var expected = fakeContext.GetFakeData <User>(). Where(user => user.Id == userId). Join(fakeContext.GetFakeData <Candidate>(), user => user.Id, candidate => candidate.UserId, (user, candidate) => candidate). Join(fakeContext.GetFakeData <Acceleration>(), candidate => candidate.AccelerationId, acceleration => acceleration.Id, (candidate, acceleration) => acceleration). Where(acceleration => acceleration.Id == accelerationId). Join(fakeContext.GetFakeData <Models.Challenge>(), acceleration => acceleration.ChallengeId, challenge => challenge.Id, (acceleration, challenge) => challenge). Distinct(). ToList(); var service = new ChallengeService(context); var actual = service.FindByAccelerationIdAndUserId(userId, accelerationId); Assert.Equal(expected, actual, new ChallengeIdComparer()); } }
public CompanyServiceTest() { _contextoFake = new FakeContext("CompanyTest"); _contextoFake.FillWithAll(); _contexto = new CodenationContext(_contextoFake.FakeOptions); _companyService = new CompanyService(_contexto); }
public UserServiceTest() { _contextoFake = new FakeContext("UserTest"); _contextoFake.FillWithAll(); _contexto = new CodenationContext(_contextoFake.FakeOptions); _userService = new UserService(_contexto); }
public SubmissionServiceTest() { _contextoFake = new FakeContext("SubmissionTest"); _contextoFake.FillWithAll(); _contexto = new CodenationContext(_contextoFake.FakeOptions); _submissionService = new SubmissionService(_contexto); }
public ChallengeServiceTest() { _contextoFake = new FakeContext("ChallengeService"); _contextoFake.FillWithAll(); _contexto = new CodenationContext(_contextoFake.FakeOptions); _challengeService = new ChallengeService(_contexto); }
public CandidateServiceTest() { _contextoFake = new FakeContext("CandidateTest"); _contextoFake.FillWithAll(); _contexto = new CodenationContext(_contextoFake.FakeOptions); _candidateService = new CandidateService(_contexto); }
public void Should_Be_Right_Users_When_Find_By_Accelaration_Name(string accelerationName) { var fakeContext = new FakeContext("UserById"); fakeContext.FillWithAll(); using (var context = new CodenationContext(fakeContext.FakeOptions)) { var expected = fakeContext.GetFakeData <User>().FindAll(x => x.FullName == accelerationName); var service = new UserService(context); var actual = service.FindByAccelerationName(accelerationName); Assert.Equal(expected, actual, new UserIdComparer()); } }
public void Should_Be_Right_Candidate_When_Find_By_Id(int userId, int AccelerationId, int CompanyId) { var fakeContext = new FakeContext("CandidateById"); fakeContext.FillWithAll(); 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 Should_Be_Higher_Score_When_Get_By_Challenge_Id(int challengeId) { var fakeContext = new FakeContext("HigherSubmissionByChallenge"); fakeContext.FillWithAll(); using (var context = new CodenationContext(fakeContext.FakeOptions)) { var expected = fakeContext.GetFakeData <Submission>(). Where(challenge => challenge.ChallengeId == challengeId). Max(challenge => challenge.Score); var service = new SubmissionService(context); var actual = service.FindHigherScoreByChallengeId(challengeId); Assert.Equal(expected, actual); } }
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); } }