Multi language dynamic object changes

This commit is contained in:
uppuv
2023-09-08 15:40:06 -04:00
parent 24a6e6513e
commit 4cf7d9f891
21 changed files with 370 additions and 283 deletions

View File

@ -8,42 +8,42 @@ namespace DamageAssesment.Api.Questions.Test
{
public class CategoryMockData
{
public static async Task<(bool, IEnumerable<Questions.Models.QuestionCategory>, string)> getOkResponse()
public static async Task<(bool, IEnumerable<Questions.Models.MultiLanQuestionCategory>, string)> getOkResponse()
{
IEnumerable<Questions.Models.QuestionCategory> list = new List<Questions.Models.QuestionCategory>();
IEnumerable<Questions.Models.MultiLanQuestionCategory> list = new List<Questions.Models.MultiLanQuestionCategory>();
for (int i = 0; i < 10; i++)
{
list.Append(new Questions.Models.QuestionCategory { Id = i, CategoryImage = "img"+i,CategoryName="Category "+i });
list.Append(new Questions.Models.MultiLanQuestionCategory { Id = i, IconLibrary = "img"+i,IconName="Category "+i });
}
return (true, list, null);
}
public static async Task<(bool, Questions.Models.QuestionCategory, string)> getOkResponse(int Id)
public static async Task<(bool, Questions.Models.MultiLanQuestionCategory, string)> getOkResponse(int Id)
{
var Questions = await getOkResponse();
var Question = Questions.Item2.FirstOrDefault(s => s.Id == Id);
return (true, Question, null);
}
public static async Task<(bool, Questions.Models.QuestionCategory, string)> getBadRequestResponse()
public static async Task<(bool, Questions.Models.MultiLanQuestionCategory, string)> getBadRequestResponse()
{
return (false, null, "Bad Request");
}
public static async Task<(bool, Questions.Models.QuestionCategory, string)> getNotFoundResponse()
public static async Task<(bool, Questions.Models.MultiLanQuestionCategory, string)> getNotFoundResponse()
{
return (false, null, "Not Found");
}
public static async Task<(bool, IEnumerable<Questions.Models.QuestionCategory>, string)> getNoContentResponse()
public static async Task<(bool, IEnumerable<Questions.Models.MultiLanQuestionCategory>, string)> getNoContentResponse()
{
IEnumerable<Questions.Models.QuestionCategory> list = new List<Questions.Models.QuestionCategory>();
IEnumerable<Questions.Models.MultiLanQuestionCategory> list = new List<Questions.Models.MultiLanQuestionCategory>();
return (false, list, null);
}
public static async Task<Questions.Models.QuestionCategory> getInputQuestionCategoryData()
{
return new Questions.Models.QuestionCategory { Id = 1, CategoryName = "Category 1",CategoryImage="img 1" };
return new Questions.Models.QuestionCategory { Id = 1, IconName = "Category 1",IconLibrary="img 1" };
}
}

View File

@ -5,13 +5,13 @@ namespace DamageAssesment.Api.Questions.Test
public class MockData
{
public static async Task<(bool, IEnumerable<Questions.Models.Question>, string)> getOkResponse()
public static async Task<(bool, IEnumerable<Questions.Models.MultiLanQuestion>, string)> getOkResponse()
{
IEnumerable<Questions.Models.Question> list = new List<Questions.Models.Question>();
IEnumerable<Questions.Models.MultiLanQuestion> list = new List<Questions.Models.MultiLanQuestion>();
for (int i = 0; i < 10; i++)
{
list.Append(new Questions.Models.Question { Id = i, TypeText = "Text" + i, SurveyId = 1, QuestionNumber = 1, IsRequired = true, Comment = false, Key = true, CategoryId=i });
list.Append(new Questions.Models.MultiLanQuestion { Id = i, TypeText = "Text" + i, SurveyId = 1, QuestionNumber = 1, IsRequired = true, Comment = false, Key = true, CategoryId=i });
}
return (true, list, null);
}
@ -23,38 +23,38 @@ namespace DamageAssesment.Api.Questions.Test
for (int i = 0; i < 10; i++)
{
List<Models.Question> question = new List<Models.Question>();
question.Add(new Models.Question { Id = i, TypeText = "Text" + i, SurveyId = 1, QuestionNumber = 1, IsRequired = true, Comment = false, Key = true, CategoryId = i });
List<Models.MultiLanQuestion> question = new List<Models.MultiLanQuestion>();
question.Add(new Models.MultiLanQuestion { Id = i, TypeText = "Text" + i, SurveyId = 1, QuestionNumber = 1, IsRequired = true, Comment = false, Key = true, CategoryId = i });
list.Append(new Questions.Models.SurveyQuestions
{
CategoryId = i,
CategoryImage = "img" + i,
CategoryName = "Category " + i,
IconLibrary = "img" + i,
IconName = "Category " + i,
Questions = question
});
}
return (true, list, null);
}
public static async Task<(bool, Questions.Models.Question, string)> getOkResponse(int Id)
public static async Task<(bool, Questions.Models.MultiLanQuestion, string)> getOkResponse(int Id)
{
var Questions = await getOkResponse();
var Question = Questions.Item2.FirstOrDefault(s => s.Id == Id);
return (true, Question, null);
}
public static async Task<(bool, Questions.Models.Question, string)> getBadRequestResponse()
public static async Task<(bool, Questions.Models.MultiLanQuestion, string)> getBadRequestResponse()
{
return (false, null, "Bad Request");
}
public static async Task<(bool, Questions.Models.Question, string)> getNotFoundResponse()
public static async Task<(bool, Questions.Models.MultiLanQuestion, string)> getNotFoundResponse()
{
return (false, null, "Not Found");
}
public static async Task<(bool, IEnumerable<Questions.Models.Question>, string)> getNoContentResponse()
public static async Task<(bool, IEnumerable<Questions.Models.MultiLanQuestion>, string)> getNoContentResponse()
{
IEnumerable<Questions.Models.Question> list = new List<Questions.Models.Question>();
IEnumerable<Questions.Models.MultiLanQuestion> list = new List<Questions.Models.MultiLanQuestion>();
return (false, list, null);
}
public static async Task<(bool, List<Questions.Models.SurveyQuestions>, string)> getNoSurveyContentResponse()

View File

@ -42,7 +42,7 @@ namespace DamageAssesment.Api.Questions.Test
mockQuestionService.Setup(service => service.GetQuestionAsync(1,null)).ReturnsAsync(mockResponse);
var QuestionProvider = new QuestionsController(mockQuestionService.Object);
var result = (OkObjectResult)await QuestionProvider.GetQuestionAsync(1,null);
var result = (OkObjectResult)await QuestionProvider.GetQuestionByIdAsync(1,null);
Assert.Equal(200, result.StatusCode);
}
@ -55,7 +55,7 @@ namespace DamageAssesment.Api.Questions.Test
mockQuestionService.Setup(service => service.GetQuestionAsync(99,null)).ReturnsAsync(mockResponse);
var QuestionProvider = new QuestionsController(mockQuestionService.Object);
var result = (NotFoundResult)await QuestionProvider.GetQuestionAsync(99,null);
var result = (NotFoundResult)await QuestionProvider.GetQuestionByIdAsync(99,null);
Assert.Equal(404, result.StatusCode);
}
@ -188,10 +188,10 @@ namespace DamageAssesment.Api.Questions.Test
{
var mockQuestionService = new Mock<IQuestionsProvider>();
var mockResponse = await CategoryMockData.getOkResponse();
mockQuestionService.Setup(service => service.GetQuestionCategoriesAsync()).ReturnsAsync(mockResponse);
mockQuestionService.Setup(service => service.GetQuestionCategoriesAsync("en")).ReturnsAsync(mockResponse);
var QuestionProvider = new QuestionsController(mockQuestionService.Object);
var result = (OkObjectResult)await QuestionProvider.GetQuestionCategoriesAsync();
var result = (OkObjectResult)await QuestionProvider.GetQuestionCategoriesAsync("en");
Assert.Equal(200, result.StatusCode);
}
@ -201,10 +201,10 @@ namespace DamageAssesment.Api.Questions.Test
{
var mockQuestionService = new Mock<IQuestionsProvider>();
var mockResponse = await CategoryMockData.getNoContentResponse();
mockQuestionService.Setup(service => service.GetQuestionCategoriesAsync()).ReturnsAsync(mockResponse);
mockQuestionService.Setup(service => service.GetQuestionCategoriesAsync("en")).ReturnsAsync(mockResponse);
var QuestionProvider = new QuestionsController(mockQuestionService.Object);
var result = (NoContentResult)await QuestionProvider.GetQuestionCategoriesAsync();
var result = (NoContentResult)await QuestionProvider.GetQuestionCategoriesAsync("en");
Assert.Equal(204, result.StatusCode);
}
@ -214,10 +214,10 @@ namespace DamageAssesment.Api.Questions.Test
{
var mockQuestionService = new Mock<IQuestionsProvider>();
var mockResponse = await CategoryMockData.getOkResponse(1);
mockQuestionService.Setup(service => service.GetQuestionCategoryAsync(1)).ReturnsAsync(mockResponse);
mockQuestionService.Setup(service => service.GetQuestionCategoryAsync(1, "en")).ReturnsAsync(mockResponse);
var QuestionProvider = new QuestionsController(mockQuestionService.Object);
var result = (OkObjectResult)await QuestionProvider.GetQuestionCategoryAsync(1);
var result = (OkObjectResult)await QuestionProvider.GetQuestionCategoryAsync(1, "en");
Assert.Equal(200, result.StatusCode);
}
@ -227,10 +227,10 @@ namespace DamageAssesment.Api.Questions.Test
{
var mockQuestionService = new Mock<IQuestionsProvider>();
var mockResponse = await CategoryMockData.getNotFoundResponse();
mockQuestionService.Setup(service => service.GetQuestionCategoryAsync(99)).ReturnsAsync(mockResponse);
mockQuestionService.Setup(service => service.GetQuestionCategoryAsync(99, "en")).ReturnsAsync(mockResponse);
var QuestionProvider = new QuestionsController(mockQuestionService.Object);
var result = (NotFoundResult)await QuestionProvider.GetQuestionCategoryAsync(99);
var result = (NotFoundResult)await QuestionProvider.GetQuestionCategoryAsync(99, "en");
Assert.Equal(404, result.StatusCode);
}