public List <Note> RetrieveAllNotes()
 {
     using (PlannerContext pc = new PlannerContext())
     {
         return(pc.Notes.ToList());
     }
 }
コード例 #2
0
 public List <Feature> RetrieveAllFeatures()
 {
     using (PlannerContext pc = new PlannerContext())
     {
         return(pc.Features.ToList());
     }
 }
コード例 #3
0
        public void MakeSureThatTheNoteIsNotReturnedWhenAttemptedToSearchForAnUnrelatedString()
        {
            using (PlannerContext pc = new PlannerContext())
            {
                Note _testNote = new Note()
                {
                    Title = "TestNote",
                    Body  = "A test note",
                };

                pc.Notes.Add(_testNote);

                pc.SaveChanges();

                List <Note> _foundNotes = _searcher.SearchNotes("I can't find the note");

                string _title = "";
                string _body  = "";

                foreach (var item in _foundNotes)
                {
                    _title = item.Title;
                    _body  = item.Body;
                }

                Assert.Multiple(() =>
                {
                    Assert.AreEqual("", _title);
                    Assert.AreEqual("", _body);

                    Assert.IsEmpty(_foundNotes);
                });
            }
        }
コード例 #4
0
        public void WhenANewNoteIsAddedTheDetailsAreCorrect()
        {
            using (PlannerContext pc = new PlannerContext())
            {
                _crudNoteManager.CreateNewNote("TestNote", "A test note");

                var _noteDetails =
                    from n in pc.Notes
                    where n.Title == "TestNote"
                    select n;

                string _title = "", _body = "";

                foreach (var item in _noteDetails)
                {
                    _title = item.Title;
                    _body  = item.Body;
                }

                Assert.Multiple(() =>
                {
                    Assert.AreEqual("TestNote", _title);
                    Assert.AreEqual("A test note", _body);
                });
            }
        }
        public void WhenAProjectIsSelectedMakeSureTheInformationIsCorrect()
        {
            using (PlannerContext pc = new PlannerContext())
            {
                Project _testProj = new Project()
                {
                    Title       = "TestProj",
                    Description = "A blank test project",
                    Status      = 1,
                    Link        = "No Link"
                };

                pc.Projects.Add(_testProj);

                pc.SaveChanges();

                _crudProjectManager.SetSelectedProject(_testProj);

                Assert.Multiple(() =>
                {
                    Assert.AreEqual("TestProj", _crudProjectManager.SelectedProject.Title);
                    Assert.AreEqual("A blank test project", _crudProjectManager.SelectedProject.Description);
                    Assert.AreEqual(1, _crudProjectManager.SelectedProject.Status);
                    Assert.AreEqual("No Link", _crudProjectManager.SelectedProject.Link);
                });
            }
        }
コード例 #6
0
        public void WhenNothingHasChangedWhenUpdateIsCalledEnsureTheInformationHasNotChanged()
        {
            using (PlannerContext pc = new PlannerContext())
            {
                Note _testNote = new Note()
                {
                    Title = "TestNote",
                    Body  = "A test note",
                };

                pc.Notes.Add(_testNote);

                pc.SaveChanges();

                int _key = _testNote.NoteId;

                _crudNoteManager.SelectedNote = _testNote;

                _crudNoteManager.UpdateNote("TestNote", "A test note");

                Assert.Multiple(() =>
                {
                    Assert.AreEqual("TestNote", _crudNoteManager.SelectedNote.Title);
                    Assert.AreEqual("A test note", _crudNoteManager.SelectedNote.Body);
                    Assert.AreEqual(_key, _crudNoteManager.SelectedNote.NoteId);
                });
            }
        }
        public void TearDown()
        {
            using (PlannerContext pc = new PlannerContext())
            {
                var _selectedIssue =
                    from i in pc.Issues
                    where i.Title == "TestIssue"
                    select i;

                var _selectedProject =
                    from p in pc.Projects
                    where p.Title == "temp"
                    select p;

                var _secondProject =
                    from p in pc.Projects
                    where p.Title == "temp2"
                    select p;

                pc.Projects.RemoveRange(_selectedProject);
                pc.Projects.RemoveRange(_secondProject);
                pc.Issues.RemoveRange(_selectedIssue);

                pc.SaveChanges();
            }
        }
        public void WhenAProjectIsDeletedMakeSureTheIssuesAreRemovedFromTheDatabase()
        {
            using (PlannerContext pc = new PlannerContext())
            {
                Issue _testIssue = new Issue()
                {
                    Title       = "TestIssue",
                    Description = "This is a test issue",
                    Status      = 1,
                    Priority    = 1,
                    Notes       = "No notes needed",
                    ProjectId   = _crudProjectManager.SelectedProject.ProjectId
                };

                pc.Issues.Add(_testIssue);

                pc.SaveChanges();

                int _key = _testIssue.IssueId;

                _crudIssueManager.SelectedIssue = _testIssue;

                _crudProjectManager.DeleteProject();

                var _containsDeleted =
                    from i in pc.Issues
                    where i.IssueId == _key
                    select i;

                Assert.IsEmpty(_containsDeleted);
            }
        }
        public void WhenUpdatingMultiplePropertiesOfAnIssueEnsureTheInformationHasBeenUpdated()
        {
            using (PlannerContext pc = new PlannerContext())
            {
                Issue _testIssue = new Issue()
                {
                    Title       = "TestIssue",
                    Description = "This is a test issue",
                    Status      = 1,
                    Priority    = 1,
                    Notes       = "No notes needed",
                    ProjectId   = _crudProjectManager.SelectedProject.ProjectId
                };

                pc.Issues.Add(_testIssue);

                pc.SaveChanges();

                int _key = _testIssue.IssueId;

                _crudIssueManager.SelectedIssue = _testIssue;

                _crudIssueManager.UpdateIssue("TestIssue", "This is an updated test issue", 2, 2, "No notes here");

                Assert.Multiple(() =>
                {
                    Assert.AreEqual("TestIssue", _crudIssueManager.SelectedIssue.Title);
                    Assert.AreEqual("This is an updated test issue", _crudIssueManager.SelectedIssue.Description);
                    Assert.AreEqual(2, _crudIssueManager.SelectedIssue.Status);
                    Assert.AreEqual(2, _crudIssueManager.SelectedIssue.Priority);
                    Assert.AreEqual("No notes here", _crudIssueManager.SelectedIssue.Notes);
                    Assert.AreEqual(_key, _crudIssueManager.SelectedIssue.IssueId);
                });
            }
        }
        public void WhenNothingHasChangedWhenUpdateIsCalledEnsureTheInformationHasNotChanged()
        {
            using (PlannerContext pc = new PlannerContext())
            {
                Project _testProj = new Project()
                {
                    Title       = "TestProj",
                    Description = "A blank test project",
                    Status      = 1,
                    Link        = "No Link"
                };

                pc.Projects.Add(_testProj);

                pc.SaveChanges();

                int _key = _testProj.ProjectId;

                _crudProjectManager.SelectedProject = _testProj;

                _crudProjectManager.UpdateProject("TestProj", "A blank test project", 1, "No Link");

                Assert.Multiple(() =>
                {
                    Assert.AreEqual("TestProj", _crudProjectManager.SelectedProject.Title);
                    Assert.AreEqual("A blank test project", _crudProjectManager.SelectedProject.Description);
                    Assert.AreEqual(1, _crudProjectManager.SelectedProject.Status);
                    Assert.AreEqual("No Link", _crudProjectManager.SelectedProject.Link);
                    Assert.AreEqual(_key, _crudProjectManager.SelectedProject.ProjectId);
                });
            }
        }
コード例 #11
0
        public void WhenAProjectIsDeletedMakeSureTheFeaturesAreRemovedFromTheDatabase()
        {
            using (PlannerContext pc = new PlannerContext())
            {
                Feature _testFeat = new Feature()
                {
                    Title       = "TestFeat",
                    Description = "This is a test feature",
                    Status      = 1,
                    Priority    = 1,
                    Notes       = "No notes needed",
                    ProjectId   = _crudProjectManager.SelectedProject.ProjectId
                };

                pc.Features.Add(_testFeat);

                pc.SaveChanges();

                int _key = _testFeat.FeatureId;

                _crudFeatureManager.SelectedFeature = _testFeat;

                _crudProjectManager.DeleteProject();

                var _containsDeleted =
                    from f in pc.Features
                    where f.FeatureId == _key
                    select f;

                Assert.IsEmpty(_containsDeleted);
            }
        }
        public void WhenUpdatingMultiplePropertiesOfAProjectEnsureTheInformationHasBeenUpdated()
        {
            using (PlannerContext pc = new PlannerContext())
            {
                Project _testProj = new Project()
                {
                    Title       = "TestProj",
                    Description = "A blank test project",
                    Status      = 1,
                    Link        = "No Link"
                };

                pc.Projects.Add(_testProj);

                pc.SaveChanges();

                int _key = _testProj.ProjectId;

                _crudProjectManager.SelectedProject = _testProj;

                _crudProjectManager.UpdateProject("TestProj", "I've updated this test project", 3, "www.google.com");

                Assert.Multiple(() =>
                {
                    Assert.AreEqual("TestProj", _crudProjectManager.SelectedProject.Title);
                    Assert.AreEqual("I've updated this test project", _crudProjectManager.SelectedProject.Description);
                    Assert.AreEqual(3, _crudProjectManager.SelectedProject.Status);
                    Assert.AreEqual("www.google.com", _crudProjectManager.SelectedProject.Link);
                    Assert.AreEqual(_key, _crudProjectManager.SelectedProject.ProjectId);
                });
            }
        }
コード例 #13
0
        public void WhenANewFeatureIsAddedTheDetailsAreCorrect()
        {
            using (PlannerContext pc = new PlannerContext())
            {
                _crudFeatureManager.CreateNewFeature("TestFeat", "This is a test feature", 1, 1, "No notes needed", _crudProjectManager);

                var _featureDetails =
                    from f in pc.Features
                    where f.Title == "TestFeat"
                    select f;

                string _title = "", _description = "", _notes = "";
                int    _status = -5, _priority = -5;

                foreach (var item in _featureDetails)
                {
                    _title       = item.Title;
                    _description = item.Description;
                    _status      = item.Status;
                    _priority    = item.Priority;
                    _notes       = item.Notes;
                }

                Assert.Multiple(() =>
                {
                    Assert.AreEqual("TestFeat", _title);
                    Assert.AreEqual("This is a test feature", _description);
                    Assert.AreEqual(1, _status);
                    Assert.AreEqual(1, _priority);
                    Assert.AreEqual("No notes needed", _notes);
                });
            }
        }
コード例 #14
0
        public void WhenANoteIsDeletedMakeSureItIsRemovedFromTheDatabase()
        {
            using (PlannerContext pc = new PlannerContext())
            {
                Note _testNote = new Note()
                {
                    Title = "TestNote",
                    Body  = "A test note",
                };

                pc.Notes.Add(_testNote);

                pc.SaveChanges();

                int _key = _testNote.NoteId;

                _crudNoteManager.SelectedNote = _testNote;

                _crudNoteManager.DeleteNote();

                var _containsDeleted =
                    from n in pc.Notes
                    where n.NoteId == _key
                    select n;

                Assert.IsEmpty(_containsDeleted);
            }
        }
        public void AddAnIssueAndCheckThatTheExportMethodHasExportedAJSONFile()
        {
            using (PlannerContext pc = new PlannerContext())
            {
                Issue _testIssue = new Issue()
                {
                    Title       = "TestIssue",
                    Description = "This is a test issue",
                    Status      = 1,
                    Priority    = 1,
                    Notes       = "No notes needed",
                    ProjectId   = _crudProjectManager.SelectedProject.ProjectId
                };

                pc.Issues.Add(_testIssue);

                pc.SaveChanges();

                _jsonExporter.InitSerialisation();

                _jsonExporter.SerialiseIssues();

                FileAssert.Exists(@"C:\Users\Alex\Documents\Engineering 73\Entity Framework Project\Entity-Framework-Project-Planner\ProjectPlanner\ProjectPlannerTESTS\bin\Debug\netcoreapp3.1\JSON Export\Issues.json");
            }
        }
        public void AddAFeatureAndCheckThatTheExportMethodHasExportedAXMLFile()
        {
            using (PlannerContext pc = new PlannerContext())
            {
                Feature _testFeat = new Feature()
                {
                    Title       = "TestFeat",
                    Description = "This is a test feature",
                    Status      = 2,
                    Priority    = 1,
                    Notes       = "No notes needed",
                    ProjectId   = _crudProjectManager.SelectedProject.ProjectId
                };

                pc.Features.Add(_testFeat);

                pc.SaveChanges();

                _xmlExporter.InitSerialisation();

                _xmlExporter.SerialiseFeatures();

                FileAssert.Exists(@"C:\Users\Alex\Documents\Engineering 73\Entity Framework Project\Entity-Framework-Project-Planner\ProjectPlanner\ProjectPlannerTESTS\bin\Debug\netcoreapp3.1\XML Export\Features.xml");
            }
        }
コード例 #17
0
        public void WhenAListOfIssuesIsRetrievedMakeSureItIsNotEmptyIfThereAreIssuesInTheDatabase()
        {
            using (PlannerContext pc = new PlannerContext())
            {
                Issue _testIssue = new Issue()
                {
                    Title       = "TestIssue",
                    Description = "This is a test issue",
                    Status      = 1,
                    Priority    = 1,
                    Notes       = "No notes needed",
                    ProjectId   = _crudProjectManager.SelectedProject.ProjectId
                };

                pc.Issues.Add(_testIssue);

                pc.SaveChanges();

                List <Issue> _issueList = new List <Issue>();

                _issueList = _crudIssueManager.RetrieveAllIssues();

                Assert.IsNotEmpty(_issueList);
            }
        }
        public void WhenANewProjectIsAddedTheDetailsAreCorrect()
        {
            using (PlannerContext pc = new PlannerContext())
            {
                _crudProjectManager.CreateNewProject("TestProj", "A blank test project", 0, "No link");

                var _projectDetails =
                    from p in pc.Projects
                    where p.Title == "TestProj"
                    select p;

                string _title = "", _description = "", _link = "";
                int    _status = -5;

                foreach (var item in _projectDetails)
                {
                    _title       = item.Title;
                    _description = item.Description;
                    _status      = item.Status;
                    _link        = item.Link;
                }

                Assert.Multiple(() =>
                {
                    Assert.AreEqual("TestProj", _title);
                    Assert.AreEqual("A blank test project", _description);
                    Assert.AreEqual(0, _status);
                    Assert.AreEqual("No link", _link);
                });
            }
        }
        public void WhenAProjectIsDeletedMakeSureItIsRemovedFromTheDatabase()
        {
            using (PlannerContext pc = new PlannerContext())
            {
                Project _testProj = new Project()
                {
                    Title       = "TestProj",
                    Description = "A blank test project",
                    Status      = 1,
                    Link        = "No Link"
                };

                pc.Projects.Add(_testProj);

                pc.SaveChanges();

                int _key = 0;

                _crudProjectManager.SelectedProject = _testProj;

                _crudProjectManager.DeleteProject();

                var _containsDeleted =
                    from p in pc.Projects
                    where p.ProjectId == _key
                    select p;

                Assert.IsEmpty(_containsDeleted);
            }
        }
コード例 #20
0
        public void WhenNothingHasChangedWhenUpdateIsCalledEnsureTheInformationHasNotChanged()
        {
            using (PlannerContext pc = new PlannerContext())
            {
                Feature _testFeat = new Feature()
                {
                    Title       = "TestFeat",
                    Description = "This is a test feature",
                    Status      = 1,
                    Priority    = 1,
                    Notes       = "No notes needed",
                    ProjectId   = _crudProjectManager.SelectedProject.ProjectId
                };

                pc.Features.Add(_testFeat);

                pc.SaveChanges();

                int _key = _testFeat.FeatureId;

                _crudFeatureManager.SelectedFeature = _testFeat;

                _crudFeatureManager.UpdateFeature("TestFeat", "This is a test feature", 1, 1, "No notes needed");

                Assert.Multiple(() =>
                {
                    Assert.AreEqual("TestFeat", _crudFeatureManager.SelectedFeature.Title);
                    Assert.AreEqual("This is a test feature", _crudFeatureManager.SelectedFeature.Description);
                    Assert.AreEqual(1, _crudFeatureManager.SelectedFeature.Status);
                    Assert.AreEqual(1, _crudFeatureManager.SelectedFeature.Priority);
                    Assert.AreEqual("No notes needed", _crudFeatureManager.SelectedFeature.Notes);
                    Assert.AreEqual(_key, _crudFeatureManager.SelectedFeature.FeatureId);
                });
            }
        }
コード例 #21
0
        public void WhenAFeatureIsSelectedMakeSureTheInformationIsCorrect()
        {
            using (PlannerContext pc = new PlannerContext())
            {
                Feature _testFeat = new Feature()
                {
                    Title       = "TestFeat",
                    Description = "This is a test feature",
                    Status      = 1,
                    Priority    = 1,
                    Notes       = "No notes needed",
                    ProjectId   = _crudProjectManager.SelectedProject.ProjectId
                };

                pc.Features.Add(_testFeat);

                pc.SaveChanges();

                _crudFeatureManager.SetSelectedFeature(_testFeat);

                Assert.Multiple(() =>
                {
                    Assert.AreEqual("TestFeat", _crudFeatureManager.SelectedFeature.Title);
                    Assert.AreEqual("This is a test feature", _crudFeatureManager.SelectedFeature.Description);
                    Assert.AreEqual(1, _crudFeatureManager.SelectedFeature.Status);
                    Assert.AreEqual(1, _crudFeatureManager.SelectedFeature.Priority);
                    Assert.AreEqual("No notes needed", _crudFeatureManager.SelectedFeature.Notes);
                });
            }
        }
コード例 #22
0
        public void TearDown()
        {
            using (PlannerContext pc = new PlannerContext())
            {
                var _selectedFeature =
                    from f in pc.Features
                    where f.Title == "TestFeat"
                    select f;

                var _selectedProject =
                    from p in pc.Projects
                    where p.Title == "temp"
                    select p;

                var _secondProject =
                    from p in pc.Projects
                    where p.Title == "temp2"
                    select p;

                pc.Projects.RemoveRange(_selectedProject);
                pc.Projects.RemoveRange(_secondProject);
                pc.Features.RemoveRange(_selectedFeature);

                pc.SaveChanges();
            }
        }
コード例 #23
0
        public void Setup()
        {
            using (PlannerContext pc = new PlannerContext())
            {
                var _selectedFeature =
                    from f in pc.Features
                    where f.Title == "TestFeat"
                    select f;

                Project _tempProj = new Project()
                {
                    Title       = "temp",
                    Description = "Temp Temp",
                    Status      = 1,
                    Link        = "Temporary"
                };

                pc.Features.RemoveRange(_selectedFeature);
                pc.Projects.Add(_tempProj);

                pc.SaveChanges();

                _crudProjectManager.SelectedProject = _tempProj;
            }
        }
コード例 #24
0
        public void WhenAListOfFeaturesIsRetrievedMakeSureItIsNotEmptyIfThereAreFeaturesInTheDatabase()
        {
            using (PlannerContext pc = new PlannerContext())
            {
                Feature _testFeat = new Feature()
                {
                    Title       = "TestFeat",
                    Description = "This is a test feature",
                    Status      = 1,
                    Priority    = 1,
                    Notes       = "No notes needed",
                    ProjectId   = _crudProjectManager.SelectedProject.ProjectId
                };

                pc.Features.Add(_testFeat);

                pc.SaveChanges();

                List <Feature> _featureList = new List <Feature>();

                _featureList = _crudFeatureManager.RetrieveAllFeatures();

                Assert.IsNotEmpty(_featureList);
            }
        }
コード例 #25
0
 public List <Project> RetrieveAllProjects()
 {
     using (PlannerContext pc = new PlannerContext())
     {
         return(pc.Projects.ToList());
     }
 }
コード例 #26
0
 public List <Issue> RetrieveAllIssues()
 {
     using (PlannerContext pc = new PlannerContext())
     {
         return(pc.Issues.ToList());
     }
 }
コード例 #27
0
 public UserController(IUserServices service,
                       PlannerContext context,
                       IHostingEnvironment env)
 {
     Env          = env;
     Context      = context;
     UserServices = service;
 }
コード例 #28
0
        public void PopulateRoleMembersDropDownList(PlannerContext _context)
        {
            var memberQuery = from m in _context.Member
                              orderby m.MemberName // Sort by MemberName.
                              select m;

            MemberNameSL = new SelectList(memberQuery.AsNoTracking(), "MemberID", "MemberName");
        }
コード例 #29
0
        public void PopulateRoleDropDownList(PlannerContext _context, object selectedRole = null)
        {
            var roleQuery = from d in _context.Role
                            orderby d.RoleTypeName // Sort by name.
                            select d;

            RoleNameSL = new SelectList(roleQuery, "RoleID", "RoleTypeName", selectedRole);
        }
コード例 #30
0
 public EventController(PlannerContext context,
                        IEventServices services,
                        ICategoryServices categoryServices)
 {
     Context          = context;
     Services         = services;
     CategoryServices = categoryServices;
 }