DCSIMG
March 2007 - Posts - Doron Goldberg

March 2007 - Posts

!מרון המלך

Posted by dorong | with no comments
תגים:

After finishing the wwf hands on lab, I started practicing my first wf project as part of my preparations for starting working with it in two of our upcoming projects (one of them is for distributing email's inside the organization and the other is for managing content&forms inside sps 2003!!!).

 

The first project I created is a very simple wf which is exposed as a web service and uses a simple calculator (add/divide/subtract/multiply) class to perform some calculations.

 

I used nunit in order to test the calculator class and the exposed web service automatically created for the wf itself.

 

Well, that was too easy and wasn't exactly a real automated unit test...

Next thing I wanted to do is test a wf, not a wf interface - set the parameters, launch the wf from within the test fixture and validate the results.

I will pretend I was TDDing in this example so I'll start from the tests of a simple flow which will receive a number and set the IsEven property:

 [TestFixture]
    public class MySecondNotWSWorkFlowTEST
    {
        private int isEvenInt;
        private bool isEven;
        private bool TestCompleted;
        private WorkflowRuntime wr;
        void workflowRuntime_WorkflowCompleted(object sender, WorkflowCompletedEventArgs e)
        {
            
            isEven = (bool)e.OutputParameters["IsEven"];
            if (isEven)
                isEvenInt = 1;
            TestCompleted = true;
        }
        [TestFixtureSetUp]
        public void FixtureSetUp()
        {

            wr = new WorkflowRuntime();
            wr.WorkflowCompleted += workflowRuntime_WorkflowCompleted;
            wr.StartRuntime();
        }
        [SetUp]
        public void TestSetUp()
        {
            TestCompleted = false;
            isEvenInt = 0;
        }
        [Test]
        public void EvenTEST()
        {
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("Number", 10);
            WorkflowInstance instance = wr.CreateWorkflow(typeof(MySecondNotWSWorkFlow.Workflow1), parameters);
            instance.Start();
            while(!TestCompleted){}
            Assert.AreEqual(1,isEvenInt);
        }
        [Test]
        public void OddTEST()
        {
            Dictionary<string, object> parameters = new Dictionary<string, object>();
            parameters.Add("Number", 11);
            WorkflowInstance instance = wr.CreateWorkflow(typeof(MySecondNotWSWorkFlow.Workflow1), parameters);
            instance.Start();
            while (!TestCompleted) { }
            Assert.AreEqual(0, isEvenInt);
        }
    }

As you can see the test is a bit weird:

1. Why using isEvenInt?

 Because accessing isEven from the test functions resulted an error on the second test:

NUnit.Framework.AssertionException 
at NUnit.Framework.Assert.DoAssert(IAsserter asserter)
at NUnit.Framework.Assert.IsTrue(Boolean condition, String message, Object[] args)
at NUnit.Framework.Assert.IsTrue(Boolean condition)
at CalculatorTEST.MySecondNotWSWorkFlowTEST.OddTES

I'm still not sure why, I hope to resolve it in the future.

2. While (!TestCompleted) { } ?!?!?

I do not know how to test async functions using nunit - maybe some advanced users of the tool can help on that?

And the flow:

 

Flow code:

    public sealed partial class Workflow1: SequentialWorkflowActivity
    {
        public static DependencyProperty IsEvenProperty = System.Workflow.ComponentModel.DependencyProperty.Register("IsEven", typeof(bool), typeof(Workflow1));
        [Description("This is the description which appears in the Property Browser")]
        [Category("This is the category which will be displayed in the Property Browser")]
        [Browsable(true)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
        public bool IsEven
        {
            get
            {
                return ((bool)(base.GetValue(Workflow1.IsEvenProperty)));
            }
            set
            {
                base.SetValue(Workflow1.IsEvenProperty, value);
            }
        }
        public Workflow1()
        {
            InitializeComponent();
        }
        private  CalculationOperation operation;
        public CalculationOperation Operation
        {
            get { return operation; }
            set { operation = value; }
        }
        private int number;
                                    
        public int Number
        {
            get { return number; }
            set { number = value; }
        }

        private bool isprimary;

        public bool IsPrimary
        {
            get { return isprimary; }
            set { isprimary = value; }
        }

        private void codeActivity1_ExecuteCode(object sender, EventArgs e)
        {
            IsEven = true;
        }

        private void codeActivity2_ExecuteCode(object sender, EventArgs e)
        {
            IsEven = false;
        }
    
    }

What next?

 

I have some ideas in mind:

1. WWFMock

2. Using a flow in order to test a second flow, creating Assert activities maybe?

3. Using a flow in order to test regular non-flow based applications

 

All of the above are "research" ideas and I'm not sure they are of any real use, are they?

Posted by dorong | 1 comment(s)
תגים:, ,

Can't view Hebrew data stored in your Oracle database using TOAD / PL/SQL developer ?

That, also, is a well known problem with a very usually-it-works solution for Windows users:

In order to be able to view Hebrew fonts properly from Oracle you need to set the NLS_LANG registry key.

The key can be found here:

HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\HOMEID\NLS_LANG where ID is the unique number identifying the Oracle home.

The right value of the key for Hebrew fonts is: HEBREW_ISRAEL.IW8MSWIN1255

 

The full explanation + additional information can be found here.

Posted by dorong | 6 comment(s)
תגים:,

While working with oracle in .NET projects I came across one very annoying reoccurring problem:

"Could not create an environment: OCIEnvCreate returned -1"

 Two things came up:

1 - permissions issue

2 - a missing ORACLE_HOME environment variable

"Ever received this error message while trying to connect to a Oracle database from .Net and wondered why this is happening. Well, I was banging my head on my workstation for about a week.

The whole internet pointed to the oracle bin folder not having permissions to ASPNET account. I gave full access for all the folders to Everyone in this world in addition to ASPNET account. ( I guess only Read & Execute and List folder contents permissions are enough). Still, my ASP.Net application was not connecting to the database.

So, what was the problem ???

My machine did not have a ORACLE_HOME environment variable. There was a Oracle forms installation and I guess my application was trying to create the environment inside the Oracle forms folder.

I created a ORACLE_HOME environment variable pointing to the Oracle directory. Restarted the machine. Bingo! it started working."

Source -> here

Posted by dorong | with no comments
תגים:,

במפגש הקרוב תהיה לנו הזדמנות לפגוש את שחר פריש שיעביר את ההרצאות. שחר הינו חבר בכיר בצוות הפיתוח של  Excel Services ומגיע לביקור בישראל. שחר כתב גם ספר על הנושא, מספר מאמרים ב-MSDN ובעל הבלוג המשמעותי ביותר על  Excel Services.

Excel Services היא טכנולוגיה של Microsoft Office SharePoint שהופכת לפשוטים יותר את השימוש, השיתוף, האבטחה והניהול של חוברות עבודה של Microsoft Office Excel 2007 כדוחות אינטראקטיביים העובדים בסביבת דפדפן בצורה עקבית בכל חלקי הארגון. ישנם שלושה רכיבים בסיסיים של Excel Services  שפועלים זה עם זה ויוצרים יחד את העיצוב המבני הכולל של  Excel Services

1.        Excel Calculation Services (ECS) הוא ה"מנגנון" של Excel Services שטוען את חוברת העבודה, מחשב בנאמנות מלאה עם Microsoft Office Excel 2007,  ומרענן נתונים חיצוניים מבסיסי נתונים רלציוניים.

2.        Excel Web Access (EWA)  הוא רכיב Web Part שמציג ומאפשר אינטראקציה עם חוברת עבודה של Microsoft Office Excel בדפדפן באמצעות Dynamic Hierarchical Tag Markup Language (DHTML) ו- JavaScript בלי צורך להוריד פקדי ActiveX למחשב הלקוח, ואפשר לחבר אותו אל רכיבי Web Part אחרים בלוחות מחוונים ובדפי Web Part אחרים.

3.        Excel Web Services (EWS) הוא שירות רשת שמתארח ב- Microsoft Office SharePoint Services אשר מספק מספר שיטות שמפתחים יכולים להשתמש בהן כממשק לתכנות יישומים (API) כדי לבנות יישומים מותאמים אישית גם מחוץ ל-SharePoint המבוססים על חוברת עבודה של Excel.

לחץ כאן להרשמה.

Posted by dorong | with no comments