Example #1
0
        public async Task TestGetAvailableElementDescriptors(string version, bool shouldSuccess = true)
        {
            var unmockedService = new TemplatesManagementService(null, new UploadFileOptions(), null, null);

            _mockTemplatesManagementService.Reset();
            _mockTemplatesManagementService.Setup(x => x.GetAvailableElementDescriptors())
            .Returns(unmockedService.GetAvailableElementDescriptors());

            using (var response = await _client.GetAsync($"/api/{version}/templates/element-descriptors/available"))
            {
                if (shouldSuccess)
                {
                    response.EnsureSuccessStatusCode();
                    var stringResponse = await response.Content.ReadAsStringAsync();

                    var json = JArray.Parse(stringResponse);
                    Assert.NotEmpty(json);
                    Assert.Equal(Enum.GetNames(typeof(ElementDescriptorType)).Length, json.Count);
                }
                else
                {
                    Assert.False(response.IsSuccessStatusCode);
                }
            }

            _mockTemplatesManagementService.Reset();
        }
Example #2
0
 public TemplatesController(TemplatesStorageReader templatesStorageReader, TemplatesManagementService templatesManagementService)
 {
     _templatesStorageReader     = templatesStorageReader;
     _templatesManagementService = templatesManagementService;
 }