Example #1
0
func TestConvertCategoryToViewModel(t *testing.T) {
	category := models.Category{}
	category.SetId(42)
	category.SetImageUrl("the image URL")
	category.SetTitle("the title")
	category.SetDescription("the description")
	category.SetIsOrientRight(true)

	result := ConvertCategoryToViewModel(category)

	if result.Id != category.Id() {
		t.Error("Id not converted properly")
	}

	if result.ImageUrl != category.ImageUrl() {
		t.Error("Image URL not converted properly")
	}

	if result.Title != category.Title() {
		t.Error("Title not converted properly")
	}

	if result.Description != category.Description() {
		t.Error("Description not converted properly")
	}

	if result.IsOrientRight != category.IsOrientRight() {
		t.Error("IsOrientRight not converted properly")
	}
}
Example #2
0
func ConvertCategoryToViewModel(category models.Category) viewmodels.Category {
	result := viewmodels.Category{
		Id:            category.Id(),
		ImageUrl:      category.ImageUrl(),
		Title:         category.Title(),
		Description:   category.Description(),
		IsOrientRight: category.IsOrientRight(),
	}
	return result
}