示例#1
0
        public void UpdateMangaTagsForUserTest()
        {
            string username = System.Environment.GetEnvironmentVariable("MAL_USERNAME");
            string password = System.Environment.GetEnvironmentVariable("MAL_PASSWORD");

            // Monster
            int mangaId = 1;

            MangaUpdate partialBaseInfo = new MangaUpdate()
            {
                Tags = "test base tag, test base tag 2"
            };

            MangaUpdate partialUpdateInfo = new MangaUpdate()
            {
                Tags = "test updated tag, test updated tag 2"
            };

            using (MyAnimeListApi api = new MyAnimeListApi())
            {
                using (GetUserMangaDetailsTest helper = new GetUserMangaDetailsTest())
                {
                    helper.Login(username, password);

                    string result = api.UpdateMangaForUser(mangaId, partialBaseInfo, username, password);
                    Assert.Equal("Updated", result);

                    MangaUpdate baseReults = helper.GetUserMangaDetailsAsync(username, mangaId);

                    // Assert first update against base info
                    Assert.Equal(partialBaseInfo.Tags, baseReults.Tags);

                    result = api.UpdateMangaForUser(mangaId, partialUpdateInfo, username, password);
                    Assert.Equal("Updated", result);

                    MangaUpdate updatedResults = helper.GetUserMangaDetailsAsync(username, mangaId);

                    // Assert second update with update info
                    Assert.Equal(partialUpdateInfo.Tags, updatedResults.Tags);

                    // Assert that only the tags has been changed
                    Assert.Equal(baseReults.Chapter, updatedResults.Chapter);
                    Assert.Equal(baseReults.Volume, updatedResults.Volume);
                    Assert.Equal(baseReults.Status, updatedResults.Status);
                    Assert.Equal(baseReults.Score, updatedResults.Score);
                    Assert.Equal(baseReults.TimesReread, updatedResults.TimesReread);
                    Assert.Equal(baseReults.RereadValue, updatedResults.RereadValue);
                    Assert.Equal(baseReults.DateStart, updatedResults.DateStart);
                    Assert.Equal(baseReults.DateFinish, updatedResults.DateFinish);
                    Assert.Equal(baseReults.Priority, updatedResults.Priority);
                    Assert.Equal(baseReults.EnableDiscussion, updatedResults.EnableDiscussion);
                    Assert.Equal(baseReults.EnableRereading, updatedResults.EnableRereading);
                    Assert.Equal(baseReults.Comments, updatedResults.Comments);
                    Assert.NotEqual(baseReults.Tags, updatedResults.Tags);
                }
            }
        }
示例#2
0
        public void UpdateMangaForUserTest()
        {
            string username = System.Environment.GetEnvironmentVariable("MAL_USERNAME");
            string password = System.Environment.GetEnvironmentVariable("MAL_PASSWORD");

            // Monster
            int mangaId = 1;

            MangaUpdate baseInfo = new MangaUpdate()
            {
                Chapter          = 1,
                Volume           = 2,
                Status           = MangaCompletionStatus.Reading,
                Score            = 3,
                TimesReread      = 1,
                RereadValue      = 2, // low
                DateStart        = new DateTime(2017, 10, 1),
                DateFinish       = new DateTime(2017, 10, 5),
                Priority         = 0, // low
                EnableDiscussion = 0,
                EnableRereading  = 0,
                Comments         = "base comment,base comment 2",
                // ScanGroup = "scan_group",
                Tags = "test base tag, test base tag 2"
            };

            MangaUpdate updateInfo = new MangaUpdate()
            {
                Chapter          = 162,
                Volume           = 18,
                Status           = MangaCompletionStatus.Completed,
                Score            = 10,
                TimesReread      = 2,
                RereadValue      = 4, // high
                DateStart        = new DateTime(2017, 12, 10),
                DateFinish       = new DateTime(2017, 12, 15),
                Priority         = 1, // medium
                EnableDiscussion = 1,
                EnableRereading  = 1,
                Comments         = "test updated comment, test updated comment2",
                // ScanGroup = "scan_group_updated",
                Tags = "test updated tag, test updated tag 2"
            };

            using (MyAnimeListApi api = new MyAnimeListApi())
            {
                using (GetUserMangaDetailsTest helper = new GetUserMangaDetailsTest())
                {
                    helper.Login(username, password);

                    string result = api.UpdateMangaForUser(mangaId, baseInfo, username, password);
                    Assert.Equal("Updated", result);

                    MangaUpdate baseReults = helper.GetUserMangaDetailsAsync(username, mangaId);

                    // Assert first update against base info
                    Assert.Equal(baseInfo.Chapter, baseReults.Chapter);
                    Assert.Equal(baseInfo.Volume, baseReults.Volume);
                    Assert.Equal(baseInfo.Status, baseReults.Status);
                    Assert.Equal(baseInfo.Score, baseReults.Score);
                    Assert.Equal(baseInfo.TimesReread, baseReults.TimesReread);
                    Assert.Equal(baseInfo.RereadValue, baseReults.RereadValue);
                    Assert.Equal(baseInfo.DateStart, baseReults.DateStart);
                    Assert.Equal(baseInfo.DateFinish, baseReults.DateFinish);
                    Assert.Equal(baseInfo.Priority, baseReults.Priority);
                    Assert.Equal(baseInfo.EnableDiscussion, baseReults.EnableDiscussion);
                    Assert.Equal(baseInfo.EnableRereading, baseReults.EnableRereading);
                    Assert.Equal(baseInfo.Comments, baseReults.Comments);
                    Assert.Equal(baseInfo.Tags, baseReults.Tags);

                    result = api.UpdateMangaForUser(mangaId, updateInfo, username, password);
                    Assert.Equal("Updated", result);

                    MangaUpdate updatedResults = helper.GetUserMangaDetailsAsync(username, mangaId);

                    // Assert second update with update info
                    Assert.Equal(updateInfo.Chapter, updatedResults.Chapter);
                    Assert.Equal(updateInfo.Volume, updatedResults.Volume);
                    Assert.Equal(updateInfo.Status, updatedResults.Status);
                    Assert.Equal(updateInfo.Score, updatedResults.Score);
                    Assert.Equal(updateInfo.TimesReread, updatedResults.TimesReread);
                    Assert.Equal(updateInfo.RereadValue, updatedResults.RereadValue);
                    Assert.Equal(updateInfo.DateStart, updatedResults.DateStart);
                    Assert.Equal(updateInfo.DateFinish, updatedResults.DateFinish);
                    Assert.Equal(updateInfo.Priority, updatedResults.Priority);
                    Assert.Equal(updateInfo.EnableDiscussion, updatedResults.EnableDiscussion);
                    Assert.Equal(updateInfo.EnableRereading, updatedResults.EnableRereading);
                    Assert.Equal(updateInfo.Comments, updatedResults.Comments);
                    Assert.Equal(updateInfo.Tags, updatedResults.Tags);

                    // Assert all values have been changed
                    Assert.NotEqual(baseReults.Chapter, updatedResults.Chapter);
                    Assert.NotEqual(baseReults.Volume, updatedResults.Volume);
                    Assert.NotEqual(baseReults.Status, updatedResults.Status);
                    Assert.NotEqual(baseReults.Score, updatedResults.Score);
                    Assert.NotEqual(baseReults.TimesReread, updatedResults.TimesReread);
                    Assert.NotEqual(baseReults.RereadValue, updatedResults.RereadValue);
                    Assert.NotEqual(baseReults.DateStart, updatedResults.DateStart);
                    Assert.NotEqual(baseReults.DateFinish, updatedResults.DateFinish);
                    Assert.NotEqual(baseReults.Priority, updatedResults.Priority);
                    Assert.NotEqual(baseReults.EnableDiscussion, updatedResults.EnableDiscussion);
                    Assert.NotEqual(baseReults.EnableRereading, updatedResults.EnableRereading);
                    Assert.NotEqual(baseReults.Comments, updatedResults.Comments);
                    Assert.NotEqual(baseReults.Tags, updatedResults.Tags);
                }
            }
        }