403 lines
7.4 KiB
Go
403 lines
7.4 KiB
Go
package logic
|
|
|
|
import (
|
|
"sevenkeys/database"
|
|
"testing"
|
|
)
|
|
|
|
func TestFilterPrinting_ReturnsTrue_IfSetCodeDoesNotMatch(t *testing.T) {
|
|
printing := database.CardPrinting{
|
|
SetCode: "rtr",
|
|
IsFoil: false,
|
|
IsPromo: false,
|
|
Language: "en",
|
|
}
|
|
|
|
searchCriteria := SearchCriteria{
|
|
SetCode: "otj",
|
|
Foil: False,
|
|
Promo: False,
|
|
Language: "en",
|
|
}
|
|
|
|
filter := filterPrinting(printing, searchCriteria)
|
|
|
|
if filter != true {
|
|
t.Errorf("filter was false")
|
|
}
|
|
}
|
|
|
|
func TestFilterPrinting_ReturnsFalse_IfSetCodeDoesMatch(t *testing.T) {
|
|
printing := database.CardPrinting{
|
|
SetCode: "rtr",
|
|
IsFoil: false,
|
|
IsPromo: false,
|
|
Language: "en",
|
|
}
|
|
|
|
searchCriteria := SearchCriteria{
|
|
SetCode: "rtr",
|
|
Foil: False,
|
|
Promo: False,
|
|
Language: "en",
|
|
}
|
|
|
|
filter := filterPrinting(printing, searchCriteria)
|
|
|
|
if filter != false {
|
|
t.Errorf("filter was true")
|
|
}
|
|
}
|
|
|
|
func TestFilterPrinting_ReturnsFalse_IfSetCodeNotSet(t *testing.T) {
|
|
printing := database.CardPrinting{
|
|
SetCode: "rtr",
|
|
IsFoil: false,
|
|
IsPromo: false,
|
|
Language: "en",
|
|
}
|
|
|
|
searchCriteria := SearchCriteria{
|
|
SetCode: "",
|
|
Foil: False,
|
|
Promo: False,
|
|
Language: "en",
|
|
}
|
|
|
|
filter := filterPrinting(printing, searchCriteria)
|
|
|
|
if filter != false {
|
|
t.Errorf("filter was true")
|
|
}
|
|
}
|
|
|
|
func TestFilterPrinting_ReturnsTrue_IfFoilCardInNonFoilSearch(t *testing.T) {
|
|
printing := database.CardPrinting{
|
|
SetCode: "rtr",
|
|
IsFoil: true,
|
|
IsPromo: false,
|
|
Language: "en",
|
|
}
|
|
|
|
searchCriteria := SearchCriteria{
|
|
SetCode: "rtr",
|
|
Foil: False,
|
|
Promo: False,
|
|
Language: "en",
|
|
}
|
|
|
|
filter := filterPrinting(printing, searchCriteria)
|
|
|
|
if filter != true {
|
|
t.Errorf("filter was false")
|
|
}
|
|
}
|
|
|
|
func TestFilterPrinting_ReturnsTrue_IfNonFoilCardInFoilSearch(t *testing.T) {
|
|
printing := database.CardPrinting{
|
|
SetCode: "rtr",
|
|
IsFoil: false,
|
|
IsPromo: false,
|
|
Language: "en",
|
|
}
|
|
|
|
searchCriteria := SearchCriteria{
|
|
SetCode: "rtr",
|
|
Foil: True,
|
|
Promo: False,
|
|
Language: "en",
|
|
}
|
|
|
|
filter := filterPrinting(printing, searchCriteria)
|
|
|
|
if filter != true {
|
|
t.Errorf("filter was false")
|
|
}
|
|
}
|
|
|
|
func TestFilterPrinting_ReturnsFalse_IfNonFoilCardInNonFoilSearch(t *testing.T) {
|
|
printing := database.CardPrinting{
|
|
SetCode: "rtr",
|
|
IsFoil: false,
|
|
IsPromo: false,
|
|
Language: "en",
|
|
}
|
|
|
|
searchCriteria := SearchCriteria{
|
|
SetCode: "rtr",
|
|
Foil: False,
|
|
Promo: False,
|
|
Language: "en",
|
|
}
|
|
|
|
filter := filterPrinting(printing, searchCriteria)
|
|
|
|
if filter != false {
|
|
t.Errorf("filter was true")
|
|
}
|
|
}
|
|
|
|
func TestFilterPrinting_ReturnsFalse_IfFoilCardInFoilSearch(t *testing.T) {
|
|
printing := database.CardPrinting{
|
|
SetCode: "rtr",
|
|
IsFoil: true,
|
|
IsPromo: false,
|
|
Language: "en",
|
|
}
|
|
|
|
searchCriteria := SearchCriteria{
|
|
SetCode: "rtr",
|
|
Foil: True,
|
|
Promo: False,
|
|
Language: "en",
|
|
}
|
|
|
|
filter := filterPrinting(printing, searchCriteria)
|
|
|
|
if filter != false {
|
|
t.Errorf("filter was true")
|
|
}
|
|
}
|
|
|
|
func TestFilterPrinting_ReturnsFalse_IfFoilCardInEitherFoilSearch(t *testing.T) {
|
|
printing := database.CardPrinting{
|
|
SetCode: "rtr",
|
|
IsFoil: true,
|
|
IsPromo: false,
|
|
Language: "en",
|
|
}
|
|
|
|
searchCriteria := SearchCriteria{
|
|
SetCode: "rtr",
|
|
Foil: Either,
|
|
Promo: False,
|
|
Language: "en",
|
|
}
|
|
|
|
filter := filterPrinting(printing, searchCriteria)
|
|
|
|
if filter != false {
|
|
t.Errorf("filter was true")
|
|
}
|
|
}
|
|
|
|
func TestFilterPrinting_ReturnsFalse_IfNonFoilCardInEitherFoilSearch(t *testing.T) {
|
|
printing := database.CardPrinting{
|
|
SetCode: "rtr",
|
|
IsFoil: false,
|
|
IsPromo: false,
|
|
Language: "en",
|
|
}
|
|
|
|
searchCriteria := SearchCriteria{
|
|
SetCode: "rtr",
|
|
Foil: Either,
|
|
Promo: False,
|
|
Language: "en",
|
|
}
|
|
|
|
filter := filterPrinting(printing, searchCriteria)
|
|
|
|
if filter != false {
|
|
t.Errorf("filter was true")
|
|
}
|
|
}
|
|
|
|
func TestFilterPrinting_ReturnsTrue_IfPromoCardInNonPromoSearch(t *testing.T) {
|
|
printing := database.CardPrinting{
|
|
SetCode: "rtr",
|
|
IsFoil: false,
|
|
IsPromo: true,
|
|
Language: "en",
|
|
}
|
|
|
|
searchCriteria := SearchCriteria{
|
|
SetCode: "rtr",
|
|
Foil: False,
|
|
Promo: False,
|
|
Language: "en",
|
|
}
|
|
|
|
filter := filterPrinting(printing, searchCriteria)
|
|
|
|
if filter != true {
|
|
t.Errorf("filter was false")
|
|
}
|
|
}
|
|
|
|
func TestFilterPrinting_ReturnsTrue_IfNonPromoCardInPromoSearch(t *testing.T) {
|
|
printing := database.CardPrinting{
|
|
SetCode: "rtr",
|
|
IsFoil: false,
|
|
IsPromo: false,
|
|
Language: "en",
|
|
}
|
|
|
|
searchCriteria := SearchCriteria{
|
|
SetCode: "rtr",
|
|
Foil: False,
|
|
Promo: True,
|
|
Language: "en",
|
|
}
|
|
|
|
filter := filterPrinting(printing, searchCriteria)
|
|
|
|
if filter != true {
|
|
t.Errorf("filter was false")
|
|
}
|
|
}
|
|
|
|
func TestFilterPrinting_ReturnsFalse_IfNonPromoCardInNonPromoSearch(t *testing.T) {
|
|
printing := database.CardPrinting{
|
|
SetCode: "rtr",
|
|
IsFoil: false,
|
|
IsPromo: false,
|
|
Language: "en",
|
|
}
|
|
|
|
searchCriteria := SearchCriteria{
|
|
SetCode: "rtr",
|
|
Foil: False,
|
|
Promo: False,
|
|
Language: "en",
|
|
}
|
|
|
|
filter := filterPrinting(printing, searchCriteria)
|
|
|
|
if filter != false {
|
|
t.Errorf("filter was true")
|
|
}
|
|
}
|
|
|
|
func TestFilterPrinting_ReturnsFalse_IfPromoCardInPromoSearch(t *testing.T) {
|
|
printing := database.CardPrinting{
|
|
SetCode: "rtr",
|
|
IsFoil: false,
|
|
IsPromo: true,
|
|
Language: "en",
|
|
}
|
|
|
|
searchCriteria := SearchCriteria{
|
|
SetCode: "rtr",
|
|
Foil: False,
|
|
Promo: True,
|
|
Language: "en",
|
|
}
|
|
|
|
filter := filterPrinting(printing, searchCriteria)
|
|
|
|
if filter != false {
|
|
t.Errorf("filter was true")
|
|
}
|
|
}
|
|
|
|
func TestFilterPrinting_ReturnsFalse_IfPromoCardInEitherPromoSearch(t *testing.T) {
|
|
printing := database.CardPrinting{
|
|
SetCode: "rtr",
|
|
IsFoil: false,
|
|
IsPromo: true,
|
|
Language: "en",
|
|
}
|
|
|
|
searchCriteria := SearchCriteria{
|
|
SetCode: "rtr",
|
|
Foil: False,
|
|
Promo: Either,
|
|
Language: "en",
|
|
}
|
|
|
|
filter := filterPrinting(printing, searchCriteria)
|
|
|
|
if filter != false {
|
|
t.Errorf("filter was true")
|
|
}
|
|
}
|
|
|
|
func TestFilterPrinting_ReturnsFalse_IfNonPromoCardInEitherPromoSearch(t *testing.T) {
|
|
printing := database.CardPrinting{
|
|
SetCode: "rtr",
|
|
IsFoil: false,
|
|
IsPromo: false,
|
|
Language: "en",
|
|
}
|
|
|
|
searchCriteria := SearchCriteria{
|
|
SetCode: "rtr",
|
|
Foil: False,
|
|
Promo: Either,
|
|
Language: "en",
|
|
}
|
|
|
|
filter := filterPrinting(printing, searchCriteria)
|
|
|
|
if filter != false {
|
|
t.Errorf("filter was true")
|
|
}
|
|
}
|
|
|
|
func TestFilterPrinting_ReturnsTrue_IfLanguageDoesNotMatch(t *testing.T) {
|
|
printing := database.CardPrinting{
|
|
SetCode: "rtr",
|
|
IsFoil: false,
|
|
IsPromo: false,
|
|
Language: "en",
|
|
}
|
|
|
|
searchCriteria := SearchCriteria{
|
|
SetCode: "rtr",
|
|
Foil: False,
|
|
Promo: False,
|
|
Language: "de",
|
|
}
|
|
|
|
filter := filterPrinting(printing, searchCriteria)
|
|
|
|
if filter != true {
|
|
t.Errorf("filter was false")
|
|
}
|
|
}
|
|
|
|
func TestFilterPrinting_ReturnsFalse_IfLanguageDoesMatch(t *testing.T) {
|
|
printing := database.CardPrinting{
|
|
SetCode: "rtr",
|
|
IsFoil: false,
|
|
IsPromo: false,
|
|
Language: "de",
|
|
}
|
|
|
|
searchCriteria := SearchCriteria{
|
|
SetCode: "rtr",
|
|
Foil: False,
|
|
Promo: False,
|
|
Language: "de",
|
|
}
|
|
|
|
filter := filterPrinting(printing, searchCriteria)
|
|
|
|
if filter != false {
|
|
t.Errorf("filter was true")
|
|
}
|
|
}
|
|
|
|
func TestFilterPrinting_ReturnsFalse_IfLanguageNotSet(t *testing.T) {
|
|
printing := database.CardPrinting{
|
|
SetCode: "rtr",
|
|
IsFoil: false,
|
|
IsPromo: false,
|
|
Language: "en",
|
|
}
|
|
|
|
searchCriteria := SearchCriteria{
|
|
SetCode: "rtr",
|
|
Foil: False,
|
|
Promo: False,
|
|
Language: "",
|
|
}
|
|
|
|
filter := filterPrinting(printing, searchCriteria)
|
|
|
|
if filter != false {
|
|
t.Errorf("filter was true")
|
|
}
|
|
}
|