Testing asynchronous function with mocha

You have to specify the callback done as the argument to the function which is provided to mocha – in this case the it() function. Like so: describe(‘api’, function() { it(‘should load a user’, function(done) { // added “done” as parameter assert.doesNotThrow(function() { doRequest(options, function(res) { assert.equal(res, ‘{Object … }’); // will not fail assert.doesNotThrow … Read more

How do I run unittest on a Tkinter app?

Bottom line: pump the events with the below code after an action that causes a UI event, before a later action that needs the effect of that event. IPython provides an elegant solution without threads it its gui tk magic command implementation that’s located in terminal/pt_inputhooks/tk.py. Instead of root.mainloop(), it runs root.dooneevent() in a loop, … Read more

F# development and unit testing? [closed]

Test-driven developers should feel right at home in functional languages like F#: small functions that give deterministically repeatable results lend themselves perfectly to unit tests. There are also capabilities in the F# language that facilitate writing tests. Take, for example, Object Expressions. You can very easily write fakes for functions that take as their input … Read more

Insert blob in oracle database with C#

Here is an example to insert blob data in oracle using c# and procedures (you said prefer that means you may). using System; using System.Data; using Oracle.DataAccess.Client; using Oracle.DataAccess.Types; using System.IO; using System.Text; //Step 1 // Connect to database // Note: Modify User Id, Password, Data Source as per your database setup string constr = … Read more

How do I mock a class without an interface?

Simply mark any method you need to fake as virtual (and not private). Then you will be able to create a fake that can override the method. If you use new Mock<Type> and you don’t have a parameterless constructor then you can pass the parameters as the arguments of the above call as it takes … Read more