public void SerializeAndDeserialize_Success()
        {
            JsonSerializerWrapper jsonSerializer = new JsonSerializerWrapper();

            Dictionary <string, List <string> > HashToFilePathDict =
                new Dictionary <string, List <string> >
            {
                { "abc", new List <string> {
                      "123", "456"
                  } },
                { "def", new List <string> {
                      "789", "456"
                  } }
            };

            string tempFile = Guid.NewGuid().ToString();

            try
            {
                jsonSerializer.Serialize(HashToFilePathDict, tempFile);
                Dictionary <string, List <string> > testedHashToFilePathDict =
                    jsonSerializer.Deserialize <Dictionary <string, List <string> > >(tempFile);

                Assert.Equal(HashToFilePathDict["abc"][0], testedHashToFilePathDict["abc"][0]);
                Assert.Equal(HashToFilePathDict["abc"][1], testedHashToFilePathDict["abc"][1]);
                Assert.Equal(HashToFilePathDict["def"][0], testedHashToFilePathDict["def"][0]);
            }
            finally
            {
                File.Delete(tempFile);
            }
        }
示例#2
0
        public async Task Deserialize_DatabaseFromFile_AsExpected(string databaseName, int groupsCount)
        {
            string databasePath = Path.Combine(TestFilesDirectory, databaseName);

            JsonSerializerWrapper jsonSerializerWrapper = new JsonSerializerWrapper();

            List <TasksGroup> entities =
                await jsonSerializerWrapper.Deserialize <List <TasksGroup> >(databasePath)
                .ConfigureAwait(false);

            Assert.Equal(groupsCount, entities.Count);
        }