Facebook
From Mungo Kitten, 5 Years ago, written in Plain Text.
This paste is a reply to Re: Untitled from Insensitive Hog - view diff
Embed
Download Paste or View Raw
Hits: 392
  1. function WorldTestSuite:TestCaseAddChairToWorld()
  2.         local result, errorInfo = World:AddEntity( "Chair" )
  3.         ASSERT( result, true, "Nie udalo sie postawic krzesla na swiecie.", errorInfo )
  4.         -- errorInfo jako 4 parametr to takie info techniczne - powod dla ktorego nie udalo sie tego zrobic
  5. end
  6.  
  7.  
  8. function World:AddEntity( name )
  9.         -- rejestrujemy polaczenie z baza danych - bedziemy ja pytac czy liczba elementow na swiecie sie zwiekszyla czy nie
  10.         local createDatabaseConnectionResult, createDatabaseConnectionErrorInfo = CreateDatabaseConnection()
  11.         if ( createDatabaseConnectionResult == false OR createDatabaseConnectionErrorInfo ~= nil ) then
  12.                 return false, createErrocreateDatabaseConnectionErrorInforInfo
  13.         end
  14.        
  15.         -- ta metoda jets w chuj fake, chcialem poprostu aby wygladalo jakby mialo sens
  16.         local currentEntitiesCount, currentEntitiesCountErrorInfo = GetIntFromDatabase( "entitiesCount" )
  17.         if ( currentEntitiesCountErrorInfo ~= nil ) then
  18.                 return false, currentEntitiesCountErrorInfo
  19.         end
  20.    
  21.         local createResult, createErrorMessage = ask_engine_to_do_something( "createEntity(" .. name .. ")" )
  22.         if ( createResult == false OR createErrorMessage ~= nil ) then
  23.                 return false, createErrorMessage
  24.         end
  25.        
  26.         -- sprawdzamy ponownie po utworzeniu krzesla liczbe entitek
  27.         local entitiesCountAfter, entitiesCountAfterErrorInfo = GetIntFromDatabase( "entitiesCount" )
  28.         if ( entitiesCountAfterErrorInfo ~= nil ) then
  29.                 return false, entitiesCountAfterErrorInfo
  30.         end
  31.    
  32.         if ( currentEntitiesCount >= entitiesCountAfter ) then
  33.                 return false, "Liczba entitek po dodaniu nowej jest rowna " .. entitiesCountAfter .. " i nie jest wieksza od poczatkowej liczby " .. currentEntitiesCount
  34.         end
  35.    
  36.         local closeDatabaseConnectionResult, closeDatabaseConnectionErrorInfo = CloseDatabaseConnection()
  37.         if ( closeDatabaseConnectionResult == false OR closeDatabaseConnectionErrorInfo ~= nil ) then
  38.                 return false, closeDatabaseConnectionErrorInfo
  39.         end
  40. end

Replies to Re: Re: Untitled rss

Title Name Language When
Re: Re: Re: Untitled Perl Hedgehog text 5 Years ago.