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

	result := ConvertCategoryToViewModel(category)

	if result.ImageUrl != category.ImageUrl() {
		t.Log("Image url not converted properly")
		t.Fail()
	}

	//ToDo - Add tests for the remaining attributes
}
Example #2
0
func Test_ConvertsCategoryToViewModel(t *testing.T) {
	category := models.Category{}
	category.SetImageUrl("the image URL")
	category.SetTitle("the title")
	category.SetDescription("the description")
	category.SetIsOrientRight(true)
	category.SetId(42)
	category.SetProducts([]models.Product{
		models.Product{},
		models.Product{},
	})

	result := ConvertCategoyToViewModel(category)

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

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

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

	if result.IsOrientRight != category.IsOrientRight() {
		t.Log("IsOrientRight not converted properly")
		t.Fail()
	}

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

	if len(result.Products) != len(category.Products()) {
		t.Log("Products not converted properly")
		t.Fail()
	}
}
Example #3
0
func Test_ConvertsCategoryToViewModel(t *testing.T) {
	category := models.Category{}
	category.SetImageUrl("the image URL")
	category.SetTitle("the title")
	category.SetDescription("the description")
	category.SetId(42)
	isOrientRight := true

	result := ConvertCategoryToViewModel(category, isOrientRight)

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

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

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

	if result.IsOrientRight != isOrientRight {
		t.Log("IsOrientRight not converted properly")
		t.Fail()
	}

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

}