public async Task Then_The_Request_Is_Sent_To_The_Api(
            Guid itemId,
            Guid shortlistUserId,
            int ukprn,
            int trainingCode,
            string sectorSubjectArea,
            double?lat,
            double?lon,
            string locationDescription,
            PostShortlistForUserRequest postShortlistForUserRequest,
            [Frozen] Mock <IApiClient> apiClient,
            ShortlistService service)
        {
            //Arrange
            apiClient.Setup(x =>
                            x.Post <string, PostShortlistForUserRequest>(
                                It.Is <CreateShortlistForUserRequest>(c =>
                                                                      c.PostUrl.Contains($"shortlist", StringComparison.InvariantCultureIgnoreCase) &&
                                                                      c.Data.Lat.Equals(lat) &&
                                                                      c.Data.Lon.Equals(lon) &&
                                                                      c.Data.LocationDescription.Equals(locationDescription) &&
                                                                      c.Data.Ukprn.Equals(ukprn) &&
                                                                      c.Data.StandardId.Equals(trainingCode) &&
                                                                      c.Data.ShortlistUserId.Equals(shortlistUserId)
                                                                      ))).ReturnsAsync(itemId.ToString);

            //Act
            var actual = await service.CreateShortlistItemForUser(shortlistUserId, ukprn, trainingCode, lat, lon, locationDescription);

            //Assert
            actual.Should().Be(itemId);
        }
コード例 #2
0
        public void Then_The_Url_Is_Correctly_Constructed_With_Data(PostShortlistData source)
        {
            var actual = new PostShortlistForUserRequest
            {
                Data = source
            };

            actual.Data.Should().BeEquivalentTo(source);
            actual.PostUrl.Should().Be("api/shortlist");
        }
        public void Then_The_Request_Is_Built_Correctly(string baseUrl, PostShortlistForUserRequest data)
        {
            //Arrange Act
            var actual = new CreateShortlistForUserRequest(baseUrl)
            {
                Data = data
            };

            //Assert
            actual.PostUrl.Should().Be($"{baseUrl}shortlist");
            actual.Data.Should().BeEquivalentTo(data);
        }
        public async Task <Guid> CreateShortlistItemForUser(Guid shortlistUserId, int ukprn, int trainingCode, double?lat, double?lon, string locationDescription)
        {
            var request = new PostShortlistForUserRequest
            {
                Lat = lat,
                Lon = lon,
                LocationDescription = locationDescription,
                Ukprn           = ukprn,
                StandardId      = trainingCode,
                ShortlistUserId = shortlistUserId
            };

            var response = await _apiClient.Post <string, PostShortlistForUserRequest>(new CreateShortlistForUserRequest(_configValue.BaseUrl) { Data = request });

            return(Guid.Parse(response));
        }