ExcelDNA Unit Testing with NUnit

368 views
Skip to first unread message

Jim

unread,
Jul 26, 2013, 4:34:01 AM7/26/13
to exce...@googlegroups.com
Hi,

I am trying to implement Unit Testing of my AddIn (C#) with NUnit, but have some issues to setup a working environment.

I've tried to setup the connection as follows.

[TestFixtureSetUp]
        public void InitialSetup()
        {
            var missing = System.Reflection.Missing.Value;
            Excel.Application excelApp = new Excel.Application();
            excelApp.Visible = true;

            bool ok = excelApp.RegisterXLL(@"F:\ExcelAddIn.xll");
            if (!ok) throw new Exception("not OK!");

            Microsoft.Office.Interop.Excel.Workbook wbk =
                excelApp.Workbooks.Add(@"F:\My_Excel_File.xlsx");


            excelApp.Run();
        }

And the Test is very simple to get Data from One cell and compare it to expected result
[Test]
        public void _cell(string Collumn, int Row)
        {

            var actual = ml._cell(CollumnT, RowT);

            // Step 3 - Assert
            int expected = 100; // This makes it clear what you expect.
            Assert.AreEqual(expected, actual);
        }

In the highlited line I've got an issue .
Is it possible for someone to post a very simple sample of Unit Testing, which will include an excel workbook involvement.
Thank you in advance

Jim

unread,
Jul 26, 2013, 8:53:42 AM7/26/13
to exce...@googlegroups.com
I am still trying to implement the above example.

Now, I've got an exception on LIne
            excelApp.Run();

Exception
at Microsoft.Office.Interop.Excel.ApplicationClass.Run(Object Macro, Object Arg1, Object Arg2, Object Arg3, Object Arg4, Object Arg5, Object Arg6, Object Arg7, Object Arg8, Object Arg9, Object Arg10, Object Arg11, Object Arg12, Object Arg13, Object Arg14, Object Arg15, Object Arg16, Object Arg17, Object Arg18, Object Arg19, Object Arg20, Object Arg21, Object Arg22, Object Arg23, Object Arg24, Object Arg25, Object Arg26, Object Arg27, Object Arg28, Object Arg29, Object Arg30)
at ChartExcelAdding.UnitTests.MainLogicUnitTests.InitialSetup()

Can someone share with me what is the correct synatx of excelApp.Run()?
Thanks
Reply all
Reply to author
Forward
0 new messages