public async Task CreateActorGoal() { var session = await Login(); var role = await CreateTestRole(); using (var client = new HttpClient { BaseAddress = new Uri(ServerUrl) }) { client.AcceptJson().AddSessionHeader(session.Id.ToString()); var newerGoal = new ActorGoal { ActorId = session.PlayerId, GoalId = role.Goal.Id, Status = 0, ConcernOutcomeId = role.Goal.ConcernId, RewardResourceOutcomeId = role.Goal.RewardResourceId, ActivityId = role.ActivityId, RoleId = role.Id }; var goalResponse = await client.PostAsJsonAsync("/api/goals/actors", newerGoal); Assert.Equal(HttpStatusCode.Created, goalResponse.StatusCode); var actorgoal = await goalResponse.Content.ReadAsJsonAsync<ActorGoal>(); Assert.Equal(1, actorgoal.Goal.Concern.Coordinates.X); Assert.Equal(role.Description, actorgoal.Role.Description); Assert.Equal(role.Goal.Description, actorgoal.Goal.Description); } }
public async Task CreateActorGoalInvalidActor() { var session = await Login(); var invalidId = Guid.NewGuid(); var role = await CreateTestRole(); using (var client = new HttpClient { BaseAddress = new Uri(ServerUrl) }) { client.AcceptJson().AddSessionHeader(session.Id.ToString()); var newerGoal = new ActorGoal { ActorId = invalidId, GoalId = role.Goal.Id, Status = 0, ConcernOutcomeId = role.Goal.ConcernId, RewardResourceOutcomeId = role.Goal.RewardResourceId, ActivityId = role.ActivityId, RoleId = role.Id }; var goalResponse = await client.PostAsJsonAsync("/api/goals/actors", newerGoal); Assert.Equal(HttpStatusCode.NotFound, goalResponse.StatusCode); var content = await goalResponse.Content.ReadAsJsonAsync<ApiError>(); Assert.Equal($"No Actor found for the passed ID", content.Error); } }
public async Task GetActorGoalValidGoal() { var session = await Login(); var role = await CreateTestRole(); using (var client = new HttpClient { BaseAddress = new Uri(ServerUrl) }) { client.AcceptJson().AddSessionHeader(session.Id.ToString()); var newerGoal = new ActorGoal { ActorId = session.PlayerId, GoalId = role.Goal.Id, Status = 0, ConcernOutcomeId = role.Goal.ConcernId, RewardResourceOutcomeId = role.Goal.RewardResourceId, ActivityId = role.ActivityId, RoleId = role.Id }; var actorgoalResponse = await client.PostAsJsonAsync("/api/goals/actors", newerGoal); Assert.Equal(HttpStatusCode.Created, actorgoalResponse.StatusCode); var goalsResponse = await client.GetAsync($"/api/goals/{role.Goal.Id}/actor"); Assert.Equal(HttpStatusCode.OK, goalsResponse.StatusCode); var goalGet = await goalsResponse.Content.ReadAsJsonAsync<ActorGoal>(); Assert.IsType(typeof(ActorGoal), goalGet); } }