-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from lindsaygelle/developer
Developer
- Loading branch information
Showing
5 changed files
with
174 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package amiibo | ||
|
||
import ( | ||
"time" | ||
|
||
"golang.org/x/text/language" | ||
) | ||
|
||
// Software is a generic interface for an Nintendo software product. | ||
// | ||
// Software provides a handler to get all common fields between the ENGGame and JPNSoftware. | ||
type Software interface { | ||
GetAvailable() bool | ||
GetID() string | ||
GetLanguage() language.Tag | ||
GetMD5() (string, error) | ||
GetName() string | ||
GetNameAlternative() string | ||
GetReleaseDate() time.Time | ||
GetURL() string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package amiibo_test | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/lindsaygelle/amiibo" | ||
"golang.org/x/text/language" | ||
) | ||
|
||
func TestSoftware(t *testing.T) { | ||
var name = "name" | ||
var nameAlt = "nameAlt" | ||
var releaseDate = time.Now() | ||
var URL = "https://ninendo.com/" | ||
var engSoftware amiibo.Software = amiibo.ENGGame{ | ||
Name: name, | ||
ReleaseDate: releaseDate, | ||
URL: URL} | ||
var jpnSoftware amiibo.Software = amiibo.JPNSoftware{ | ||
Name: name, | ||
NameAlternative: nameAlt, | ||
ReleaseDate: releaseDate, | ||
URL: URL} | ||
|
||
if getLanguage := engSoftware.GetLanguage(); getLanguage != language.English { | ||
t.Fatalf("(Software).GetLanguage() %v != %v", getLanguage, language.English) | ||
} | ||
if getLanguage := jpnSoftware.GetLanguage(); getLanguage != language.Japanese { | ||
t.Fatalf("(Software).GetLanguage() %v != %v", getLanguage, language.Japanese) | ||
} | ||
for _, v := range []amiibo.Software{engSoftware, jpnSoftware} { | ||
if getAvailable := v.GetAvailable(); !getAvailable { | ||
t.Fatalf("(Software).GetAvailable() %t != true", getAvailable) | ||
} | ||
if getName := v.GetName(); getName != name { | ||
t.Fatalf("(Software).GetName() %s != %s", getName, name) | ||
} | ||
if getNameAlternative := v.GetNameAlternative(); !(getNameAlternative == nameAlt || getNameAlternative == name) { | ||
t.Fatalf("(Software).GetNameAlternative() %s != %s || %s", getNameAlternative, nameAlt, name) | ||
} | ||
if MD5, err := v.GetMD5(); err != nil { | ||
t.Fatalf("(Software).GetMD5() (%s, %s)", MD5, err) | ||
} | ||
if getReleaseDate := v.GetReleaseDate(); getReleaseDate != releaseDate { | ||
t.Fatalf("(Software).GetReleaseDate() %v != %v", getReleaseDate, releaseDate) | ||
} | ||
if getURL := v.GetURL(); getURL != URL { | ||
t.Fatalf("(Software).GetURL() %s != %s", getURL, URL) | ||
} | ||
} | ||
} |