Exemplo n.º 1
0
        public void Load_Test_MultipleFiles_Success()
        {
            var fileSystem = new SocialMediaFileSystem(Path.Combine(_path, "Load"));
            var file1      = Path.Combine(fileSystem.PathToSaveFile, "123456789.xml");
            var file2      = Path.Combine(fileSystem.PathToSaveFile, "987654321.xml");


            if (File.Exists(file2))
            {
                File.Delete(file2);
            }
            File.Copy(file1, file2);
            List <SocialMediaUserData> users = fileSystem.Load().Cast <SocialMediaUserData>().ToList();

            Assert.True(File.Exists(file1));
            Assert.True(File.Exists(file2));
            Assert.Equal(6, users.Count);
            Equal(SocialMediaEnum.YouTube, "YouTuber", 123456789, 1, "wecylinder", users[0]);
            Equal(SocialMediaEnum.YouTube, "YouTuber", 987654321, 1, "wecylinder", users[1]);
            Equal(SocialMediaEnum.Twitter, "Tweeter", 123456789, 3, "chirp", users[2]);
            Equal(SocialMediaEnum.Twitter, "Tweeter", 987654321, 3, "chirp", users[3]);
            Equal(SocialMediaEnum.Twitch, "Streamer", 123456789, 2, "spasm", users[4]);
            Equal(SocialMediaEnum.Twitch, "Streamer", 987654321, 2, "spasm", users[5]);

            File.Delete(file2);
        }
Exemplo n.º 2
0
        public void Load_Test_Fail()
        {
            var fileSystem = new SocialMediaFileSystem(Path.Combine(_path, "Load Fail"));

            List <SocialMediaUserData> users = fileSystem.Load().Cast <SocialMediaUserData>().ToList();

            Assert.True(File.Exists(Path.Combine(fileSystem.PathToSaveFile, "fail.xml")));
            Assert.Empty(users);
        }
Exemplo n.º 3
0
        public void Load_Test_SingleFile_Success()
        {
            var fileSystem = new SocialMediaFileSystem(Path.Combine(_path, "Load"));

            List <SocialMediaUserData> users = fileSystem.Load().Cast <SocialMediaUserData>().ToList();

            Assert.True(File.Exists(Path.Combine(fileSystem.PathToSaveFile, "123456789.xml")));
            Assert.Equal(3, users.Count);
            Equal(SocialMediaEnum.YouTube, "YouTuber", 123456789, 1, "wecylinder", users[0]);
            Equal(SocialMediaEnum.Twitter, "Tweeter", 123456789, 3, "chirp", users[1]);
            Equal(SocialMediaEnum.Twitch, "Streamer", 123456789, 2, "spasm", users[2]);
        }
Exemplo n.º 4
0
 protected virtual void LoadOrCreateFromFile()
 {
     Users = FileSystem.Load().Cast <SocialMediaUserData>().ToList();
 }