public async Task CharacterLocationsAsync_successfully_returns_a_ListV2AssetsCharacterLocation()
        {
            Mock <IWebClient> mockedWebClient = new Mock <IWebClient>();

            int          characterId = 88823;
            IList <long> ids         = new List <long> {
                3, 5, 6
            };
            AssetScopes scopes = AssetScopes.esi_assets_read_assets_v1;

            SsoToken inputToken = new SsoToken {
                AccessToken = "This is a old access token", RefreshToken = "This is a old refresh token", CharacterId = characterId, AssetScopesFlags = scopes
            };
            string json = "[{\"item_id\": 12345,\"position\": {\"x\": 1.2,\"y\": 2.3,\"z\": -3.4}}]";

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

            InternalLatestAssets internalLatestAssets = new InternalLatestAssets(mockedWebClient.Object, string.Empty);

            IList <V2AssetsCharacterLocation> getCharactersAssetsLocations = await internalLatestAssets.CharacterLocationAsync(inputToken, ids);

            Assert.Equal(1, getCharactersAssetsLocations.Count);
            Assert.Equal(12345, getCharactersAssetsLocations.First().ItemId);
        }
        public async Task CorporationNamesAsync_successfully_returns_a_ListV1AssetsCorporationName()
        {
            Mock <IWebClient> mockedWebClient = new Mock <IWebClient>();

            int          characterId = 88823;
            IList <long> ids         = new List <long> {
                3, 5, 6
            };
            AssetScopes scopes = AssetScopes.esi_assets_read_corporation_assets_v1;

            SsoToken inputToken = new SsoToken {
                AccessToken = "This is a old access token", RefreshToken = "This is a old refresh token", CharacterId = characterId, AssetScopesFlags = scopes
            };
            string json = "[{\"item_id\": 12345,\"name\": \"Awesome Name\"}]";

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

            InternalLatestAssets internalLatestAssets = new InternalLatestAssets(mockedWebClient.Object, string.Empty);

            IList <V1AssetsCorporationName> getCorporationsAssetsNames = await internalLatestAssets.CorporationNamesAsync(inputToken, characterId, ids);

            Assert.Equal(1, getCorporationsAssetsNames.Count);
            Assert.Equal(12345, getCorporationsAssetsNames.First().ItemId);
            Assert.Equal("Awesome Name", getCorporationsAssetsNames.First().Name);
        }
        public async Task CharactersAsync_successfully_returns_a_pagedModelV4AssetsCharacter()
        {
            Mock <IWebClient> mockedWebClient = new Mock <IWebClient>();

            int         characterId = 88823;
            int         page        = 1;
            AssetScopes scopes      = AssetScopes.esi_assets_read_assets_v1;

            SsoToken inputToken = new SsoToken {
                AccessToken = "This is a old access token", RefreshToken = "This is a old refresh token", CharacterId = characterId, AssetScopesFlags = scopes
            };
            string json = "[{\"location_flag\": \"Hangar\",\"location_id\": 60002959,\"is_singleton\": true,\"type_id\": 3516,\"item_id\": 1000000016835,\"location_type\": \"station\",\"quantity\": 1}]";

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

            InternalLatestAssets internalLatestAssets = new InternalLatestAssets(mockedWebClient.Object, string.Empty);

            PagedModel <V5AssetsCharacter> getCharacterAssets = await internalLatestAssets.CharactersAsync(inputToken, page);

            Assert.Equal(2, getCharacterAssets.MaxPages);
            Assert.Equal(1, getCharacterAssets.CurrentPage);
            Assert.Equal(1, getCharacterAssets.Model.Count);
            Assert.Equal(LocationFlagCharacter.Hangar, getCharacterAssets.Model.First().LocationFlag);
        }
Beispiel #4
0
        public static void CheckToken(SsoToken token, AssetScopes scope)
        {
            if (token == null)
            {
                throw new EsiException("Token can not be null");
            }

            if (token.AssetScopesFlags == AssetScopes.None || !token.AssetScopesFlags.HasFlag(scope))
            {
                throw new EsiException($"This token does not have {scope} it has: {token.AssetScopesFlags}");
            }
        }
Beispiel #5
0
        public async Task CharactersAsync_successfully_returns_a_pagedModelV4AssetsCharacter()
        {
            int         characterId = 88823;
            int         page        = 1;
            AssetScopes scopes      = AssetScopes.esi_assets_read_assets_v1;

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

            LatestAssetsEndpoints internalLatestAssets = new LatestAssetsEndpoints(string.Empty, true);

            PagedModel <V5AssetsCharacter> getCharacterAssets = await internalLatestAssets.CharactersAsync(inputToken, page);

            Assert.Equal(1, getCharacterAssets.CurrentPage);
            Assert.Equal(1, getCharacterAssets.Model.Count);
            Assert.Equal(LocationFlagCharacter.Hangar, getCharacterAssets.Model.First().LocationFlag);
        }
Beispiel #6
0
        public async Task CorporationLocationsAsync_successfully_returns_a_ListV2AssetsCorporationLocation()
        {
            int          characterId = 88823;
            IList <long> ids         = new List <long> {
                3, 5, 6
            };
            AssetScopes scopes = AssetScopes.esi_assets_read_corporation_assets_v1;

            SsoToken inputToken = new SsoToken {
                AccessToken = "This is a old access token", RefreshToken = "This is a old refresh token", CharacterId = characterId, AssetScopesFlags = scopes
            };
            LatestAssetsEndpoints internalLatestAssets = new LatestAssetsEndpoints(string.Empty, true);

            IList <V2AssetsCorporationLocation> getCorporationAssetsLocations = await internalLatestAssets.CorporationLocationsAsync(inputToken, characterId, ids);

            Assert.Equal(1, getCorporationAssetsLocations.Count);
            Assert.Equal(12345, getCorporationAssetsLocations.First().ItemId);
        }
Beispiel #7
0
        public void Corporations_successfully_returns_a_pagedModelV4AssetsCorporations()
        {
            int         characterId   = 88823;
            int         corporationId = 888233;
            int         page          = 1;
            AssetScopes scopes        = AssetScopes.esi_assets_read_corporation_assets_v1;

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

            LatestAssetsEndpoints internalLatestAssets = new LatestAssetsEndpoints(string.Empty, true);

            PagedModel <V5AssetsCorporations> getCorporationAssets = internalLatestAssets.Corporations(inputToken, corporationId, page);

            Assert.Equal(1, getCorporationAssets.CurrentPage);
            Assert.Equal(1, getCorporationAssets.Model.Count);
            Assert.Equal(LocationFlagCorporation.Hangar, getCorporationAssets.Model.First().LocationFlag);
        }
Beispiel #8
0
        public void CharacterNames_successfully_returns_a_ListV1AssetsCharacterName()
        {
            int          characterId = 88823;
            IList <long> ids         = new List <long> {
                3, 5, 6
            };
            AssetScopes scopes = AssetScopes.esi_assets_read_assets_v1;

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

            LatestAssetsEndpoints internalLatestAssets = new LatestAssetsEndpoints(string.Empty, true);

            IList <V1AssetsCharacterName> getCharactersAssetsNames = internalLatestAssets.CharacterNames(inputToken, ids);

            Assert.Equal(1, getCharactersAssetsNames.Count);
            Assert.Equal(12345, getCharactersAssetsNames.First().ItemId);
            Assert.Equal("Awesome Name", getCharactersAssetsNames.First().Name);
        }