Esempio n. 1
0
        public void AddProject()
        {
            List<Project> projects = new List<Project>();
            ProjectRepository repository = new ProjectRepository(projects);
            Project project = new Project() { Name = "New Project" };

            repository.AddProject(project);

            Assert.AreEqual(1, project.Id);
            Assert.AreEqual(1, projects.Count);
            Assert.AreEqual("New Project", projects[0].Name);
        }
Esempio n. 2
0
        public void InitializeFromFolder(string path)
        {
            string filename = Path.Combine(path, "Projects.json");
            string text = File.ReadAllText(filename);
            dynamic items = Json.Decode(text);

            foreach (dynamic item in items)
            {
                Project project = new Project();
                project.Id = item.Id;
                project.Name = item.Name;
                this.projects.Add(project);
            }
        }
Esempio n. 3
0
        public void PostCreate()
        {
            Project project = new Project() { Name = "New Project" };

            var result = this.controller.Create(project);

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult));

            var rresult = (RedirectToRouteResult)result;

            Assert.AreEqual("Index", rresult.RouteValues["action"]);

            Assert.AreEqual(4, this.projects.Count);
            Assert.IsTrue(this.projects.Any(p => p.Name == "New Project"));
            Assert.AreEqual(4, project.Id);
        }
Esempio n. 4
0
        public void AddProject()
        {
            var projects = new List<Project>()
            {
                new Project() { Id = 1, Name = "Project 1" },
                new Project() { Id = 2, Name = "Project 2" },
                new Project() { Id = 3, Name = "Project 3" }
            };

            Project project = new Project() { Name = "New Project" };

            ProjectServices services = new ProjectServices(projects);

            services.AddProject(project);

            Assert.AreEqual(4, project.Id);
            Assert.IsTrue(projects.Any(p => p.Name == "New Project"));
        }
Esempio n. 5
0
 public void AddProject(Project project)
 {
     this.repository.AddProject(project);
 }
Esempio n. 6
0
 public ActionResult Create(Project project)
 {
     this.services.AddProject(project);
     return RedirectToAction("Index");
 }
Esempio n. 7
0
        public void PostCreateFirstProject()
        {
            Project project = new Project() { Name = "New Project" };
            List<Project> projects = new List<Project>();
            ProjectController controller = new ProjectController(projects);

            var result = controller.Create(project);

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult));

            var rresult = (RedirectToRouteResult)result;

            Assert.AreEqual("Index", rresult.RouteValues["action"]);

            Assert.AreEqual(1, projects.Count);
            Assert.IsTrue(projects.Any(p => p.Name == "New Project"));
            Assert.AreEqual(1, project.Id);
        }
Esempio n. 8
0
 public void AddProject(Project project)
 {
     maxid++;
     project.Id = maxid;
     this.projects.Add(project);
 }