Ejemplo n.º 1
0
 public async Task <OccupantResponse> UpdateOccupant(OccupantUpdateRequest occupant)
 {
     return(await asyncConnection(occupant.UserId, occupant.OccupantId, async db =>
     {
         OccupantResponse updatedOccupant = await db.QueryFirstAsync <OccupantResponse>(
             sql: "[Houses].[Occupants_Update]",
             param: occupant,
             commandType: CommandType.StoredProcedure
             );
         return updatedOccupant;
     }));
 }
        public void InvalidTokenTest()
        {
            OccupantUpdateRequest occupantToUpdate = new OccupantUpdateRequest
            {
                UserId      = firebaseFixture.H2UserId,
                DisplayName = StringGenerator.RandomString(100),
                OccupantId  = 2
            };

            RestClient    client   = GetClient();
            RestRequest   request  = apiCall(firebaseFixture.H1Token, sutEndpoint, sutHttpMethod, occupantToUpdate);
            IRestResponse response = client.Execute(request);

            forbiddenExpectations(response);
        }
        public void UpdateOccupantTest()
        {
            string O4DisplayName = StringGenerator.RandomString(100);
            OccupantUpdateRequest occupantToUpdate = new OccupantUpdateRequest
            {
                UserId      = firebaseFixture.H2UserId,
                DisplayName = O4DisplayName,
                OccupantId  = 2
            };

            RestClient  client  = GetClient();
            RestRequest request = apiCall <OccupantUpdateRequest>(firebaseFixture.H2Token, sutEndpoint, sutHttpMethod, occupantToUpdate);
            IRestResponse <OccupantResponse> response = client.Execute <OccupantResponse>(request);

            string expectedContent = serialize(new OccupantResponse
            {
                OccupantId  = 2,
                UserId      = firebaseFixture.H2UserId,
                DisplayName = O4DisplayName
            });

            response.StatusCode.ShouldBeEquivalentTo(HttpStatusCode.OK);
            response.Content.ShouldBeEquivalentTo(expectedContent);
        }
Ejemplo n.º 4
0
 public async Task <IActionResult> RequestUpdateOccupant([FromBody] OccupantUpdateRequest occupant)
 {
     return(await RequestHandler <OccupantResponse>(HttpVerbs.Put, occupant.UserId, async() =>
                                                    await occupantsRepository.UpdateOccupant(occupant)));
 }