public async System.Threading.Tasks.Task GetTasksWithPlayerId_ReturnsTask() { // Arrange var expectedTaskType = TaskType.Collectible; var expectedDescription = "Get Midnight's Eternal Reins from Karazhan"; var expectedGdrDescription = "Midnight's Eternal Reins"; var expectedGameDataReferences = new List <GameDataReference>() { new GameDataReference(142236, GameDataReference.GameDataType.Item, "Mount", expectedGdrDescription) }; var expectedCollectibleType = CollectibleType.Mount; var expectedSource = Source.Dungeon; var expectedPriority = Priority.Medium; var expectedRefreshFrequency = RefreshFrequency.Weekly; var task = new Task(defaultPlayerId, expectedTaskType) { Description = expectedDescription, GameDataReferences = expectedGameDataReferences, CollectibleType = expectedCollectibleType, Source = expectedSource, Priority = expectedPriority, RefreshFrequency = expectedRefreshFrequency }; await AddAsync(task); var queryString = $"playerId={defaultPlayerId}"; // Act var httpResponse = await Client.GetAsync($"/api/tasks?{queryString}"); httpResponse.EnsureSuccessStatusCode(); var response = await httpResponse.Content.ReadAsStreamAsync(); var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true, }; var result = await JsonSerializer.DeserializeAsync <GetTasksResponse>(response, options); // Assert result.PlayerId.Should().Be(defaultPlayerId); result.Tasks.Should().NotBeEmpty().And.HaveCount(1); var foundTask = result.Tasks.FirstOrDefault(); foundTask.Description.Should().Be(expectedDescription); foundTask.GameDataReferences.Should().NotBeEmpty().And.HaveCount(1); }
public async System.Threading.Tasks.Task GetPlayerZonesList_ReturnsList() { // Arrange var expectedTaskType = TaskType.Collectible; var expectedGdrDescription = "Deadwind Pass"; var expectedGameDataReferences = new List <GameDataReference>() { new GameDataReference(103, GameDataReference.GameDataType.Zone, null, expectedGdrDescription) }; var task = new Task(defaultPlayerId, expectedTaskType) { GameDataReferences = expectedGameDataReferences }; await AddAsync(task); // Act var httpResponse = await Client.GetAsync($"/api/tasks/zone-index/{defaultPlayerId}"); httpResponse.EnsureSuccessStatusCode(); var response = await httpResponse.Content.ReadAsStreamAsync(); var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true, }; var result = await JsonSerializer.DeserializeAsync <ICollection <FilterListSourceResponse> >(response, options); // Assert Assert.IsInstanceOf <ICollection <FilterListSourceResponse> >(result); result.Count.Should().Be(1); result.Any(d => d.Name.Equals(expectedGdrDescription)).Should().BeTrue(); }