public void AddPackages()
        {
            RequestKontext req2   = new RequestKontext("POST", "/packages", "HTTP/1.1", "[{\"Id\":\"test6\", \"Name\":\"WaterGoblin\", \"Damage\": 40.0}, {\"Id\":\"test7\", \"Name\":\"Dragon\", \"Damage\": 100.0}, {\"Id\":\"test8\", \"Name\":\"WaterSpell\", \"Damage\": 40.0}, {\"Id\":\"test9\", \"Name\":\"Ork\", \"Damage\": 90.0}, {\"Id\":\"test10\", \"Name\":\"FireSpell\", \"Damage\": 50.0}]", "testadmin");
            ServerReply    reply2 = ServerReply.HandlingRequest(req2);

            Assert.AreEqual("201 Created", reply2.Status);
        }
        public void BuyPackage()
        {
            RequestKontext req   = new RequestKontext("POST", "/transactions/packages", "HTTP/1.1", "", "test1");
            ServerReply    reply = ServerReply.HandlingRequest(req);

            Assert.AreEqual("200 OK", reply.Status);
        }
Exemple #3
0
        public void ShowDeck() //show all acquired cards
        {
            RequestKontext req   = new RequestKontext("GET", "/deck", "HTTP/1.1", "", "testadmin");
            ServerReply    reply = ServerReply.HandlingRequest(req);

            Assert.IsNotNull(reply);
            //return new ServerReply(req.Protocol, "200 OK", "result", "text");
            Assert.AreEqual("200 OK", reply.Status);
        }
        public void ShowScoreBoard()
        {
            RequestKontext req   = new RequestKontext("GET", "/stats", "HTTP/1.1", "", "testadmin");
            ServerReply    reply = ServerReply.HandlingRequest(req);

            Assert.IsNotNull(reply);
            //return new ServerReply(req.Protocol, "200 OK", "reply", "text");
            Assert.AreEqual("200 OK", reply.Status);
        }
        public void CheckDeals()
        {
            RequestKontext req   = new RequestKontext("GET", "/tradings", "HTTP/1.1", "", "testadmin");
            ServerReply    reply = ServerReply.HandlingRequest(req);

            Assert.IsNotNull(reply);
            //return new ServerReply(req.Protocol, "401 Unauthorized", "User doesn't have a session / invalid Token!", "text");
            Assert.AreEqual("200 OK", reply.Status);
        }
Exemple #6
0
        public void EditPlayerData()  //Ok
        {
            RequestKontext req   = new RequestKontext("PUT", "/users/testadmin", "HTTP/1.1", "{\"Name\": \"Test Admin\",  \"Bio\": \"me playin...\", \"Email\": \"[email protected]\"}", "testadmin");
            ServerReply    reply = ServerReply.HandlingRequest(req);

            Assert.IsNotNull(reply);
            //return new ServerReply(req.Protocol, "200 OK", result, "text");
            Assert.AreEqual("200 OK", reply.Status);
        }
Exemple #7
0
        public void ShowPlayerData()  //Ok
        {
            RequestKontext req   = new RequestKontext("GET", "/users/testadmin", "HTTP/1.1", "", "testadmin");
            ServerReply    reply = ServerReply.HandlingRequest(req);

            Assert.IsNotNull(reply);
            //return new ServerReply(req.Protocol, "200 OK", result, "text");
            Assert.AreEqual("200 OK", reply.Status);
        }
        public static void LogOut()  //No such User in table game_user, must create user first
        {
            RequestKontext req   = new RequestKontext("POST", "/signout", "HTTP/1.1", "", "test1");
            ServerReply    reply = ServerReply.HandlingRequest(req);

            Assert.IsNotNull(reply);
            //return new ServerReply(req.Protocol, "404 Not Found", "Error: User doesn't exist!", "text");
            Assert.AreEqual("200 OK", reply.Status);
        }
        public void Trade()
        {
            RequestKontext req   = new RequestKontext("POST", "/tradings/1", "HTTP/1.1", "\"test10\"", "test1");
            ServerReply    reply = ServerReply.HandlingRequest(req);

            Assert.IsNotNull(reply);
            //return new ServerReply(req.Protocol, "200 OK", "Treaded successfully!", "text");
            Assert.AreEqual("200 OK", reply.Status);
            Assert.AreEqual("Treaded successfully!", reply.Data);
        }
        public void TryTradeInvalidToken()
        {
            RequestKontext req   = new RequestKontext("POST", "/tradings/1", "HTTP/1.1", "\"test10\"", "teasdst1");
            ServerReply    reply = ServerReply.HandlingRequest(req);

            Assert.IsNotNull(reply);
            // return new ServerReply(req.Protocol, "401 Unauthorized", "Error: Not logged in or invalid token", "text");
            Assert.AreEqual("401 Unauthorized", reply.Status);
            Assert.AreEqual("Error: Not logged in or invalid token", reply.Data);
        }
        public void TryTradeNotObtainedCard()
        {
            RequestKontext req   = new RequestKontext("POST", "/tradings/1", "HTTP/1.1", "\"test1\"", "test1");
            ServerReply    reply = ServerReply.HandlingRequest(req);

            Assert.IsNotNull(reply);
            // return new ServerReply(req.Protocol, "409 Conflict", "Error: User doesnt own this card!", "text");
            Assert.AreEqual("409 Conflict", reply.Status);
            Assert.AreEqual("Error: User doesnt own this card!", reply.Data);
        }
        public void TryTradeNonExisitingTrade()
        {
            RequestKontext req   = new RequestKontext("POST", "/tradings/1111", "HTTP/1.1", "\"test6\"", "test1");
            ServerReply    reply = ServerReply.HandlingRequest(req);

            Assert.IsNotNull(reply);
            // return new ServerReply(req.Protocol, "409 Conflict", "Error: Trade doesn't exists!", "text");
            Assert.AreEqual("409 Conflict", reply.Status);
            Assert.AreEqual("Error: Trade doesn't exists!", reply.Data);
        }
Exemple #13
0
        public void ConfigureDeck()  //should be added to table deck
        {
            RequestKontext req   = new RequestKontext("PUT", "/deck", "HTTP/1.1", "[\"test1\", \"test2\", \"test3\", \"test4\"]", "testadmin");
            ServerReply    reply = ServerReply.HandlingRequest(req);

            Assert.IsNotNull(reply);
            //return new ServerReply(req.Protocol, "200 OK", "Deck configured!", "text");
            Assert.AreEqual("200 OK", reply.Status);
            Assert.AreEqual("Deck configured!", reply.Data);
        }
        public void TryTradeWithYourself()
        {
            RequestKontext req   = new RequestKontext("POST", "/tradings/1", "HTTP/1.1", "\"test3\"", "testadmin");
            ServerReply    reply = ServerReply.HandlingRequest(req);

            Assert.IsNotNull(reply);
            //return new ServerReply(req.Protocol, "409 Conflict", "Error: Can't trade with yourself!", "text");
            Assert.AreEqual("409 Conflict", reply.Status);
            Assert.AreEqual("Error: Can't trade with yourself!", reply.Data);
        }
Exemple #15
0
        public void ShowPlayerDataTokenNotSameAsOption()  //invalid token
        {
            RequestKontext req   = new RequestKontext("GET", "/users/asdwa", "HTTP/1.1", "", "testadmin");
            ServerReply    reply = ServerReply.HandlingRequest(req);

            Assert.IsNotNull(reply);
            //return new ServerReply(req.Protocol, "400 Bad Request", "Bad Request", "text");
            Assert.AreEqual("400 Bad Request", reply.Status);
            Assert.AreEqual("Bad Request", reply.Data);
        }
        public void CreateDealWithCardInDeck() //should fail
        {
            RequestKontext req   = new RequestKontext("POST", "/tradings", "HTTP/1.1", "{\"Id\": \"1\", \"CardToTrade\": \"test1\", \"Type\": \"spell\", \"MinimumDamage\": 15}", "testadmin");
            ServerReply    reply = ServerReply.HandlingRequest(req);

            Assert.IsNotNull(reply);
            //return new ServerReply(req.Protocol, "409 Conflict", "Error: User is not allowed to have the card in his deck!", "text");
            Assert.AreEqual("409 Conflict", reply.Status);
            Assert.AreEqual("Error: User is not allowed to have the card in his deck!", reply.Data);
        }
        public void ShowScoreBoardInvalidToken()
        {
            RequestKontext req   = new RequestKontext("GET", "/stats", "HTTP/1.1", "", "asd");
            ServerReply    reply = ServerReply.HandlingRequest(req);

            Assert.IsNotNull(reply);
            //return new ServerReply(req.Protocol, "401 Unauthorized", "Error: Not logged in or invalid token", "text");
            Assert.AreEqual("401 Unauthorized", reply.Status);
            Assert.AreEqual("Error: User is not logged in / Invalid Token!", reply.Data);
        }
Exemple #18
0
        public void EditPlayerInvalidToken()  //INvalid Token
        {
            RequestKontext req   = new RequestKontext("PUT", "/users/asd", "HTTP/1.1", "{\"Name\": \"Test Admin\",  \"Bio\": \"me playin...\", \"Email\": \"[email protected]\"}", "asd");
            ServerReply    reply = ServerReply.HandlingRequest(req);

            Assert.IsNotNull(reply);
            //return new ServerReply(req.Protocol, "401 Unauthorized", "Error: Not logged in or invalid token", "text");
            Assert.AreEqual("401 Unauthorized", reply.Status);
            Assert.AreEqual("Error: Not logged in or invalid token", reply.Data);
        }
Exemple #19
0
        public void EditPlayerDataOfSomeoneElse()  //NOt possible
        {
            RequestKontext req   = new RequestKontext("PUT", "/users/testadmin", "HTTP/1.1", "{\"Name\": \"Test Admin\",  \"Bio\": \"me playin...\", \"Email\": \"[email protected]\"}", "test1");
            ServerReply    reply = ServerReply.HandlingRequest(req);

            Assert.IsNotNull(reply);
            //return new ServerReply(req.Protocol, "401 Unauthorized", "Error: You can't change the data of someone else!", "text");
            Assert.AreEqual("401 Unauthorized", reply.Status);
            Assert.AreEqual("Error: You can't change the data of someone else!", reply.Data);
        }
        public void CreateDealWithInvalidToken() //should fail
        {
            RequestKontext req   = new RequestKontext("POST", "/tradings", "HTTP/1.1", "{\"Id\": \"1\", \"CardToTrade\": \"test5\", \"Type\": \"spell\", \"MinimumDamage\": 15}", "asdf");
            ServerReply    reply = ServerReply.HandlingRequest(req);

            Assert.IsNotNull(reply);
            //return new ServerReply(req.Protocol, "401 Unauthorized", "Error: Not logged in or invalid token", "text");
            Assert.AreEqual("401 Unauthorized", reply.Status);
            Assert.AreEqual("Error: Not logged in or invalid token", reply.Data);
        }
Exemple #21
0
        public void ConfigureDeckNot4Cards()   //in order to configure deck one must choose 4 cards
        {
            RequestKontext req   = new RequestKontext("PUT", "/deck", "HTTP/1.1", "[\"test1\", \"test2\", \"test3\"]", "testadmin");
            ServerReply    reply = ServerReply.HandlingRequest(req);

            Assert.IsNotNull(reply);
            //return new ServerReply(req.Protocol, "416 Range Not Satisfiable", "Error: Must be 4 Cards to create or edit deck!", "text");
            Assert.AreEqual("416 Range Not Satisfiable", reply.Status);
            Assert.AreEqual("Error: Must be 4 Cards to create or edit deck!", reply.Data);
        }
Exemple #22
0
        public void ShowPlayerDataInvalidToken()  //invalid token
        {
            RequestKontext req   = new RequestKontext("GET", "/users/asdwa", "HTTP/1.1", "", "asdwa");
            ServerReply    reply = ServerReply.HandlingRequest(req);

            Assert.IsNotNull(reply);
            //return new ServerReply(req.Protocol, "401 Unauthorized", ""Error: User doesn't have a session / invalid Token!"", "text");
            Assert.AreEqual("401 Unauthorized", reply.Status);
            Assert.AreEqual("Error: User doesn't have a session / invalid Token!", reply.Data);
        }
        public void CreateDealWithNotObtainedCard() //should fail
        {
            RequestKontext req   = new RequestKontext("POST", "/tradings", "HTTP/1.1", "{\"Id\": \"1\", \"CardToTrade\": \"asddwasd-sdgsd\", \"Type\": \"spell\", \"MinimumDamage\": 15}", "testadmin");
            ServerReply    reply = ServerReply.HandlingRequest(req);

            Assert.IsNotNull(reply);
            //return new ServerReply(req.Protocol, "409 Conflict", "Error: User doesnt own this card!", "text");
            Assert.AreEqual("409 Conflict", reply.Status);
            Assert.AreEqual("Error: User doesnt own this card!", reply.Data);
        }
        public void CreatePackageNotAdmin()  // NOt an admin
        {
            RequestKontext req2   = new RequestKontext("POST", "/packages", "HTTP/1.1", "[{\"Id\":\"test1\", \"Name\":\"WaterGoblin\", \"Damage\": 10.0}, {\"Id\":\"test2\", \"Name\":\"Dragon\", \"Damage\": 50.0}, {\"Id\":\"test3\", \"Name\":\"WaterSpell\", \"Damage\": 20.0}, {\"Id\":\"test4\", \"Name\":\"Ork\", \"Damage\": 45.0}, {\"Id\":\"test5\", \"Name\":\"FireSpell\", \"Damage\": 25.0}]", "test1");
            ServerReply    reply2 = ServerReply.HandlingRequest(req2);

            Assert.IsNotNull(reply2);
            //return new ServerReply(req.Protocol, "401 Unauthorized", "Error: You are not authorized!", "text");
            Assert.AreEqual("401 Unauthorized", reply2.Status);
            Assert.AreEqual("Error: You are not authorized!", reply2.Data);
        }
        public void CreateDeal()
        {
            RequestKontext req   = new RequestKontext("POST", "/tradings", "HTTP/1.1", "{\"Id\": \"1\", \"CardToTrade\": \"test5\", \"Type\": \"spell\", \"MinimumDamage\": 15}", "testadmin");
            ServerReply    reply = ServerReply.HandlingRequest(req);

            Assert.IsNotNull(reply);

            Assert.AreEqual("201 Created", reply.Status);
            Assert.AreEqual("Treade Created", reply.Data);
        }
Exemple #26
0
        public void ConfigureDeckInvalidToken()  //invalid token
        {
            RequestKontext req   = new RequestKontext("PUT", "/deck", "HTTP/1.1", "[\"test1\", \"test2\", \"test3\", \"test4\"]", "asdwa");
            ServerReply    reply = ServerReply.HandlingRequest(req);

            Assert.IsNotNull(reply);
            //return new ServerReply(req.Protocol, "401 Unauthorized", "Error: Not logged in or invalid token", "text");
            Assert.AreEqual("401 Unauthorized", reply.Status);
            Assert.AreEqual("Error: Not logged in or invalid token", reply.Data);
        }
        public void CreatePackageEmptyPayload()  // No Session Created
        {
            RequestKontext req   = new RequestKontext("POST", "/packages", "HTTP/1.1", "", "");
            ServerReply    reply = ServerReply.HandlingRequest(req);

            Assert.IsNotNull(reply);
            //return new ServerReply(req.Protocol, "204 No Content", "Error: No Content", "text");
            Assert.AreEqual("204 No Content", reply.Status);
            Assert.AreEqual("Error: No Content", reply.Data);
        }
Exemple #28
0
        public void ConfigureDeckAddNotObtainedCard()  //should not go through cause user doesnt own one or more cards that he wanna put in his deck
        {
            RequestKontext req   = new RequestKontext("PUT", "/deck", "HTTP/1.1", "[\"test1\", \"test2\", \"test3\", \"test4444\"]", "testadmin");
            ServerReply    reply = ServerReply.HandlingRequest(req);

            Assert.IsNotNull(reply);
            //return new ServerReply(req.Protocol, "401 Unauthorized", "Error: One or more Cards are not obtained by the User!", "text");
            Assert.AreEqual("401 Unauthorized", reply.Status);
            Assert.AreEqual("Error: One or more Cards are not obtained by the User!", reply.Data);
        }
        public void CreatePackageCardsAlreadyInStore()  // should not be added in store cause already exists
        {
            RequestKontext req2   = new RequestKontext("POST", "/packages", "HTTP/1.1", "[{\"Id\":\"test1\", \"Name\":\"WaterGoblin\", \"Damage\": 10.0}, {\"Id\":\"test2\", \"Name\":\"Dragon\", \"Damage\": 50.0}, {\"Id\":\"test3\", \"Name\":\"WaterSpell\", \"Damage\": 20.0}, {\"Id\":\"test4\", \"Name\":\"Ork\", \"Damage\": 45.0}, {\"Id\":\"test5\", \"Name\":\"FireSpell\", \"Damage\": 25.0}]", "testadmin");
            ServerReply    reply2 = ServerReply.HandlingRequest(req2);

            Assert.IsNotNull(reply2);
            //return new ServerReply(req.Protocol, "409 Conflict", "Error: One or more cards already exists in Store!", "text");
            Assert.AreEqual("409 Conflict", reply2.Status);
            Assert.AreEqual("Error: One or more cards already exists in Store!", reply2.Data);
        }
        public void TryTradeWithWrongCard()
        {
            RequestKontext req   = new RequestKontext("POST", "/tradings/1", "HTTP/1.1", "\"test6\"", "test1");
            ServerReply    reply = ServerReply.HandlingRequest(req);

            Assert.IsNotNull(reply);
            //return new ServerReply(req.Protocol, "409 Conflict", "Error: This Card doesn't match the required Card!", "text");
            Assert.AreEqual("409 Conflict", reply.Status);
            Assert.AreEqual("Error: This Card doesn't match the required Card!", reply.Data);
        }