Store() public méthode

public Store ( ProjectToken token ) : void
token ProjectToken
Résultat void
        public void if_storing_a_project_that_is_already_in_the_history_bring_it_to_top()
        {
            var history = new ProjectHistory();
            history.Store(new ProjectToken
            {
                Filename = "project1.xml",
                Name = "project1"
            });
            history.Store(new ProjectToken
            {
                Filename = "project2.xml",
                Name = "project2"
            });
            history.Store(new ProjectToken
            {
                Filename = "project3.xml",
                Name = "project3"
            });
            history.Store(new ProjectToken
            {
                Filename = "project4.xml",
                Name = "project4"
            });
            history.Store(new ProjectToken
            {
                Filename = "project2.xml",
                Name = "project2"
            });

            history.Projects.ShouldEqual(new[]
            {
                new ProjectToken
                {
                    Filename = "project2.xml",
                    Name = "project2"
                },
                new ProjectToken
                {
                    Filename = "project4.xml",
                    Name = "project4"
                },
                new ProjectToken
                {
                    Filename = "project3.xml",
                    Name = "project3"
                },
                new ProjectToken
                {
                    Filename = "project1.xml",
                    Name = "project1"
                }
            });
        }
        public void last_test()
        {
            var history = new ProjectHistory();
            history.Store(new ProjectToken
            {
                Filename = "project1.xml",
                Name = "project1"
            });
            history.Store(new ProjectToken
            {
                Filename = "project2.xml",
                Name = "project2"
            });
            history.Store(new ProjectToken
            {
                Filename = "project3.xml",
                Name = "project3"
            });
            history.Store(new ProjectToken
            {
                Filename = "project4.xml",
                Name = "project4"
            });

            history.LastAccessed.ShouldEqual(new ProjectToken
            {
                Filename = "project4.xml",
                Name = "project4"
            });
        }
Exemple #3
0
        public static ProjectHistory HistoryPointingToMathProject()
        {
            var history = new ProjectHistory();
            history.Store(new ProjectToken
            {
                Name = "Math",
                Filename = THE_MATH_FILE
            });

            return history;
        }
        public void save_and_load_history()
        {
            var history = new ProjectHistory();
            var theLastProject = new ProjectToken
            {
                Filename = "something",
                Name = "else"
            };
            history.Store(theLastProject);

            persistor.SaveHistory(history);

            IProjectHistory history2 = persistor.LoadHistory();

            history2.LastAccessed.ShouldEqual(theLastProject);
        }
        public void SetUp()
        {
            _history = new ProjectHistory();
            _projectToken1 = new ProjectToken
            {
                Filename = "project1.xml",
                Name = "project1"
            };

            _projectToken2 = new ProjectToken
            {
                Filename = "project2.xml",
                Name = "project2"
            };

            _projectToken3 = new ProjectToken
            {
                Filename = "project3.xml",
                Name = "project3"
            };
            _history.Store(_projectToken3);
            _history.Store(_projectToken2);
            _history.Store(_projectToken1);
        }
        public void remembers_project_history_in_most_recent_order()
        {
            var history = new ProjectHistory();
            history.Store(new ProjectToken
            {
                Filename = "project1.xml",
                Name = "project1"
            });
            history.Store(new ProjectToken
            {
                Filename = "project2.xml",
                Name = "project2"
            });
            history.Store(new ProjectToken
            {
                Filename = "project3.xml",
                Name = "project3"
            });
            history.Store(new ProjectToken
            {
                Filename = "project4.xml",
                Name = "project4"
            });

            history.Projects.ShouldEqual(new[]
            {
                new ProjectToken
                {
                    Filename = "project4.xml",
                    Name = "project4"
                },
                new ProjectToken
                {
                    Filename = "project3.xml",
                    Name = "project3"
                },
                new ProjectToken
                {
                    Filename = "project2.xml",
                    Name = "project2"
                },
                new ProjectToken
                {
                    Filename = "project1.xml",
                    Name = "project1"
                }
            });
        }
        public void persist_and_load()
        {
            var system = new FileSystem();

            var history1 = new ProjectHistory();
            history1.Store(new ProjectToken
            {
                Filename = "project1.xml",
                Name = "project1"
            });
            history1.Store(new ProjectToken
            {
                Filename = "project2.xml",
                Name = "project2"
            });
            history1.Store(new ProjectToken
            {
                Filename = "project3.xml",
                Name = "project3"
            });
            history1.Store(new ProjectToken
            {
                Filename = "project4.xml",
                Name = "project4"
            });

            system.PersistToFile(history1, "history.xml");
            var history2 = system.LoadFromFile<ProjectHistory>("history.xml");

            history2.Projects.ShouldEqual(new[]
            {
                new ProjectToken
                {
                    Filename = "project4.xml",
                    Name = "project4"
                },
                new ProjectToken
                {
                    Filename = "project3.xml",
                    Name = "project3"
                },
                new ProjectToken
                {
                    Filename = "project2.xml",
                    Name = "project2"
                },
                new ProjectToken
                {
                    Filename = "project1.xml",
                    Name = "project1"
                }
            });

            history2.LastAccessed.ShouldEqual(new ProjectToken
            {
                Filename = "project4.xml",
                Name = "project4"
            });
        }
        public void only_remembers_4_projects()
        {
            var history = new ProjectHistory();
            history.Store(new ProjectToken
            {
                Filename = "project1.xml",
                Name = "project1"
            });
            history.Store(new ProjectToken
            {
                Filename = "project2.xml",
                Name = "project2"
            });
            history.Store(new ProjectToken
            {
                Filename = "project3.xml",
                Name = "project3"
            });
            history.Store(new ProjectToken
            {
                Filename = "project4.xml",
                Name = "project4"
            });
            history.Store(new ProjectToken
            {
                Filename = "project5.xml",
                Name = "project5"
            });

            history.Projects.ShouldEqual(new[]
            {
                new ProjectToken
                {
                    Filename = "project5.xml",
                    Name = "project5"
                },
                new ProjectToken
                {
                    Filename = "project4.xml",
                    Name = "project4"
                },
                new ProjectToken
                {
                    Filename = "project3.xml",
                    Name = "project3"
                },
                new ProjectToken
                {
                    Filename = "project2.xml",
                    Name = "project2"
                },
            });
        }
        public void mark_as_last_accessed_when_the_project_is_not_the_most_recent_project()
        {
            var token = new ProjectToken
            {
                Filename = "project4.xml",
                Name = "project4"
            };

            var history = new ProjectHistory();
            history.Store(new ProjectToken
            {
                Filename = "project1.xml",
                Name = "project1"
            });
            history.Store(new ProjectToken
            {
                Filename = "project2.xml",
                Name = "project2"
            });
            history.Store(new ProjectToken
            {
                Filename = "project3.xml",
                Name = "project3"
            });

            history.Store(token);

            history.MarkAsLastAccessed(token);

            history.LastAccessed.ShouldBeTheSameAs(token);

            history.Projects.Length.ShouldEqual(4);
        }
        public void mark_as_last_accessed_when_the_project_is_already_the_most_recent_project()
        {
            var token = new ProjectToken
            {
                Filename = "project4.xml",
                Name = "project4"
            };

            var history = new ProjectHistory();
            history.Store(token);
            history.Store(new ProjectToken
            {
                Filename = "project1.xml",
                Name = "project1"
            });
            history.Store(new ProjectToken
            {
                Filename = "project2.xml",
                Name = "project2"
            });
            history.Store(new ProjectToken
            {
                Filename = "project3.xml",
                Name = "project3"
            });

            history.MarkAsLastAccessed(token);
        }