<commit_before>﻿using System.Net;
using Project.MyAnimeList.Facade;
using Project.MyAnimeList.Web;
using Xunit;
using Xunit.Abstractions;

namespace Project.MyAnimeList.Test
{
	public class AnimeListMethodsTest : CredentialCollectionTest
	{
		private readonly ITestOutputHelper _output;

		/// <summary>
		/// Gate: Jieitai Kanochi nite, Kaku Tatakaeri
		/// http://myanimelist.net/anime/28907/Gate:_Jieitai_Kanochi_nite_Kaku_Tatakaeri
		/// </summary>
		private readonly int? _id = 123;
		private readonly string _data = 
			@"<? xml version = ""1.0"" encoding = ""UTF -8"" ?>
				<entry>
					<episode>9</episode>
					<status>1</status>
					<score>9</score>
					<downloaded_episodes></downloaded_episodes>
					<storage_type></storage_type>
					<storage_value></storage_value>
					<times_rewatched></times_rewatched>
					<rewatch_value></rewatch_value>
					<date_start></date_start>
					<date_finish></date_finish>
					<priority></priority>
					<enable_discussion></enable_discussion>
					<enable_rewatching></enable_rewatching>
					<comments></comments>
					<fansub_group></fansub_group>
					<tags>test tag, 2nd tag</tags>
				</ entry>";

		public AnimeListMethodsTest(CredentialContextFixture credentialContextFixture, ITestOutputHelper output)
			: base(credentialContextFixture)
		{
			_output = output;
		}

		[Fact]
		public void TestAddAnimeRequestParametersMethod()
		{
			var sut = new AddAnimeRequestParameters(CredentialContextFixture.CredentialContext, _id, _data);

			Assert.Equal("POST", sut.HttpMethod);
		}

		[Fact]
		public void TestAddAnimeRequestParametersBaseUri()
		{
			var requestParameters = new AddAnimeRequestParameters(CredentialContextFixture.CredentialContext, _id, _data);
			var sut = new RequestUriBuilder(requestParameters);

			var actualUri = sut.GetRequestUri();

			Assert.Equal($"http://myanimelist.net/api/animelist/add/{_id.Value}.xml", actualUri);
		}

		[Fact]
		public void TestAddAnimeRequestThrowsWebExceptionForNotImplemented()
		{
			var sut = new AnimeListMethods(CredentialContextFixture.CredentialContext);

			//string uniqueId = sut.AddAnime(id, data);
			//Assert.False(string.IsNullOrEmpty(uniqueId));
			Assert.Throws<WebException>(() => sut.AddAnime(_id, _data));
		}

		[Fact]
		public void TestAddAnimeRequestUpdate()
		{
			// Gate: Jieitai Kanochi nite, Kaku Tatakaeri
			// http://myanimelist.net/anime/28907/Gate:_Jieitai_Kanochi_nite_Kaku_Tatakaeri
			int? id = 28907;
			string data = 
@"<? xml version = ""1.0"" encoding = ""UTF -8"" ?>
<entry>
	<episode>9</episode>
	<status>1</status>
	<score>9</score>
	<downloaded_episodes></downloaded_episodes>
	<storage_type></storage_type>
	<storage_value></storage_value>
	<times_rewatched></times_rewatched>
	<rewatch_value></rewatch_value>
	<date_start></date_start>
	<date_finish></date_finish>
	<priority></priority>
	<enable_discussion></enable_discussion>
	<enable_rewatching></enable_rewatching>
	<comments></comments>
	<fansub_group></fansub_group>
	<tags>test tag, 2nd tag</tags>
</ entry>";
			var sut = new AnimeListMethods(CredentialContextFixture.CredentialContext);

			var actual = sut.UpdateAnime(id, data);

			_output.WriteLine("Actual: {0}", actual);
            Assert.False(string.IsNullOrEmpty(actual));
		}
	}
}
<commit_msg>Forgot to update "Update" test<commit_after>﻿using System.Net;
using Project.MyAnimeList.Facade;
using Project.MyAnimeList.Web;
using Xunit;
using Xunit.Abstractions;

namespace Project.MyAnimeList.Test
{
	public class AnimeListMethodsTest : CredentialCollectionTest
	{
		private readonly ITestOutputHelper _output;

		/// <summary>
		/// Gate: Jieitai Kanochi nite, Kaku Tatakaeri
		/// http://myanimelist.net/anime/28907/Gate:_Jieitai_Kanochi_nite_Kaku_Tatakaeri
		/// </summary>
		private readonly int? _id = 123;
		private readonly string _data =
			@"<? xml version = ""1.0"" encoding = ""UTF -8"" ?>
				<entry>
					<episode>9</episode>
					<status>1</status>
					<score>9</score>
					<downloaded_episodes></downloaded_episodes>
					<storage_type></storage_type>
					<storage_value></storage_value>
					<times_rewatched></times_rewatched>
					<rewatch_value></rewatch_value>
					<date_start></date_start>
					<date_finish></date_finish>
					<priority></priority>
					<enable_discussion></enable_discussion>
					<enable_rewatching></enable_rewatching>
					<comments></comments>
					<fansub_group></fansub_group>
					<tags>test tag, 2nd tag</tags>
				</ entry>";

		public AnimeListMethodsTest(CredentialContextFixture credentialContextFixture, ITestOutputHelper output)
			: base(credentialContextFixture)
		{
			_output = output;
		}

		[Fact]
		public void TestAddAnimeRequestParametersMethod()
		{
			var sut = new AddAnimeRequestParameters(CredentialContextFixture.CredentialContext, _id, _data);

			Assert.Equal("POST", sut.HttpMethod);
		}

		[Fact]
		public void TestAddAnimeRequestParametersBaseUri()
		{
			var requestParameters = new AddAnimeRequestParameters(CredentialContextFixture.CredentialContext, _id, _data);
			var sut = new RequestUriBuilder(requestParameters);

			var actualUri = sut.GetRequestUri();

			Assert.Equal($"http://myanimelist.net/api/animelist/add/{_id.Value}.xml", actualUri);
		}

		[Fact]
		public void TestAddAnimeRequestThrowsWebExceptionForNotImplemented()
		{
			var sut = new AnimeListMethods(CredentialContextFixture.CredentialContext);

			//string uniqueId = sut.AddAnime(id, data);
			//Assert.False(string.IsNullOrEmpty(uniqueId));
			Assert.Throws<WebException>(() => sut.AddAnime(_id, _data));
		}

		[Fact]
		public void TestAddAnimeRequestUpdate()
		{
			var sut = new AnimeListMethods(CredentialContextFixture.CredentialContext);

			var actual = sut.UpdateAnime(_id, _data);

			_output.WriteLine("Actual: {0}", actual);
			Assert.False(string.IsNullOrEmpty(actual));
		}
	}
}

{'fraction_non_alphanumeric': 0.12768148275270294, 'fraction_numerical': 0.008409129912476403, 'mean_word_length': 4.641819941916747, 'pattern_counts': {'":': 0, '<': 114, '<?xml version=': 0, '>': 116, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 5}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4627657', 'n_tokens_mistral': 2288, 'n_tokens_neox': 1930, 'n_words': 315}