Beispiel #1
0
 private void Init(ApiOptions apiOptions)
 {
     Meta      = new MetaEndpoint(apiOptions);
     Alliance  = new AllianceEndpoint(apiOptions);
     Assets    = new AssetsEndpoint(apiOptions);
     Bookmarks = new BookmarksEndpoint(apiOptions);
     Calendar  = new CalendarEndpoint(apiOptions);
 }
Beispiel #2
0
        public async Task GetAssets()
        {
            var stubbedData = new [] {
                new Asset(
                    Enums.Locations.LocationFlags.Cargo.ToString(),
                    Enums.Locations.LocationTypes.Item.ToString())
                {
                    IsBlueprintCopy = true,
                    IsSingleton     = true,
                    ItemId          = 1234567,
                    LocationId      = 1234567,
                    Quantity        = 42,
                    TypeId          = 1234567
                },
                new Asset(
                    Enums.Locations.LocationFlags.Hangar.ToString(),
                    Enums.Locations.LocationTypes.Other.ToString())
                {
                    IsBlueprintCopy = false,
                    IsSingleton     = false,
                    ItemId          = 12345678,
                    LocationId      = 12345678,
                    Quantity        = 84,
                    TypeId          = 12345678
                }
            };

            var httpResponse = new HttpResponseMessage()
            {
                Content = new StringContent(JsonSerializer.Serialize(stubbedData))
            };
            var httpResponseTask = Task.FromResult(httpResponse);
            var response         = new EsiResponse <Asset[]>(HttpStatusCode.OK, stubbedData);

            _mockDataService
            .Setup(m => m.GetAsync(It.IsAny <Url>()))
            .Returns(httpResponseTask);

            _mockResponseFactory
            .Setup(m => m.Create <Asset[]>(It.IsAny <HttpResponseMessage>()))
            .Returns(response);

            var assetsEndpoint = new AssetsEndpoint(
                _mockDataService.Object,
                _mockResponseFactory.Object);

            // These use the same underlying code so we might as well test them all.
            var characterResult = await assetsEndpoint.Characters.GetAssets(1);

            var corporationResult = await assetsEndpoint.Corporations.GetAssets(2);

            Assert.AreEqual(response, characterResult);
            Assert.AreEqual(response, corporationResult);
        }
Beispiel #3
0
        public void GetAssetNamesThrowsErrorOnMinItemIds()
        {
            var stubbedIds = new List <long>();

            var assetsEndpoint = new AssetsEndpoint(
                _mockDataService.Object,
                _mockResponseFactory.Object);

            Assert.ThrowsAsync <ArgumentException>(
                async() => await assetsEndpoint.Characters.GetAssetNames(1, stubbedIds));
            Assert.ThrowsAsync <ArgumentException>(
                async() => await assetsEndpoint.Corporations.GetAssetNames(2, stubbedIds));
        }
Beispiel #4
0
        public async Task GetAssetLocations()
        {
            var stubbedPosition = new Position(1, 2, 3);
            var stubbedIds      = new List <long> {
                1, 2, 3, 4, 5
            };
            var stubbedData = new []
            {
                new AssetLocation(stubbedPosition)
                {
                    ItemId = 1
                },
                new AssetLocation(stubbedPosition)
                {
                    ItemId = 2
                }
            };

            var httpResponse = new HttpResponseMessage()
            {
                Content = new StringContent(JsonSerializer.Serialize(stubbedData))
            };
            var httpResponseTask = Task.FromResult(httpResponse);
            var response         = new EsiResponse <AssetLocation[]>(HttpStatusCode.OK, stubbedData);

            _mockDataService
            .Setup(m => m.PostAsync(It.IsAny <Url>()))
            .Returns(httpResponseTask);

            _mockResponseFactory
            .Setup(m => m.Create <AssetLocation[]>(It.IsAny <HttpResponseMessage>()))
            .Returns(response);

            var assetsEndpoint = new AssetsEndpoint(
                _mockDataService.Object,
                _mockResponseFactory.Object);

            var characterResult = await assetsEndpoint.Characters.GetAssetLocations(1, stubbedIds);

            var corporationResult = await assetsEndpoint.Corporations.GetAssetLocations(2, stubbedIds);

            Assert.AreEqual(response, characterResult);
            Assert.AreEqual(response, corporationResult);
        }
Beispiel #5
0
        public void GetAssetNamesThrowsErrorOnMaxItemIds()
        {
            // Create the list and populate it.
            var stubbedIds = new List <long>();

            for (var i = 0; i <= 1000; i++)
            {
                stubbedIds.Add(i);
            }

            var assetsEndpoint = new AssetsEndpoint(
                _mockDataService.Object,
                _mockResponseFactory.Object);

            Assert.ThrowsAsync <ArgumentException>(
                async() => await assetsEndpoint.Characters.GetAssetNames(1, stubbedIds));
            Assert.ThrowsAsync <ArgumentException>(
                async() => await assetsEndpoint.Corporations.GetAssetNames(2, stubbedIds));
        }