public void TextSanitizerUtilitiesSanitizeReturnsArgumentNullException()
        {
            //arrange
            ApiTestModel?nullApiTestModel = null;

            //act
            var exceptionResult = Assert.Throws <ArgumentNullException>(() => TextSanitizerUtilities.Sanitize(nullApiTestModel));

            // assert
            Assert.Equal("Value cannot be null. (Parameter 'model')", exceptionResult.Message);
        }
        public void TextSanitizerUtilitiesSanitizeReturnsSuccess(string name, string description, string expectedName, string expectedDescription)
        {
            //arrange
            var apiTestModel = new ApiTestModel {
                Id = Guid.NewGuid(), Name = name, Description = description
            };

            //act
            TextSanitizerUtilities.Sanitize(apiTestModel);

            //assert
            Assert.Equal(expectedName, apiTestModel.Name);
            Assert.Equal(expectedDescription, apiTestModel.Description);
        }
Exemplo n.º 3
0
        public async Task <TModel?> ImportAsync <TModel>(Uri uri)
            where TModel : class
        {
            logger.LogInformation($"Getting LMI data from: {uri}");

            var apiData = await apiDataConnector.GetAsync <TModel>(httpClient, uri).ConfigureAwait(false);

            if (apiData != null)
            {
                logger.LogInformation($"Sanitizing LMI data from: {uri}");

                TextSanitizerUtilities.Sanitize(apiData);

                logger.LogInformation($"Get LMI data from: {uri} was successful");

                return(apiData);
            }

            return(default);