Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }