コード例 #1
0
        public async Task AllianceAsync_successfully_returns_a_pagedModelV2ContactAlliance()
        {
            Mock <IWebClient> mockedWebClient = new Mock <IWebClient>();

            int            characterId = 88823;
            int            page        = 1;
            AllianceScopes scopes      = AllianceScopes.esi_alliances_read_contacts_v1;

            SsoToken inputToken = new SsoToken {
                AccessToken = "This is a old access token", RefreshToken = "This is a old refresh token", CharacterId = characterId, AllianceScopesFlags = scopes
            };
            string json = "[\r\n  {\r\n    \"contact_id\": 2112625428,\r\n    \"contact_type\": \"character\",\r\n    \"standing\": 9.9\r\n  }\r\n]";

            mockedWebClient.Setup(x => x.GetAsync(It.IsAny <WebHeaderCollection>(), It.IsAny <string>(), It.IsAny <int>())).ReturnsAsync(new EsiModel {
                Model = json, MaxPages = 2
            });

            InternalLatestContacts internalLatestContacts = new InternalLatestContacts(mockedWebClient.Object, string.Empty);

            PagedModel <V2ContactAlliance> returnModel = await internalLatestContacts.AllianceAsync(inputToken, 9923, page);

            Assert.Equal(2112625428, returnModel.Model.First().ContactId);
            Assert.Equal(V2ContactAllianceContactTypes.Character, returnModel.Model[0].ContactType);
            Assert.Equal(9.9f, returnModel.Model[0].Standing);
        }
コード例 #2
0
        public static void CheckToken(SsoToken token, AllianceScopes scope)
        {
            if (token == null)
            {
                throw new EsiException("Token can not be null");
            }

            if (token.AllianceScopesFlags == AllianceScopes.None || !token.AllianceScopesFlags.HasFlag(scope))
            {
                throw new EsiException($"This token does not have {scope} it has: {token.AllianceScopesFlags}");
            }
        }
コード例 #3
0
        public async Task AllianceLabelsAsync_successfully_returns_a_IListV1ContactAllianceLabel()
        {
            int            characterId = 88823;
            AllianceScopes scopes      = AllianceScopes.esi_alliances_read_contacts_v1;

            SsoToken inputToken = new SsoToken {
                AccessToken = "This is a old access token", RefreshToken = "This is a old refresh token", CharacterId = characterId, AllianceScopesFlags = scopes
            };

            LatestContactsEndpoints internalLatestContacts = new LatestContactsEndpoints(string.Empty, true);

            IList <V1ContactAllianceLabel> returnModel = await internalLatestContacts.AllianceLabelsAsync(inputToken, 9923);

            Assert.Equal(1, returnModel.First().LabelId);
            Assert.Equal("Alliance Friends", returnModel.First().LabelName);
        }
コード例 #4
0
        public async Task AllianceAsync_successfully_returns_a_pagedModelV2ContactAlliance()
        {
            int            characterId = 88823;
            int            page        = 1;
            AllianceScopes scopes      = AllianceScopes.esi_alliances_read_contacts_v1;

            SsoToken inputToken = new SsoToken {
                AccessToken = "This is a old access token", RefreshToken = "This is a old refresh token", CharacterId = characterId, AllianceScopesFlags = scopes
            };

            LatestContactsEndpoints internalLatestContacts = new LatestContactsEndpoints(string.Empty, true);

            PagedModel <V2ContactAlliance> returnModel = await internalLatestContacts.AllianceAsync(inputToken, 9923, page);

            Assert.Equal(2112625428, returnModel.Model.First().ContactId);
            Assert.Equal(V2ContactAllianceContactTypes.Character, returnModel.Model[0].ContactType);
            Assert.Equal(9.9f, returnModel.Model[0].Standing);
        }
コード例 #5
0
        public async Task AllianceLabelsAsync_successfully_returns_a_IListV1ContactAllianceLabel()
        {
            Mock <IWebClient> mockedWebClient = new Mock <IWebClient>();

            int            characterId = 88823;
            AllianceScopes scopes      = AllianceScopes.esi_alliances_read_contacts_v1;

            SsoToken inputToken = new SsoToken {
                AccessToken = "This is a old access token", RefreshToken = "This is a old refresh token", CharacterId = characterId, AllianceScopesFlags = scopes
            };
            string json = "[\r\n  {\r\n    \"label_id\": 1,\r\n    \"label_name\": \"Alliance Friends\"\r\n  }\r\n]";

            mockedWebClient.Setup(x => x.GetAsync(It.IsAny <WebHeaderCollection>(), It.IsAny <string>(), It.IsAny <int>())).ReturnsAsync(new EsiModel {
                Model = json, MaxPages = 2
            });

            InternalLatestContacts internalLatestContacts = new InternalLatestContacts(mockedWebClient.Object, string.Empty);

            IList <V1ContactAllianceLabel> returnModel = await internalLatestContacts.AllianceLabelsAsync(inputToken, 9923);

            Assert.Equal(1, returnModel.First().LabelId);
            Assert.Equal("Alliance Friends", returnModel.First().LabelName);
        }