I am creating Sample Fitnesse Test and facing this error while running test
fit
Date: 6:34:29 PM (IST) on Tuesday, April 9, 2013
Test Page: .CalculatorRunner
Command: java -cp fitnesse.jar; fit.FitServer devcode 8082 12
Exit code: -1
Time elapsed: 1.013 seconds
Standard Error:
Error: Could not find or load main class fit.FitServer
Internal Exception:
FitClient: external process terminated before a connection could be established.
code at C# side
namespace ConsoleApplication1
{
public class CalculatorRunner : ColumnFixture
{
int arg1;
public int Arg1
{
get { return arg1; }
set { arg1 = value; }
}
int arg2;
public int Arg2
{
get { return arg2; }
set { arg2 = value; }
}
public int Sum()
{
return Arg1 + Arg2;
}
}
}
And Code for Fitnesse Page
!path C:\..\bin\Debug\*.*
!| import |
| ConsoleApplication1 |
!1 Let's run a simple calculator
!| CalculatorRunner |
| Arg1 | Arg2 | Sum? |
| 0 | 0 | 0 |
| 1 | 1 | 3 |
| 1 | 3 | 4 |
| 2 | 3 | 5 |
For C# fixtures you need a different fit server:
http://fitsharp.github.io/Fit/UsingFitnesse.html
Related
Here is the example from the doc
The doc says the
Integer literals are automatically converted to doubles when necessary:
double z = 1; // Equivalent to double z = 1.0.
But when I check the runtimeType the type is int
print(z.runtimeType); // prints to int
I guess you are testing using dartpad.dev or compiled your code to JavaScript. In JavaScript, there are no separate types of int and double so Dart are just guessing the type, when using runtimeType, based on the current value since JavaScript are representing all numbers as double internally.
But if we are running in the Dart VM or compiled to native code, we can determine the type. So you example will return double as the type of z if running with Dart VM.
void main(List<String> args) {
print(1.1.runtimeType); // dartpad: double, dartvm: double
print(1.0.runtimeType); // dartpad: int, dartvm: double
print(1.runtimeType); // dartpad: int, dartvm: int
}
See also the note about the different behavior of the int type, when compiled to JavaScript, in the Dart documentation:
https://api.dart.dev/stable/2.12.3/dart-core/int-class.html
A more detailed example is showed here where we can see how a double declared variable behave differently when running the Dart code in DartVM vs as compiled JavaScript:
void main(List<String> args) {
print('| toString | runtimeType | is int | is double |');
for (double i = 0; i <= 2; i += 0.5) {
print('| ${i.toString().padRight(8)} | '
'${i.runtimeType.toString().padLeft(11)} | '
'${(i is int).toString().padLeft(6)} | '
'${(i is double).toString().padLeft(9)} |');
}
}
Which returns the following using DartPad:
| toString | runtimeType | is int | is double |
| 0 | int | true | true |
| 0.5 | double | false | true |
| 1 | int | true | true |
| 1.5 | double | false | true |
| 2 | int | true | true |
While DartVM returns:
| toString | runtimeType | is int | is double |
| 0.0 | double | false | true |
| 0.5 | double | false | true |
| 1.0 | double | false | true |
| 1.5 | double | false | true |
| 2.0 | double | false | true |
And for int we can do the same:
void main(List<String> args) {
print('| toString | runtimeType | is int | is double |');
for (int i = 0; i <= 2; i += 1) {
print('| ${i.toString().padRight(8)} | '
'${i.runtimeType.toString().padLeft(11)} | '
'${(i is int).toString().padLeft(6)} | '
'${(i is double).toString().padLeft(9)} |');
}
}
DartPad:
| toString | runtimeType | is int | is double |
| 0 | int | true | true |
| 1 | int | true | true |
| 2 | int | true | true |
DartVM:
| toString | runtimeType | is int | is double |
| 0 | int | true | false |
| 1 | int | true | false |
| 2 | int | true | false |
I am struggling with one code line. It is a Key generation Line for a Expert Adviser. Can someone help me figure out how I can generate key by using this line:
int key=3*(StringToInteger(StringSubstr(IntegerToString(AccountNumber()), 0, 3)))+333333;
And what is the problem?
int accountNumber = AccountNumber();
string accountNumberString = IntegerToString(accountNumber);
string accountNumberStringFirst3Digits=
StringSubstr(accountNumberString,0,3);
int accountNumberFirstThreeDigits = StringToInteger(accountNumberStringFirst3Digits);
int accountNumberFirstThreeDigitsMultiplied = 3 * accountNumberFirstThreeDigits;
int key = accountNumberFirstThreeDigitsMultiplied + 333333;
Can someone help me figure out how to generate key by this line?
Welcome, certainly, let's look on that :
int key = 3*(StringToInteger(StringSubstr(IntegerToString(AccountNumber()), 0, 3)))+333333;
Your code actually means this:
// +------------------------------------------------------------------------------- type declaration
// | +--------------------------------------------------------------------------- variable name definition
// | | +------------------------------------------------------------------------- assignment operator
// | | | +----------------------------------------------------------------------- compile-time integer constant
// | | | | +--------------------------------------------------------------------- multiply operator
// | | | | | +-------------------------------------------------- MT4 system function: StringToInteger( aString )
// | | | | | | +------------------------------------ MT4 system function: StringSubstr( aString, aPosToStartSubstrFrom, aSubstrLength )
// | | | | | | | +------------------- MT4 system function: IntegerToString( aIntNum ) | |
// | | | | | | | | +---- MT4 system function: AccountNumber() | |
// | | | | | | | | | | |
// | | | | | | | | | +------------------------------------------------------------------+ |
// | | | | | | | | | | +------------------------------------------------------------------------------+
// | | | | | | | | | | |
int key = 3 * ( StringToInteger( StringSubstr( IntegerToString( AccountNumber() ), 0, 3 ) ) )
+ 333333;
// | ||
// +------||----------------------------------------------------------------- add operator
// +|----------------------------------------------------------------- compile-time integer constant
// +----------------------------------------------------------------- literal MQL4-language syntax-terminator
The code above both defines and generates a fair integer value, so wherever your Expert Advisor code refers to a value of key, this calculated value will be used ( see also the documentation about the New-MQL4 scope-of-validity, inside which this variable remains visible ).
Given a table games and column identifiers, whose type is HSTORE:
| id | name | identifiers |
|----|------------------|------------------------------------|
| 1 | Metal Gear | { sku: 109127072, ean: 512312342 } |
| 2 | Theme Hospital | { sku: 399348341 } |
| 3 | Final Fantasy | { ean: 109127072, upc: 999284928 } |
| 4 | Age of Mythology | { tbp: 'a998fa31'} |
| 5 | Starcraft II | { sku: 892937742, upc: 002399488 } |
How can I find if a given set of key-value pairs has at least one match in the database?
For example, if I supply this array: [ {sku: 109127072 }, { upc: 999284928 } ], I should see:
| id | name | identifiers |
|----|----------------|------------------------------------|
| 1 | Metal Gear | { sku: 109127072, ean: 512312342 } |
| 3 | Final Fantasy | { ean: 109127072, upc: 999284928 } |
For rails 5 you, think, should try using or operator like:
h = { sku: 109127072, upc: 999284928 }
rela = Person.where("identifiers -> ? = ?", h.keys.first, h[h.keys.first])
h.keys[1..-1].reduce(rela) {|rela, key| rela.or("identifiers -> ? = ?", key, h[key]) }
# => relation with ored-arguments
for non 5-th rails you shall use arel as descibed here.
Can not understand why aggregateQuery always returns an empty result. Tried to test in aql, the same problem: 0 rows in set.
Indexes are all there.
aql> show indexes
+---------------+-------------+-----------+------------+-------+------------------------------+-------------+------------+-----------+
| ns | bin | indextype | set | state | indexname | path | sync_state | type |
+---------------+-------------+-----------+------------+-------+------------------------------+-------------+------------+-----------+
| "test" | "name" | "NONE" | "profiles" | "RW" | "inx_test_name" | "name" | "synced" | "STRING" |
| "test" | "age" | "NONE" | "profiles" | "RW" | "inx_test_age" | "age" | "synced" | "NUMERIC" |
aql> select * from test.profiles
+---------+-----+
| name | age |
+---------+-----+
| "Sally" | 19 |
| 20 | |
| 22 | |
| 28 | |
| "Ann" | 22 |
| "Bob" | 22 |
| "Tammy" | 22 |
| "Ricky" | 20 |
| 22 | |
| 19 | |
+---------+-----+
10 rows in set (0.026 secs)
aql> AGGREGATE mystream.avg_age() ON test.profiles WHERE age BETWEEN 20 and 29
0 rows in set (0.004 secs)
It seems that you are trying the example here.
There are two problems about the udf script. I paste the code of the lua script :
function avg_age(stream)
local function female(rec)
return rec.gender == "F"
end
local function name_age(rec)
return map{ name=rec.name, age=rec.age }
end
local function eldest(p1, p2)
if p1.age > p2.age then
return p1
else
return p2
end
end
return stream : filter(female) : map(name_age) : reduce(eldest)
end
First, there is no bin named 'gender' in your set, so you got 0 rows after aggregateQuery.
Second, this script isn't doing exactly what the function name 'avg_age' means, it just return the eldest record with name and age.
I paste my code bellow, it just replace the reduce func, and alert the map and filter func to meat the demand. You can just skip the filter process.
function avg_age(stream)
count = 0
sum = 0
local function female(rec)
return true
end
local function name_age(rec)
return rec.age
end
local function avg(p1, p2)
count = count + 1
sum = sum + p2
return sum / count
end
return stream : filter(female) : map(name_age) : reduce(avg)
end
The output looks like bellow :
AGGREGATE mystream.avg_age() ON test.avgage WHERE age BETWEEN 20 and 29
+---------+
| avg_age |
+---------+
| 22 |
+---------+
1 row in set (0.001 secs)
I need to write a criteria or HQL that selects InterfaceVersion only with the latest version for each interfaceCode. Version consists of majorVersion.minorVersion.editVersion.
exemple:
InterfaceVersion table:
id | interface_code_id | major_version | minor_version | edit_version
---|-------------------|---------------|---------------|-------------
1 | 1 | 1 | 1 | 6
2 | 1 | 1 | 5 | 0
3 | 2 | 1 | 0 | 0
4 | 2 | 0 | 1 | 0
5 | 2 | 2 | 0 | 1
6 | 2 | 1 | 3 | 6
expected result would be:
InterfaceVersions instances with ids [2, 5]
I have this GORM domain classes(simplified):
InterfaceCode{
int id
String code
static hasMany = [ versionList: InterfaceVersion]
}
InterfaceVersion{
int id
InterfaceCode interfaceCode
int majorVersion
int minorVersion
int editVersion
static belongsTo = [ InterfaceCode ]
static constraints = {
interfaceCode(unique:['majorVersion','minorVersion','editVersion'])
}
}
So far I've been able to come up with this sql:
SELECT t1.*
FROM Interface_Version t1
Left Outer Join Interface_Version T2
On (T1.Interface_Code_Id = T2.Interface_Code_Id And
(T1.Major_Version < T2.Major_Version Or
(T1.Major_Version = T2.Major_Version And T1.Minor_Version < T2.Minor_Version) Or
(T1.Major_Version = T2.Major_Version And T1.Minor_Version = T2.Minor_Version And T1.Edit_Version < T2.Edit_Version ) )
)
WHERE t2.id IS NULL
Can you please convert this sql to hql or critearia or come up with something nicer ?