@ -48,7 +48,7 @@ final class ServerDataTests: XCTestCase {
club . phone = " 061234567890 "
club . phone = " 061234567890 "
club . courtCount = 3
club . courtCount = 3
let inserted_club : Club = try await StoreCenter . main . service ( ) . post ( club )
if let inserted_club : Club = try await StoreCenter . main . service ( ) . post ( club ) {
assert ( inserted_club . lastUpdate = = club . lastUpdate )
assert ( inserted_club . lastUpdate = = club . lastUpdate )
assert ( inserted_club . name = = club . name )
assert ( inserted_club . name = = club . name )
assert ( inserted_club . acronym = = club . acronym )
assert ( inserted_club . acronym = = club . acronym )
@ -66,7 +66,9 @@ final class ServerDataTests: XCTestCase {
let updated_club : Club = try await StoreCenter . main . service ( ) . put ( inserted_club )
let updated_club : Club = try await StoreCenter . main . service ( ) . put ( inserted_club )
assert ( updated_club . phone = = inserted_club . phone )
assert ( updated_club . phone = = inserted_club . phone )
} else {
XCTFail ( " missing data " )
}
}
}
func testLogin ( ) async throws {
func testLogin ( ) async throws {
@ -88,12 +90,14 @@ final class ServerDataTests: XCTestCase {
}
}
let event = Event ( creator : userId , club : clubId , name : " Roland Garros " , tenupId : " abc " )
let event = Event ( creator : userId , club : clubId , name : " Roland Garros " , tenupId : " abc " )
let e = try await StoreCenter . main . service ( ) . post ( event )
if let e = try await StoreCenter . main . service ( ) . post ( event ) {
assert ( e . name = = event . name )
assert ( e . name = = event . name )
assert ( e . lastUpdate = = event . lastUpdate )
assert ( e . lastUpdate = = event . lastUpdate )
assert ( e . tenupId = = event . tenupId )
assert ( e . tenupId = = event . tenupId )
} else {
XCTFail ( " missing data " )
}
}
}
func testTournament ( ) async throws {
func testTournament ( ) async throws {
@ -105,7 +109,8 @@ final class ServerDataTests: XCTestCase {
}
}
let tournament = Tournament ( event : eventId , name : " RG Homme " , startDate : Date ( ) , endDate : nil , creationDate : Date ( ) , isPrivate : false , groupStageFormat : MatchFormat . megaTie , roundFormat : MatchFormat . nineGames , loserRoundFormat : MatchFormat . nineGamesDecisivePoint , groupStageSortMode : GroupStageOrderingMode . snake , groupStageCount : 2 , rankSourceDate : Date ( ) , dayDuration : 5 , teamCount : 3 , teamSorting : TeamSortingType . rank , federalCategory : TournamentCategory . mix , federalLevelCategory : TournamentLevel . p1000 , federalAgeCategory : FederalTournamentAge . a45 , closedRegistrationDate : Date ( ) , groupStageAdditionalQualified : 4 , courtCount : 9 , prioritizeClubMembers : true , qualifiedPerGroupStage : 1 , teamsPerGroupStage : 2 , entryFee : 30.0 , additionalEstimationDuration : 5 , isDeleted : true , publishTeams : true , publishSummons : true , publishGroupStages : true , publishBrackets : true , shouldVerifyBracket : true , shouldVerifyGroupStage : true , hideTeamsWeight : true , publishTournament : true , hidePointsEarned : true , publishRankings : true , loserBracketMode : . manual , initialSeedRound : 8 , initialSeedCount : 4 , accountIsRequired : false , licenseIsRequired : false , minimumPlayerPerTeam : 3 , maximumPlayerPerTeam : 5 , information : " Super " )
let tournament = Tournament ( event : eventId , name : " RG Homme " , startDate : Date ( ) , endDate : nil , creationDate : Date ( ) , isPrivate : false , groupStageFormat : MatchFormat . megaTie , roundFormat : MatchFormat . nineGames , loserRoundFormat : MatchFormat . nineGamesDecisivePoint , groupStageSortMode : GroupStageOrderingMode . snake , groupStageCount : 2 , rankSourceDate : Date ( ) , dayDuration : 5 , teamCount : 3 , teamSorting : TeamSortingType . rank , federalCategory : TournamentCategory . mix , federalLevelCategory : TournamentLevel . p1000 , federalAgeCategory : FederalTournamentAge . a45 , closedRegistrationDate : Date ( ) , groupStageAdditionalQualified : 4 , courtCount : 9 , prioritizeClubMembers : true , qualifiedPerGroupStage : 1 , teamsPerGroupStage : 2 , entryFee : 30.0 , additionalEstimationDuration : 5 , isDeleted : true , publishTeams : true , publishSummons : true , publishGroupStages : true , publishBrackets : true , shouldVerifyBracket : true , shouldVerifyGroupStage : true , hideTeamsWeight : true , publishTournament : true , hidePointsEarned : true , publishRankings : true , loserBracketMode : . manual , initialSeedRound : 8 , initialSeedCount : 4 , accountIsRequired : false , licenseIsRequired : false , minimumPlayerPerTeam : 3 , maximumPlayerPerTeam : 5 , information : " Super " )
let t = try await StoreCenter . main . service ( ) . post ( tournament )
if let t = try await StoreCenter . main . service ( ) . post ( tournament ) {
assert ( t . lastUpdate . formatted ( ) = = tournament . lastUpdate . formatted ( ) )
assert ( t . lastUpdate . formatted ( ) = = tournament . lastUpdate . formatted ( ) )
assert ( t . event = = tournament . event )
assert ( t . event = = tournament . event )
@ -153,6 +158,10 @@ final class ServerDataTests: XCTestCase {
assert ( t . minimumPlayerPerTeam = = tournament . minimumPlayerPerTeam )
assert ( t . minimumPlayerPerTeam = = tournament . minimumPlayerPerTeam )
assert ( t . maximumPlayerPerTeam = = tournament . maximumPlayerPerTeam )
assert ( t . maximumPlayerPerTeam = = tournament . maximumPlayerPerTeam )
assert ( t . information = = tournament . information )
assert ( t . information = = tournament . information )
} else {
XCTFail ( " missing data " )
}
}
}
func testGroupStage ( ) async throws {
func testGroupStage ( ) async throws {
@ -165,7 +174,7 @@ final class ServerDataTests: XCTestCase {
let groupStage = GroupStage ( tournament : tournamentId , index : 2 , size : 3 , format : MatchFormat . nineGames , startDate : Date ( ) , name : " Yeah! " , step : 1 )
let groupStage = GroupStage ( tournament : tournamentId , index : 2 , size : 3 , format : MatchFormat . nineGames , startDate : Date ( ) , name : " Yeah! " , step : 1 )
groupStage . storeId = " 123 "
groupStage . storeId = " 123 "
let gs : GroupStage = try await StoreCenter . main . service ( ) . post ( groupStage )
if let gs : GroupStage = try await StoreCenter . main . service ( ) . post ( groupStage ) {
assert ( gs . tournament = = groupStage . tournament )
assert ( gs . tournament = = groupStage . tournament )
assert ( gs . storeId = = groupStage . storeId )
assert ( gs . storeId = = groupStage . storeId )
@ -176,7 +185,9 @@ final class ServerDataTests: XCTestCase {
assert ( gs . matchFormat = = groupStage . matchFormat )
assert ( gs . matchFormat = = groupStage . matchFormat )
assert ( gs . startDate != nil )
assert ( gs . startDate != nil )
assert ( gs . step = = groupStage . step )
assert ( gs . step = = groupStage . step )
} else {
XCTFail ( " missing data " )
}
}
}
@ -192,7 +203,7 @@ final class ServerDataTests: XCTestCase {
let round = Round ( tournament : tournamentId , index : 1 , parent : parentRoundId , matchFormat : MatchFormat . nineGames , startDate : Date ( ) , groupStageLoserBracket : false , loserBracketMode : . manual )
let round = Round ( tournament : tournamentId , index : 1 , parent : parentRoundId , matchFormat : MatchFormat . nineGames , startDate : Date ( ) , groupStageLoserBracket : false , loserBracketMode : . manual )
round . storeId = " abc "
round . storeId = " abc "
let r : Round = try await StoreCenter . main . service ( ) . post ( round )
if let r : Round = try await StoreCenter . main . service ( ) . post ( round ) {
assert ( r . storeId = = round . storeId )
assert ( r . storeId = = round . storeId )
assert ( r . tournament = = round . tournament )
assert ( r . tournament = = round . tournament )
@ -203,7 +214,9 @@ final class ServerDataTests: XCTestCase {
assert ( r . startDate != nil )
assert ( r . startDate != nil )
assert ( r . groupStageLoserBracket = = round . groupStageLoserBracket )
assert ( r . groupStageLoserBracket = = round . groupStageLoserBracket )
assert ( r . loserBracketMode = = round . loserBracketMode )
assert ( r . loserBracketMode = = round . loserBracketMode )
} else {
XCTFail ( " missing data " )
}
}
}
func testTeamRegistration ( ) async throws {
func testTeamRegistration ( ) async throws {
@ -222,7 +235,7 @@ final class ServerDataTests: XCTestCase {
let teamRegistration = TeamRegistration ( tournament : tournamentId , groupStage : groupStageId , registrationDate : Date ( ) , callDate : Date ( ) , bracketPosition : 1 , groupStagePosition : 2 , comment : " comment " , source : " source " , sourceValue : " source V " , logo : " logo " , name : " Stax " , walkOut : true , wildCardBracket : true , wildCardGroupStage : true , weight : 1 , lockedWeight : 11 , confirmationDate : Date ( ) , qualified : true )
let teamRegistration = TeamRegistration ( tournament : tournamentId , groupStage : groupStageId , registrationDate : Date ( ) , callDate : Date ( ) , bracketPosition : 1 , groupStagePosition : 2 , comment : " comment " , source : " source " , sourceValue : " source V " , logo : " logo " , name : " Stax " , walkOut : true , wildCardBracket : true , wildCardGroupStage : true , weight : 1 , lockedWeight : 11 , confirmationDate : Date ( ) , qualified : true )
teamRegistration . storeId = " 123 "
teamRegistration . storeId = " 123 "
let tr : TeamRegistration = try await StoreCenter . main . service ( ) . post ( teamRegistration )
if let tr : TeamRegistration = try await StoreCenter . main . service ( ) . post ( teamRegistration ) {
assert ( tr . storeId = = teamRegistration . storeId )
assert ( tr . storeId = = teamRegistration . storeId )
assert ( tr . tournament = = teamRegistration . tournament )
assert ( tr . tournament = = teamRegistration . tournament )
@ -246,6 +259,9 @@ final class ServerDataTests: XCTestCase {
assert ( tr . qualified = = teamRegistration . qualified )
assert ( tr . qualified = = teamRegistration . qualified )
assert ( tr . finalRanking = = teamRegistration . finalRanking )
assert ( tr . finalRanking = = teamRegistration . finalRanking )
assert ( tr . pointsEarned = = teamRegistration . pointsEarned )
assert ( tr . pointsEarned = = teamRegistration . pointsEarned )
} else {
XCTFail ( " missing data " )
}
}
}
func testPlayerRegistration ( ) async throws {
func testPlayerRegistration ( ) async throws {
@ -259,7 +275,7 @@ final class ServerDataTests: XCTestCase {
let playerRegistration = PlayerRegistration ( teamRegistration : teamRegistrationId , firstName : " juan " , lastName : " lebron " , licenceId : " 123 " , rank : 11 , paymentType : PlayerPaymentType . cash , sex : PlayerSexType . male , tournamentPlayed : 2 , points : 33 , clubName : " le club " , ligueName : " la league " , assimilation : " ass " , phoneNumber : " 123123 " , email : " email@email.com " , birthdate : nil , computedRank : 222 , source : PlayerRegistration . PlayerDataSource . frenchFederation , hasArrived : true )
let playerRegistration = PlayerRegistration ( teamRegistration : teamRegistrationId , firstName : " juan " , lastName : " lebron " , licenceId : " 123 " , rank : 11 , paymentType : PlayerPaymentType . cash , sex : PlayerSexType . male , tournamentPlayed : 2 , points : 33 , clubName : " le club " , ligueName : " la league " , assimilation : " ass " , phoneNumber : " 123123 " , email : " email@email.com " , birthdate : nil , computedRank : 222 , source : PlayerRegistration . PlayerDataSource . frenchFederation , hasArrived : true )
playerRegistration . storeId = " 123 "
playerRegistration . storeId = " 123 "
let pr : PlayerRegistration = try await StoreCenter . main . service ( ) . post ( playerRegistration )
if let pr : PlayerRegistration = try await StoreCenter . main . service ( ) . post ( playerRegistration ) {
assert ( pr . storeId = = playerRegistration . storeId )
assert ( pr . storeId = = playerRegistration . storeId )
assert ( pr . lastName = = playerRegistration . lastName )
assert ( pr . lastName = = playerRegistration . lastName )
@ -283,7 +299,9 @@ final class ServerDataTests: XCTestCase {
assert ( pr . captain = = playerRegistration . captain )
assert ( pr . captain = = playerRegistration . captain )
assert ( pr . coach = = playerRegistration . coach )
assert ( pr . coach = = playerRegistration . coach )
assert ( pr . registeredOnline = = playerRegistration . registeredOnline )
assert ( pr . registeredOnline = = playerRegistration . registeredOnline )
} else {
XCTFail ( " missing data " )
}
}
}
func testMatch ( ) async throws {
func testMatch ( ) async throws {
@ -298,7 +316,7 @@ final class ServerDataTests: XCTestCase {
let match : Match = Match ( round : parentRoundId , groupStage : nil , startDate : Date ( ) , endDate : Date ( ) , index : 2 , format : MatchFormat . twoSets , servingTeamId : teamRegistrationId , winningTeamId : teamRegistrationId , losingTeamId : teamRegistrationId , disabled : true , courtIndex : 1 , confirmed : true )
let match : Match = Match ( round : parentRoundId , groupStage : nil , startDate : Date ( ) , endDate : Date ( ) , index : 2 , format : MatchFormat . twoSets , servingTeamId : teamRegistrationId , winningTeamId : teamRegistrationId , losingTeamId : teamRegistrationId , disabled : true , courtIndex : 1 , confirmed : true )
match . storeId = " 123 "
match . storeId = " 123 "
let m : Match = try await StoreCenter . main . service ( ) . post ( match )
if let m : Match = try await StoreCenter . main . service ( ) . post ( match ) {
assert ( m . storeId = = match . storeId )
assert ( m . storeId = = match . storeId )
assert ( m . lastUpdate = = match . lastUpdate )
assert ( m . lastUpdate = = match . lastUpdate )
@ -314,7 +332,9 @@ final class ServerDataTests: XCTestCase {
assert ( m . disabled = = match . disabled )
assert ( m . disabled = = match . disabled )
assert ( m . courtIndex = = match . courtIndex )
assert ( m . courtIndex = = match . courtIndex )
assert ( m . confirmed = = match . confirmed )
assert ( m . confirmed = = match . confirmed )
} else {
XCTFail ( " missing data " )
}
}
}
func testTeamScore ( ) async throws {
func testTeamScore ( ) async throws {
@ -331,7 +351,7 @@ final class ServerDataTests: XCTestCase {
}
}
let teamScore = TeamScore ( match : matchId , teamRegistration : teamRegistrationId , score : " 6/6 " , walkOut : 1 , luckyLoser : 1 )
let teamScore = TeamScore ( match : matchId , teamRegistration : teamRegistrationId , score : " 6/6 " , walkOut : 1 , luckyLoser : 1 )
teamScore . storeId = " !23 "
teamScore . storeId = " !23 "
let ts : TeamScore = try await StoreCenter . main . service ( ) . post ( teamScore )
if let ts : TeamScore = try await StoreCenter . main . service ( ) . post ( teamScore ) {
assert ( ts . storeId = = teamScore . storeId )
assert ( ts . storeId = = teamScore . storeId )
assert ( ts . lastUpdate = = teamScore . lastUpdate )
assert ( ts . lastUpdate = = teamScore . lastUpdate )
@ -340,7 +360,9 @@ final class ServerDataTests: XCTestCase {
assert ( ts . score = = teamScore . score )
assert ( ts . score = = teamScore . score )
assert ( ts . walkOut = = teamScore . walkOut )
assert ( ts . walkOut = = teamScore . walkOut )
assert ( ts . luckyLoser = = teamScore . luckyLoser )
assert ( ts . luckyLoser = = teamScore . luckyLoser )
} else {
XCTFail ( " missing data " )
}
}
}
func testCourt ( ) async throws {
func testCourt ( ) async throws {
@ -352,7 +374,7 @@ final class ServerDataTests: XCTestCase {
}
}
let court = Court ( index : 1 , club : clubId , name : " Philippe Chatrier " , exitAllowed : true , indoor : true )
let court = Court ( index : 1 , club : clubId , name : " Philippe Chatrier " , exitAllowed : true , indoor : true )
let c : Court = try await StoreCenter . main . service ( ) . post ( court )
if let c : Court = try await StoreCenter . main . service ( ) . post ( court ) {
assert ( c . lastUpdate = = court . lastUpdate )
assert ( c . lastUpdate = = court . lastUpdate )
assert ( c . club = = court . club )
assert ( c . club = = court . club )
@ -360,7 +382,9 @@ final class ServerDataTests: XCTestCase {
assert ( c . index = = court . index )
assert ( c . index = = court . index )
assert ( c . exitAllowed = = court . exitAllowed )
assert ( c . exitAllowed = = court . exitAllowed )
assert ( c . indoor = = court . indoor )
assert ( c . indoor = = court . indoor )
} else {
XCTFail ( " missing data " )
}
}
}
func testDateInterval ( ) async throws {
func testDateInterval ( ) async throws {
@ -372,14 +396,16 @@ final class ServerDataTests: XCTestCase {
}
}
let dateInterval = DateInterval ( event : eventId , courtIndex : 1 , startDate : Date ( ) , endDate : Date ( ) )
let dateInterval = DateInterval ( event : eventId , courtIndex : 1 , startDate : Date ( ) , endDate : Date ( ) )
let di : PadelClub . DateInterval = try await StoreCenter . main . service ( ) . post ( dateInterval )
if let di : PadelClub . DateInterval = try await StoreCenter . main . service ( ) . post ( dateInterval ) {
assert ( di . lastUpdate = = dateInterval . lastUpdate )
assert ( di . lastUpdate = = dateInterval . lastUpdate )
assert ( di . event = = dateInterval . event )
assert ( di . event = = dateInterval . event )
assert ( di . courtIndex = = dateInterval . courtIndex )
assert ( di . courtIndex = = dateInterval . courtIndex )
assert ( di . startDate . formatted ( ) = = dateInterval . startDate . formatted ( ) )
assert ( di . startDate . formatted ( ) = = dateInterval . startDate . formatted ( ) )
assert ( di . endDate . formatted ( ) = = dateInterval . endDate . formatted ( ) )
assert ( di . endDate . formatted ( ) = = dateInterval . endDate . formatted ( ) )
} else {
XCTFail ( " missing data " )
}
}
}
func testPurchase ( ) async throws {
func testPurchase ( ) async throws {
@ -394,7 +420,7 @@ final class ServerDataTests: XCTestCase {
let purchase : Purchase = Purchase ( user : userId , transactionId : transactionId , purchaseDate : Date ( ) , productId : " app.padelclub.productId " , quantity : quantity , revocationDate : Date ( ) , expirationDate : Date ( ) )
let purchase : Purchase = Purchase ( user : userId , transactionId : transactionId , purchaseDate : Date ( ) , productId : " app.padelclub.productId " , quantity : quantity , revocationDate : Date ( ) , expirationDate : Date ( ) )
let p : Purchase = try await StoreCenter . main . service ( ) . post ( purchase )
if let p : Purchase = try await StoreCenter . main . service ( ) . post ( purchase ) {
assert ( p . id = = purchase . id )
assert ( p . id = = purchase . id )
assert ( p . lastUpdate = = purchase . lastUpdate )
assert ( p . lastUpdate = = purchase . lastUpdate )
@ -404,7 +430,9 @@ final class ServerDataTests: XCTestCase {
assert ( p . quantity = = purchase . quantity )
assert ( p . quantity = = purchase . quantity )
assert ( p . revocationDate ? . formatted ( ) = = purchase . revocationDate ? . formatted ( ) )
assert ( p . revocationDate ? . formatted ( ) = = purchase . revocationDate ? . formatted ( ) )
assert ( p . expirationDate ? . formatted ( ) = = purchase . expirationDate ? . formatted ( ) )
assert ( p . expirationDate ? . formatted ( ) = = purchase . expirationDate ? . formatted ( ) )
} else {
XCTFail ( " missing data " )
}
}
}
func testDrawLog ( ) async throws {
func testDrawLog ( ) async throws {
@ -416,7 +444,9 @@ final class ServerDataTests: XCTestCase {
}
}
let drawLog = DrawLog ( tournament : tournamentId , drawSeed : 1 , drawMatchIndex : 1 , drawTeamPosition : . two , drawType : . court )
let drawLog = DrawLog ( tournament : tournamentId , drawSeed : 1 , drawMatchIndex : 1 , drawTeamPosition : . two , drawType : . court )
let d : DrawLog = try await StoreCenter . main . service ( ) . post ( drawLog )
drawLog . storeId = " !23 "
if let d : DrawLog = try await StoreCenter . main . service ( ) . post ( drawLog ) {
assert ( d . tournament = = drawLog . tournament )
assert ( d . tournament = = drawLog . tournament )
assert ( d . drawDate . formatted ( ) = = drawLog . drawDate . formatted ( ) )
assert ( d . drawDate . formatted ( ) = = drawLog . drawDate . formatted ( ) )
@ -424,6 +454,9 @@ final class ServerDataTests: XCTestCase {
assert ( d . drawTeamPosition = = drawLog . drawTeamPosition )
assert ( d . drawTeamPosition = = drawLog . drawTeamPosition )
assert ( d . drawMatchIndex = = drawLog . drawMatchIndex )
assert ( d . drawMatchIndex = = drawLog . drawMatchIndex )
assert ( d . drawType = = drawLog . drawType )
assert ( d . drawType = = drawLog . drawType )
} else {
XCTFail ( " missing data " )
}
}
}
}
}