public void SaveTeste_When_Update() { var fakeContext = new FakeContext("UpdateAcceleration"); int idAccelerationUpdate = 1; fakeContext.FillWith <Acceleration>(); fakeContext.FillWith <Models.Challenge>(); using (var context = new CodenationContext(fakeContext.FakeOptions)) { var expected = fakeContext.GetFakeData <Acceleration>().Find(x => x.Id == idAccelerationUpdate); expected.Name = "name"; expected.Slug = "slug"; expected.ChallengeId = 1; expected.CreatedAt = DateTime.Today; var service = new AccelerationService(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.ChallengeId, actual.ChallengeId); Assert.Equal(expected.CreatedAt, actual.CreatedAt); } }
public void SaveTeste_When_Update(int userId, int challengeId) { var fakeContext = new FakeContext("UpdateSubmission"); fakeContext.FillWith<Submission>(); fakeContext.FillWith<User>(); fakeContext.FillWith<Models.Challenge>(); using (var context = new CodenationContext(fakeContext.FakeOptions)) { var expected = fakeContext.GetFakeData<Submission>() .Find(x => x.UserId == userId && x.ChallengeId == challengeId); expected.UserId = 1; expected.ChallengeId = 2; expected.Score = 100; expected.CreatedAt = DateTime.Today; var service = new SubmissionService(context); var actual = service.Save(expected); Assert.Equal(expected, actual); Assert.Equal(expected.Score, actual.Score); Assert.Equal(expected.CreatedAt, actual.CreatedAt); } }
public void FindByCompanyIdTest_Return_Right(int companyId, params int[] idAccelerationExpected) { var fakeContext = new FakeContext("AccelerationFindByCompanyId"); fakeContext.FillWith <Candidate>(); fakeContext.FillWith <Acceleration>(); using (var context = new CodenationContext(fakeContext.FakeOptions)) { List <Acceleration> expected = new List <Acceleration>(); foreach (var id in idAccelerationExpected) { var expectedData = fakeContext.GetFakeData <Acceleration>().Find(x => x.Id == id); if (!(expectedData is null)) { expected.Add(fakeContext.GetFakeData <Acceleration>().Find(x => x.Id == id)); } } var service = new AccelerationService(context); var actual = service.FindByCompanyId(companyId); Assert.Equal(expected, actual, new AccelerationIdComparer()); } }
public void SaveTeste_When_Update_Id_Not_Exist(int userId, int accelerationId, int companyId) { var fakeContext = new FakeContext("UpdateCandidateNotExist"); fakeContext.FillWith <Candidate>(); fakeContext.FillWith <User>(); fakeContext.FillWith <Company>(); fakeContext.FillWith <Acceleration>(); using (var context = new CodenationContext(fakeContext.FakeOptions)) { var fakeCandidate = new Candidate(); fakeCandidate.UserId = userId; fakeCandidate.AccelerationId = accelerationId; fakeCandidate.CompanyId = companyId; fakeCandidate.Status = 1; fakeCandidate.CreatedAt = DateTime.Today; var service = new CandidateService(context); var actual = service.Save(fakeCandidate); Assert.Equal(fakeCandidate, actual, new CandidateIdComparer()); Assert.Equal(fakeCandidate.Status, actual.Status); Assert.Equal(fakeCandidate.CreatedAt, actual.CreatedAt); } }
public void SaveTeste_When_Update(int userId, int accelerationId, int companyId) { var fakeContext = new FakeContext("UpdateCandidate"); 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); expected.UserId = 1; expected.AccelerationId = 1; expected.CompanyId = 3; expected.Status = 1; expected.CreatedAt = DateTime.Today; var service = new CandidateService(context); var actual = service.Save(expected); Assert.Equal(expected, actual); Assert.Equal(expected.Status, actual.Status); Assert.Equal(expected.CreatedAt, actual.CreatedAt); } }
public void Should_Add_New_Candidate_When_Save() { var fakeContext = new FakeContext("SaveNewCandidate"); fakeContext.FillWith <Candidate>(); fakeContext.FillWith <User>(); fakeContext.FillWith <Company>(); fakeContext.FillWith <Acceleration>(); var fakeCandidate = new Candidate(); fakeCandidate.UserId = 1; fakeCandidate.AccelerationId = 1; fakeCandidate.CompanyId = 2; fakeCandidate.Status = 1; fakeCandidate.CreatedAt = DateTime.Today; using (var context = new CodenationContext(fakeContext.FakeOptions)) { var service = new CandidateService(context); var actual = service.Save(fakeCandidate); Assert.Equal(fakeCandidate, actual, new CandidateIdComparer()); Assert.Equal(fakeCandidate.Status, actual.Status); Assert.Equal(fakeCandidate.CreatedAt, actual.CreatedAt); } }
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 SaveTeste_When_Update_Id_Not_Exist() { var fakeContext = new FakeContext("UpdateAccelerationNotExists"); fakeContext.FillWith <Acceleration>(); fakeContext.FillWith <Models.Challenge>(); using (var context = new CodenationContext(fakeContext.FakeOptions)) { var expected = new Acceleration(); expected.Id = -1; expected.Name = "name"; expected.Slug = "slug"; expected.ChallengeId = 1; expected.CreatedAt = DateTime.Today; var service = new AccelerationService(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.ChallengeId, actual.ChallengeId); Assert.Equal(expected.CreatedAt, actual.CreatedAt); } }
public void FindHigherScoreByChallengeIdTeste_Return_Right(int challengeId, decimal expectedMaxScore) { var fakeContext = new FakeContext("FindHigherScoreByChallengeId"); fakeContext.FillWith<Submission>(); fakeContext.FillWith<Models.Challenge>(); using (var context = new CodenationContext(fakeContext.FakeOptions)) { var service = new SubmissionService(context); var actual = service.FindHigherScoreByChallengeId(challengeId); Assert.Equal(expectedMaxScore, actual); } }
public void FindByCompanyIdTest_Return_Right(int companyId, params string[] idCandidatesExpected) { var fakeContext = new FakeContext("Candidate_FindByCompanyId"); fakeContext.FillWith <Candidate>(); using (var context = new CodenationContext(fakeContext.FakeOptions)) { List <Candidate> expected = new List <Candidate>(); foreach (var idCandidate in idCandidatesExpected) { var idCandidateInt = idCandidate.Split(',').Select(x => int.Parse(x)).ToList(); expected.Add(fakeContext .GetFakeData <Candidate>() .Find(x => x.UserId == idCandidateInt[0] && x.AccelerationId == idCandidateInt[1] && x.CompanyId == idCandidateInt[2])); } var service = new CandidateService(context); var actual = service.FindByCompanyId(companyId); Assert.Equal(expected, actual, new CandidateIdComparer()); } }
public void SaveTeste_When_Update() { var fakeContext = new FakeContext("UpdateUser"); int idUserUpdate = 1; fakeContext.FillWith <User>(); using (var context = new CodenationContext(fakeContext.FakeOptions)) { var expected = fakeContext.GetFakeData <User>().Find(x => x.Id == idUserUpdate); expected.FullName = "full name"; expected.Email = "email"; expected.Nickname = "nickname"; expected.Password = "******"; expected.CreatedAt = DateTime.Today; 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.Email, actual.Email); Assert.Equal(expected.Nickname, actual.Nickname); Assert.Equal(expected.Password, actual.Password); Assert.Equal(expected.CreatedAt, actual.CreatedAt); } }
public void SaveTeste_When_Update_Id_Not_Exist() { var fakeContext = new FakeContext("UpdateUser"); fakeContext.FillWith <User>(); using (var context = new CodenationContext(fakeContext.FakeOptions)) { var expected = new User(); expected.Id = 999; expected.FullName = "full name"; expected.Email = "email"; expected.Nickname = "nickname"; expected.Password = "******"; expected.CreatedAt = DateTime.Today; var service = new UserService(context); var actual = service.Save(expected); Assert.NotEqual(0, actual.Id); Assert.Equal(expected.FullName, actual.FullName); Assert.Equal(expected.Email, actual.Email); Assert.Equal(expected.Nickname, actual.Nickname); Assert.Equal(expected.Password, actual.Password); Assert.Equal(expected.CreatedAt, actual.CreatedAt); } }
public void Should_Add_New_Acceleration_When_Save() { var fakeContext = new FakeContext("SaveNewAcceleration"); fakeContext.FillWith <Models.Challenge>(); var fakeAcceleration = new Acceleration(); fakeAcceleration.Name = "name"; fakeAcceleration.Slug = "slug"; fakeAcceleration.ChallengeId = 1; fakeAcceleration.CreatedAt = DateTime.Today; using (var context = new CodenationContext(fakeContext.FakeOptions)) { var service = new AccelerationService(context); var actual = service.Save(fakeAcceleration); Assert.NotEqual(0, actual.Id); Assert.Equal(fakeAcceleration.Name, actual.Name); Assert.Equal(fakeAcceleration.Slug, actual.Slug); Assert.Equal(fakeAcceleration.ChallengeId, actual.ChallengeId); Assert.Equal(fakeAcceleration.CreatedAt, actual.CreatedAt); } }
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()); } }
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 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()); } }
public void Should_Return_By_Acceleration_Name(string name, int[] usersIds) { var fakeContext = new FakeContext("UserByAccelerationName"); fakeContext.FillWith <User>(); using (var context = new CodenationContext(new Microsoft.EntityFrameworkCore.DbContextOptions <CodenationContext>())) { var expected = fakeContext.GetFakeData <User>().Where(x => usersIds.Contains(x.Id)).ToList(); var service = new UserService(context); var actual = service.FindByAccelerationName(name); Assert.Equal(expected, actual, new UserIdComparer()); } }
public void Should_Return_Right_User_When_Find_By_Id(int id) { var fakeContext = new FakeContext("UserById"); fakeContext.FillWith <User>(); using (var context = new CodenationContext(fakeContext.FakeOptions)) { var expected = fakeContext.GetFakeData <User>().Find(x => x.Id == id); var service = new UserService(context); var actual = service.FindById(id); Assert.Equal(expected, actual, new UserIdComparer()); } }
public void Should_Be_Right_Acceleration_When_Find_By_Id(int id) { var fakeContext = new FakeContext("AccelerationById"); fakeContext.FillWith <Acceleration>(); using (var context = new CodenationContext(fakeContext.FakeOptions)) { var expected = fakeContext.GetFakeData <Acceleration>().Find(x => x.Id == id); var service = new AccelerationService(context); var actual = service.FindById(id); Assert.Equal(expected, actual, new AccelerationIdComparer()); } }
public void Should_Update_The_Sumission_When_Save() { var fakeContext = new FakeContext("SaveSubmission"); fakeContext.FillWith <Submission>(); var expected = fakeContext.GetFakeData <Submission>().First(); expected.Score = 99.9M; using (var context = new CodenationContext(fakeContext.FakeOptions)) { var service = new SubmissionService(context); var actual = service.Save(expected); Assert.Equal(expected, actual, new SubmissionIdComparer()); Assert.Equal(expected.Score, actual.Score); } }
public void Should_Update_The_Candidate_When_Save() { var fakeContext = new FakeContext("SaveCandidate"); fakeContext.FillWith <Candidate>(); var expected = fakeContext.GetFakeData <Candidate>().First(); expected.Status = 999; using (var context = new CodenationContext(fakeContext.FakeOptions)) { var service = new CandidateService(context); var actual = service.Save(expected); Assert.Equal(expected, actual, new CandidateIdComparer()); Assert.Equal(expected.Status, actual.Status); } }
public void Should_Update_The_Acceleration_When_Save() { var fakeContext = new FakeContext("SaveAcceleration"); fakeContext.FillWith <Acceleration>(); var expected = fakeContext.GetFakeData <Acceleration>().First(); expected.Name = "new value"; expected.Slug = "new value"; using (var context = new CodenationContext(fakeContext.FakeOptions)) { var service = new AccelerationService(context); var actual = service.Save(expected); Assert.Equal(expected.Id, actual.Id); Assert.Equal(expected.Name, actual.Name); Assert.Equal(expected.Slug, actual.Slug); } }
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); } }