Revision: 4373
Author: [email protected]
Date: Mon Dec 6 12:58:32 2010
Log: Edited wiki page HowToUseCSharp through web user interface.
http://code.google.com/p/robotframework/source/detail?r=4373
Modified:
/wiki/HowToUseCSharp.wiki
=======================================
--- /wiki/HowToUseCSharp.wiki Mon Dec 6 12:54:47 2010
+++ /wiki/HowToUseCSharp.wiki Mon Dec 6 12:58:32 2010
@@ -11,9 +11,58 @@
This simple example demonstrates how to use C# language from Robot
Framework test libraries. The example assumes that you have the .Net
framework and IronPython installed on your system. This version is
implemented and tested on Windows.
-= Details =
-
-Add your content here. Format your content with:
- * Text in *bold* or _italic_
- * Headings, paragraphs, and lists
- * Automatic links to other wiki pages
+= System under test =
+
+The demo application is a very simple C# class whose two methods simply
add two numbers and concatenate two strings, which should be enough for the
purpose of this exercise.
+
+{{{
+namespace Test
+{
+ public class Combine
+ {
+ public int AddNumbers(int number1, int number2)
+ {
+ return number1 + number2;
+ }
+
+ public string AddStrings(string string1, string string2)
+ {
+ return string1 + " " + string2;
+ }
+ }
+}
+}}}
+
+
+= Test library =
+
+A simple test library that can interact with the above using the .Net CLR.
The methods’ names in that library will act as keywords for the Robot
Framework.
+
+CombineLibrary:
+
+Simple module without a class:
+
+CombineLibrary.py
+
+{{{
+
+import clr
+clr.AddReferenceToFileAndPath('Combine.dll') #include full path to Dll if
required
+from Test import Combine
+
+def add_two_numbers(num1, num2):
+ try:
+ intNum1 = int(num1)
+ intNum2 = int(num2)
+ except:
+ raise Exception("Values must be integer numbers!")
+ cmb = Combine()
+ total = cmb.AddNumbers(intNum1, intNum2)
+ return str(total)
+
+def add_two_words(word1, word2):
+ cmb = Combine()
+ return cmb.AddStrings(word1, word2)
+
+}}}
+