Exemplo n.º 1
0
        private void GetAuditTeamsAndRelatedTest()
        {
            using (var context = new Context())
            {
                var auditTeamRepository = new AuditTeamRepository(context);
                context.Database.Log = (message) => Debug.WriteLine(message);

                Assert.Throws <NotImplementedException>(() => auditTeamRepository.GetList());
            }
        }
Exemplo n.º 2
0
        private void AddTest()
        {
            using (var context = new Context())
            {
                var auditTeamRepository = new AuditTeamRepository(context);
                context.Database.Log = (message) => Debug.WriteLine(message);

                auditTeamRepository.Add(_auditTeamDataMock.AuditTeam);

                Assert.AreNotEqual(Guid.Empty, _auditTeamDataMock.AuditTeamId, "Empty guid was return");
            }
        }
Exemplo n.º 3
0
        private void GetAuditTeamAndRelatedTest()
        {
            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(_auditTeamDataMock.AuditTeamId, downloadedAuditTeam.Id, "GetAuditTeamAndRelatedTest returns audit team with different guid");
                Assert.IsNotNull(downloadedAuditTeam.Project, "GetAuditTeamAndRelatedTest does not returns related projects");
                Assert.IsNotNull(downloadedAuditTeam.Auditor, "GetAuditTeamAndRelatedTest does not returns related auditors");
            }
        }
Exemplo n.º 4
0
        private void DeleteTest()
        {
            using (var context = new Context())
            {
                var auditTeamRepository = new AuditTeamRepository(context);
                context.Database.Log = (message) => Debug.WriteLine(message);

                var downloadedAuditTeam = auditTeamRepository.Get(_auditTeamDataMock.AuditTeamId);
                var id = downloadedAuditTeam.Id;
                Assert.IsNotNull(downloadedAuditTeam, "AuditTeam does not exist before delete.");

                auditTeamRepository.Delete(downloadedAuditTeam);

                downloadedAuditTeam = auditTeamRepository.Get(id);
                Assert.IsNull(downloadedAuditTeam, "AuditTeam exists after delete.");
            }
        }
Exemplo n.º 5
0
        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);
            }
        }