public void CorporationStats_successfully_returns_a_V1FwCorporationStats()
        {
            Mock <IWebClient> mockedWebClient = new Mock <IWebClient>();

            int               characterId   = 828658;
            string            characterName = "ThisIsACharacter";
            CorporationScopes scopes        = CorporationScopes.esi_corporations_read_fw_stats_v1;

            SsoToken inputToken = new SsoToken {
                AccessToken = "This is a old access token", RefreshToken = "This is a old refresh token", CharacterId = characterId, CharacterName = characterName, CorporationScopesFlags = scopes
            };
            string json = "{\r\n  \"enlisted_on\": \"2017-10-17T00:00:00Z\",\r\n  \"faction_id\": 500001,\r\n  \"kills\": {\r\n    \"last_week\": 893,\r\n    \"total\": 684350,\r\n    \"yesterday\": 136\r\n  },\r\n  \"pilots\": 28863,\r\n  \"victory_points\": {\r\n    \"last_week\": 102640,\r\n    \"total\": 52658260,\r\n    \"yesterday\": 15980\r\n  }\r\n}";

            mockedWebClient.Setup(x => x.Get(It.IsAny <WebHeaderCollection>(), It.IsAny <string>(), It.IsAny <int>())).Returns(new EsiModel {
                Model = json
            });

            InternalLatestFactionWarfare internalLatestFactionWarfare = new InternalLatestFactionWarfare(mockedWebClient.Object, string.Empty);

            V1FwCorporationStats result = internalLatestFactionWarfare.CorporationStats(inputToken, 33);

            Assert.Equal(new DateTime(2017, 10, 17, 00, 00, 00), result.EnlistedOn);
            Assert.Equal(500001, result.FactionId);
            Assert.Equal(893, result.Kills.LastWeek);
            Assert.Equal(684350, result.Kills.Total);
            Assert.Equal(136, result.Kills.Yesterday);
            Assert.Equal(28863, result.Pilots);
            Assert.Equal(102640, result.VictoryPoints.LastWeek);
            Assert.Equal(52658260, result.VictoryPoints.Total);
            Assert.Equal(15980, result.VictoryPoints.Yesterday);
        }
Ejemplo n.º 2
0
        public async Task CorporationAsync_successfully_returns_a_PagedModelV2ContactCorporation()
        {
            Mock <IWebClient> mockedWebClient = new Mock <IWebClient>();

            int characterId          = 88823;
            int page                 = 1;
            CorporationScopes scopes = CorporationScopes.esi_corporations_read_contacts_v1;

            SsoToken inputToken = new SsoToken {
                AccessToken = "This is a old access token", RefreshToken = "This is a old refresh token", CharacterId = characterId, CorporationScopesFlags = scopes
            };
            string json = "[\r\n  {\r\n    \"contact_id\": 123,\r\n    \"contact_type\": \"character\",\r\n    \"is_watched\": true,\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 <V2ContactCorporation> returnModel = await internalLatestContacts.CorporationAsync(inputToken, 88, page);

            Assert.Equal(123, returnModel.Model.First().ContactId);
            Assert.Equal(V2ContactCorporationContactTypes.Character, returnModel.Model[0].ContactType);
            Assert.True(returnModel.Model[0].IsWatched);
            Assert.Equal(9.9f, returnModel.Model[0].Standing);
        }
Ejemplo n.º 3
0
        public static void CheckToken(SsoToken token, CorporationScopes scope)
        {
            if (token == null)
            {
                throw new EsiException("Token can not be null");
            }

            if (token.CorporationScopesFlags == CorporationScopes.None || !token.CorporationScopesFlags.HasFlag(scope))
            {
                throw new EsiException($"This token does not have {scope} it has: {token.CorporationScopesFlags}");
            }
        }
        public async Task CorporationLabelsAsync_successfully_returns_a_IListV1ContactCorporationLabel()
        {
            int characterId          = 88823;
            CorporationScopes scopes = CorporationScopes.esi_corporations_read_contacts_v1;

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

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

            IList <V1ContactCorporationLabel> returnModel = await internalLatestContacts.CorporationLabelsAsync(inputToken, 22);

            Assert.Equal(2, returnModel.First().LabelId);
            Assert.Equal("Corporation Friends", returnModel.First().LabelName);
        }
        public async Task CorporationAsync_successfully_returns_a_PagedModelV2ContactCorporation()
        {
            int characterId          = 88823;
            int page                 = 1;
            CorporationScopes scopes = CorporationScopes.esi_corporations_read_contacts_v1;

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

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

            PagedModel <V2ContactCorporation> returnModel = await internalLatestContacts.CorporationAsync(inputToken, 88, page);

            Assert.Equal(123, returnModel.Model.First().ContactId);
            Assert.Equal(V2ContactCorporationContactTypes.Character, returnModel.Model[0].ContactType);
            Assert.True(returnModel.Model[0].IsWatched);
            Assert.Equal(9.9f, returnModel.Model[0].Standing);
        }
Ejemplo n.º 6
0
        public async Task CorporationLabelsAsync_successfully_returns_a_IListV1ContactCorporationLabel()
        {
            Mock <IWebClient> mockedWebClient = new Mock <IWebClient>();

            int characterId          = 88823;
            CorporationScopes scopes = CorporationScopes.esi_corporations_read_contacts_v1;

            SsoToken inputToken = new SsoToken {
                AccessToken = "This is a old access token", RefreshToken = "This is a old refresh token", CharacterId = characterId, CorporationScopesFlags = scopes
            };
            string json = "[\r\n  {\r\n    \"label_id\": 2,\r\n    \"label_name\": \"Corporation 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 <V1ContactCorporationLabel> returnModel = await internalLatestContacts.CorporationLabelsAsync(inputToken, 22);

            Assert.Equal(2, returnModel.First().LabelId);
            Assert.Equal("Corporation Friends", returnModel.First().LabelName);
        }
        public async Task CorporationStatsAsync_successfully_returns_a_V1FwCorporationStats()
        {
            int               characterId   = 828658;
            string            characterName = "ThisIsACharacter";
            CorporationScopes scopes        = CorporationScopes.esi_corporations_read_fw_stats_v1;

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

            LatestFactionWarfareEndpoints internalLatestFactionWarfare = new LatestFactionWarfareEndpoints(string.Empty, true);

            V1FwCorporationStats result = await internalLatestFactionWarfare.CorporationStatsAsync(inputToken, 33);

            Assert.Equal(new DateTime(2017, 10, 17, 00, 00, 00), result.EnlistedOn);
            Assert.Equal(500001, result.FactionId);
            Assert.Equal(893, result.Kills.LastWeek);
            Assert.Equal(684350, result.Kills.Total);
            Assert.Equal(136, result.Kills.Yesterday);
            Assert.Equal(28863, result.Pilots);
            Assert.Equal(102640, result.VictoryPoints.LastWeek);
            Assert.Equal(52658260, result.VictoryPoints.Total);
            Assert.Equal(15980, result.VictoryPoints.Yesterday);
        }