コード例 #1
0
        public void should_thrown_when_file_is_not_xml()
        {
            var fileSystem = new FileSystem();
            var fileName = Path.GetTempFileName();
            fileSystem.WriteStringToFile(fileName, "not xml!");

            typeof(ApplicationException).ShouldBeThrownBy(() => fileSystem.LoadFromFile<SerializeMe>(fileName));
        }
コード例 #2
0
        public void should_return_empty_instance_when_file_does_not_exist()
        {
            var fileSystem = new FileSystem();
            const string fileName = "does not exist";

            var result = fileSystem.LoadFromFile<SerializeMe>(fileName);

            result.Name.ShouldBeNull();
            result.Index.ShouldEqual(0);
        }
コード例 #3
0
        public void should_deserialize_xml()
        {
            var fileSystem = new FileSystem();
            var fileName = Path.GetTempFileName();
            fileSystem.WriteStringToFile(fileName, SerializeMe.SerializedXml);

            var result = fileSystem.LoadFromFile<SerializeMe>(fileName);

            result.Name.ShouldEqual("Serialized Name");
            result.Index.ShouldEqual(42);
        }
コード例 #4
0
ファイル: Project.cs プロジェクト: storyteller/Storyteller
        public static Project LoadForFolder(string folder)
        {
            var system = new FileSystem();
            var file = folder.AppendPath(FILE);

            var project = system.FileExists(file) ? system.LoadFromFile<Project>(file) : new Project();

            project.ProjectPath = folder;

            return project;
        }
コード例 #5
0
        public ResultHistory LoadResults(string directory)
        {
            var history = new ResultHistory();
            var system = new FileSystem();
            system.GetFiles(directory, "stresult").Each(f =>
            {
                var result = system.LoadFromFile<TestResult>(f);
                history[result.Locator] = result;
            });

            return history;
        }
コード例 #6
0
        public void save_and_load_an_object_to_xml()
        {
            var object1 = new BigObject
            {
                Name = "Max",
                Age = 5
            };
            var system = new FileSystem();
            system.PersistToFile(object1, "bigobject.xml");

            var object2 = system.LoadFromFile<BigObject>("bigobject.xml");

            object1.ShouldNotBeTheSameAs(object2);
            object1.ShouldEqual(object2);
        }
コード例 #7
0
ファイル: Project.cs プロジェクト: jamesmanning/Storyteller
        public static Project LoadForFolder(string folder)
        {
            var system = new FileSystem();
            var file = folder.AppendPath(FILE);

            if (system.FileExists(file))
            {
                return system.LoadFromFile<Project>(file);
            }

            return new Project();
        }