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

Replies to Re: Re: Re: Untitled rss

Title Name Language When
Re: Re: Re: Re: Untitled Whipped Baboon text 6 Years ago.