private void UpdateTest() { var newProject = new ProjectDataMock(); using (var context = new Context()) { var projectsRepository = new ProjectsRepository(context); context.Database.Log = (message) => Debug.WriteLine(message); var userStore = new UserStore <User>(context); var userManager = new ApplicationUserManager(userStore); var randomUser = UserGenerator.GenerateUser(); userManager.Create(randomUser, UserGenerator.RandomString()); newProject.Project.UserId = randomUser.Id; newProject.Project.User = randomUser; projectsRepository.Add(newProject.Project); _auditTeamDataMock.AuditTeam.ProjectId = newProject.ProjectId; _auditTeamDataMock.AuditTeam.AuditorId = newProject.Project.Auditors.First().AuditorId; } using (var context = new Context()) { var auditTeamRepository = new AuditTeamRepository(context); context.Database.Log = (message) => Debug.WriteLine(message); auditTeamRepository.Update(_auditTeamDataMock.AuditTeam); } using (var context = new Context()) { var auditTeamRepository = new AuditTeamRepository(context); context.Database.Log = (message) => Debug.WriteLine(message); var downloadedAuditTeam = auditTeamRepository.Get(_auditTeamDataMock.AuditTeamId); Assert.AreEqual(newProject.ProjectId, downloadedAuditTeam.ProjectId); Assert.AreEqual(newProject.Project.Auditors.First().AuditorId, downloadedAuditTeam.AuditorId); } }
private void AddTest() { using (var context = new Context()) { var auditorsRepository = new AuditorsRepository(context); context.Database.Log = (message) => Debug.WriteLine(message); var userStore = new UserStore <User>(context); var userManager = new ApplicationUserManager(userStore); var randomUser = UserGenerator.GenerateUser(); userManager.Create(randomUser, UserGenerator.RandomString()); _auditorDataMock.Auditor.Projects.First().Project.UserId = randomUser.Id; _auditorDataMock.Auditor.Projects.First().Project.User = randomUser; auditorsRepository.Add(_auditorDataMock.Auditor); Assert.AreNotEqual(Guid.Empty, _auditorDataMock.AuditorId, "Empty guid was return"); } }
private void InitData() { using (var context = new Context()) { var projectsRepository = new ProjectsRepository(context); context.Database.Log = (message) => Debug.WriteLine(message); var project = new ProjectDataMock(); var userStore = new UserStore <User>(context); var userManager = new ApplicationUserManager(userStore); var randomUser = UserGenerator.GenerateUser(); userManager.Create(randomUser, UserGenerator.RandomString()); project.Project.UserId = randomUser.Id; project.Project.User = randomUser; projectsRepository.Add(project.Project); _auditTeamDataMock = new AuditTeamDataMock(project.ProjectId, project.Project.Auditors.First().AuditorId); } }