public void Corporation_successfully_returns_a_listV1KillmailCorporation() { Mock <IWebClient> mockedWebClient = new Mock <IWebClient>(); int characterId = 828658; string characterName = "ThisIsACharacter"; KillmailScopes scopes = KillmailScopes.esi_killmails_read_corporation_killmails_v1; SsoToken inputToken = new SsoToken { AccessToken = "This is a old access token", RefreshToken = "This is a old refresh token", CharacterId = characterId, CharacterName = characterName, KillmailScopesFlags = scopes }; string json = "[\r\n {\r\n \"killmail_hash\": \"8eef5e8fb6b88fe3407c489df33822b2e3b57a5e\",\r\n \"killmail_id\": 2\r\n },\r\n {\r\n \"killmail_hash\": \"b41ccb498ece33d64019f64c0db392aa3aa701fb\",\r\n \"killmail_id\": 1\r\n }\r\n]"; mockedWebClient.Setup(x => x.Get(It.IsAny <WebHeaderCollection>(), It.IsAny <string>(), It.IsAny <int>())).Returns(new EsiModel { Model = json }); InternalLatestKillmails internalLatestKillmails = new InternalLatestKillmails(mockedWebClient.Object, string.Empty); IList <V1KillmailCorporation> returnModel = internalLatestKillmails.Corporation(inputToken, 2, 1); Assert.Equal(2, returnModel.Count); Assert.Equal("8eef5e8fb6b88fe3407c489df33822b2e3b57a5e", returnModel[0].KillmailHash); Assert.Equal(2, returnModel[0].KillmailId); Assert.Equal("b41ccb498ece33d64019f64c0db392aa3aa701fb", returnModel[1].KillmailHash); Assert.Equal(1, returnModel[1].KillmailId); }
public static void CheckToken(SsoToken token, KillmailScopes scope) { if (token == null) { throw new EsiException("Token can not be null"); } if (token.KillmailScopesFlags == KillmailScopes.None || !token.KillmailScopesFlags.HasFlag(scope)) { throw new EsiException($"This token does not have {scope} it has: {token.KillmailScopesFlags}"); } }
public async Task CorporationAsync_successfully_returns_a_listV1KillmailCorporation() { int characterId = 828658; string characterName = "ThisIsACharacter"; KillmailScopes scopes = KillmailScopes.esi_killmails_read_corporation_killmails_v1; SsoToken inputToken = new SsoToken { AccessToken = "This is a old access token", RefreshToken = "This is a old refresh token", CharacterId = characterId, CharacterName = characterName, KillmailScopesFlags = scopes }; LatestKillmailsEndpoints internalLatestKillmails = new LatestKillmailsEndpoints(string.Empty, true); IList <V1KillmailCorporation> returnModel = await internalLatestKillmails.CorporationAsync(inputToken, 2, 1); Assert.Equal(2, returnModel.Count); Assert.Equal("8eef5e8fb6b88fe3407c489df33822b2e3b57a5e", returnModel[0].KillmailHash); Assert.Equal(2, returnModel[0].KillmailId); Assert.Equal("b41ccb498ece33d64019f64c0db392aa3aa701fb", returnModel[1].KillmailHash); Assert.Equal(1, returnModel[1].KillmailId); }