OSDN Git Service

エラーログのレスポンスからapi_resultを取り除くのをやめる
[kancollesniffer/KancolleSniffer.git] / KancolleSniffer.Test / ErrorLogTest.cs
1 // Copyright (C) 2017 Kazuhiro Fujieda <fujieda@users.osdn.me>\r
2 //\r
3 // Licensed under the Apache License, Version 2.0 (the "License");\r
4 // you may not use this file except in compliance with the License.\r
5 // You may obtain a copy of the License at\r
6 //\r
7 //    http://www.apache.org/licenses/LICENSE-2.0\r
8 //\r
9 // Unless required by applicable law or agreed to in writing, software\r
10 // distributed under the License is distributed on an "AS IS" BASIS,\r
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
12 // See the License for the specific language governing permissions and\r
13 // limitations under the License.\r
14 \r
15 using ExpressionToCodeLib;\r
16 using Microsoft.VisualStudio.TestTools.UnitTesting;\r
17 \r
18 namespace KancolleSniffer.Test\r
19 {\r
20     [TestClass]\r
21     public class ErrorLogTest\r
22     {\r
23         [TestMethod]\r
24         public void RemoveTokenFromRequest()\r
25         {\r
26             var request =\r
27                 "api%5Fverno=1&api%5Ftoken=0123456abcdef&api%5Fport=0123456789";\r
28             var response = "";\r
29             ErrorLog.RemoveUnwantedInformation(ref request, ref response);\r
30             PAssert.That(() => request == "api%5Fverno=1&api%5Fport=0123456789", "トークンが中間");\r
31             var request2 = "api%5Fverno=1&api%5Ftoken=0123456abcdef";\r
32             ErrorLog.RemoveUnwantedInformation(ref request2, ref response);\r
33             PAssert.That(() => request2 == @"api%5Fverno=1", "トークンが末尾");\r
34             var request3 = "api%5Ftoken=0123456abcdef&api%5Fverno=1";\r
35             ErrorLog.RemoveUnwantedInformation(ref request3, ref response);\r
36             PAssert.That(() => request3 == @"api%5Fverno=1", "トークンが先頭");\r
37             var request4 = "api%5Ftoken=0123456abcdef";\r
38             ErrorLog.RemoveUnwantedInformation(ref request4, ref response);\r
39             PAssert.That(() => request4 == "", "トークン単独");\r
40         }\r
41 \r
42         [TestMethod]\r
43         public void RemoveUnwantedInformationFromResponse()\r
44         {\r
45             var request = "";\r
46             var response = @"{""api_result"":1,""api_result_msg"":""成功"",""api_data"":" +\r
47                            @"{""api_basic"":{""api_member_id"":""123456""," +\r
48                            @"""api_nickname"":""ぱんなこった"",""api_nickname_id"":""12345678"",""api_active_flag"":1}}}";\r
49             ErrorLog.RemoveUnwantedInformation(ref request, ref response);\r
50             PAssert.That(() => response ==\r
51                                @"{""api_result"":1,""api_result_msg"":""成功"",""api_data"":" +\r
52                                @"{""api_basic"":{""api_active_flag"":1}}}");\r
53         }\r
54     }\r
55 }