コード例 #1
0
        public void JsonPrePostSerialization_AreEqual(string relativeFilePath, string toSerialize)
        {
            //setup
            var debugger       = new ConsoleDebugger();
            var jsonSerializer = new NewtonsoftJsonSerializer();
            var fileSerializer = new TextFileSerializer(jsonSerializer, debugger);
            var finalPath      = Path.Combine(Environment.CurrentDirectory, relativeFilePath);

            if (File.Exists(finalPath))
            {
                File.Delete(finalPath);
            }

            //write / read
            fileSerializer.Write(finalPath, toSerialize);
            Assert.True(File.Exists(finalPath));

            var deserialized = fileSerializer.Read <string>(finalPath);

            //compare results
            Assert.Equal(toSerialize, deserialized);

            //cleanup
            File.Delete(finalPath);
        }
コード例 #2
0
        public void DirectoryCreation_NoExceptions(string completeFilePath, string toSerialize)
        {
            //setup to ensure the directory is created on this run
            string directoryName = Path.GetDirectoryName(completeFilePath);

            if (Directory.Exists(directoryName))
            {
                Directory.Delete(directoryName);
            }

            var debugger       = new ConsoleDebugger();
            var jsonSerializer = new NewtonsoftJsonSerializer();
            var fileSerializer = new TextFileSerializer(jsonSerializer, debugger);

            try
            {
                fileSerializer.Write(completeFilePath, toSerialize);
            }
            catch (Exception e)
            {
                Assert.False(true);
            }
        }