Oren Eini

CEO of RavenDB

a NoSQL Open Source Document Database

Get in touch with me:

oren@ravendb.net +972 52-548-6969

Posts: 7,640
|
Comments: 51,260
Privacy Policy · Terms
filter by tags archive
time to read 3 min | 523 words

Let me state it againMercedes Lackey is awesome. And by that I mean that she is a really good.

Product image for ASIN: 0886779898 Brightly Burning is another story in Mercedes Lackey's Valdemar books, the book is about Lavan Firestorm (an important figure in Valdemar's history) and his story. And his end, the book is (like all the other Mercedes Lackey's books I've read) captivating and hard to put down. Unlike the rest of her books, this does not have a happy ending. In fact, it's not a very happy book, from the start to the end, Lavan is in... unusual situations (tortured, in love with a talking horse*, losing friends, feared, misunderstood, forced to kill a lot of strangers,losing his Companion, dying). The ending seems to be the only way out of a very bad situation, I cannot help but think that if the hero would've been allows to grow up, there would have been... problems. Either with the hero, or with the people around him. As it is, the story makes for a great legend, is told in a really convincing way and made me wish so much that it would go some other way. I wouldn't recommend it unless you already read about Valdemar, as it's not very good introduction for . If you have read Valdemar's novels before, than it's a very good read.

Product image for ASIN: 0765302209 To Light A Candle is the second book in  The Obsidian Trilogy, following Product image for ASIN: 0765341417 The Outstretched Shadow. Those books talks about a world where most of the humans are walled in a single city, and magic is something of a science, and a boring one at that. From there the story gets complicated, and involves elves, Wildmagic, Knight-mages, demon and a really good story. The world is real and very consistent; magic is something that has limits and bounds, and is explained very well (at least as well as you can explain magic :-) ). The plot is interesting to watch, and the characters are excellent. Highly recommended.

Product image for ASIN: 0756402468 Sanctuary is the next one on my reading list, it's the first trilogy by Mercedes Lackey that I'm ending, so I'm really interested in how she would finish the book. So far the The Dragon Jousters books were very good, so I've high hopes, I'll blog about it when I'm done.

Some more interesting books can be found here, I really like Hienlien, and I put some of those on my reading list (which is already bigger than I can manage).

*Yes, that is not an accurate description, so sue me :-)

time to read 2 min | 224 words

I just found this: Adding JScript.NET Macro Support to Your Application [via CraigBlog]

This is a very cool (and simple, and elegant) idea. What I like even more is taking this idea further, and using this to do the last layer glue for the application. Considerring the level of seperation that we usually have, we (hopefully) write an application by creating small parts that are independant of each other, and only at the end we bring them together, this allows to create an application that would be far easier for the user to modify.

For example, let's say that I would do that for NQA, here is how you would translate an HQL statement from an existing project [Uncompiled code]:

var dataMgr = AppDataManager.DefaultAppManager;
var myPrj = dataMgr.GetProjectByName("My NQA Project");
MessageBox.Show(myPrj.TranslateHql("from Customer cst where cst.PayementRecieved = true"));

I might get to that, if/when I'll get NQA to the state that I want it.

time to read 2 min | 276 words

I've one test class that takes over a minute to execute(!), that is unacceptable. Taking a look inside, I can see why this is so, it construct the database and creates an AppDomain on each and every test. Moving those to the TestFixtureSetup made it run in 1.6 seconds, which I consider far better.

The second offender took only 22 seconds to run, also for the same reason, moving to TestFixtureSetup can it down to 1.5, which is much better. The other main offender was 10 seconds (down to 0.67).

It took me 30 minutes, and I cut the time to run my test suite from over 140 seconds to 27 seconds, but that is still not enough.

One class is testing the AppDomain load/unload, so there isn't much that can be done about it, but I still managed to move it from 10 seconds to 5.

The next thing to tackle was 14.5 seconds spent on UI testing. I've commented before, databases and networking may be slow, but until you look at the timing for UI tests, you won't believe how slow the UI is.

Considerring my previous diffculities with testing the UI, I removed those tests all together, and removed the reference to MbUnitForms.

Total time to run the tests before "optimization"*: 140+ Secodns.
Total time to run the test after "optimization"*: 11.45 seconds.

Now I no longer have to look for something else to do while I'm running the tests. :-)

time to read 18 min | 3593 words

Anyone can suggest a pattern to do that? I'm currently trying to test some of my multi threaded code, and I get into a whole lot of trouble.

The problem is that I'm trying to test that things happen in two threads at the same time, and I'm not sure I'm doing it properly. Per Udi's suggestion I changed my code to use notifications, rather than busy waiting.

Because of the need to syncronized between the threads, I created the following method:

public void ExecuteInUIThread(Delegate d, params object[] parameters)
{
  if(this.InvokeRequired)
     Invoke(d,parameters);
  else
     d.DynamicInvoke(parameters); 
}

The problem is how to test that the method called from the class I'm testing is the right one, I'm not so sure about how to do this properly. But before I get to the solution, here is the problem:

I've a class which is called from the UI thread to do work, it spun off a thread which does it works, and when done, it call the ExecuteInUIThread method with a delegate to an OnSuccess or OnFailure method. My problem is with the tests, how do I make sure that I get the correct response from the class. Take into account that I'm mocking the class which contains the ExecuteInUIThread method, and that is a complex issue.

I solved it this way, using a custom constraint in the mock object, which allows me to run my own test method when the mock is called, here is what I've, it's an extention of the idea I'd with DelegatingConstraint:

public class DelegatingConstraintWithArgs : BaseConstraint

      {

            private readonly string message;

            private readonly int numberOfParams;

            private Delegate d;

            private int currentParam = 0;

            private object[] args;

            private bool delegateCalled = false;

 

            public DelegatingConstraintWithArgs(Delegate d, int numberOfParams, string message)

            {

                  this.message = message;

                  this.d = d;

                  this.numberOfParams = numberOfParams;

                  this.args = new object[numberOfParams];

            }

 

 

            public override bool Eval(object val)

            {

                  args[currentParam] = val;

                  currentParam += 1;

                  if (currentParam == numberOfParams)

                  {

                      bool ret= (bool) d.DynamicInvoke(args);

                      delegateCalled = true;

                      return ret;

                  }

                  return true;

            }

 

            public override string Message

            {

                  get { return message; }

            }

 

            public bool DelegateCalled

            {

                  get { return delegateCalled; }

            }

}    

This class will gather the paramters of the method, and when it will reach the final number, will execute the delegate on them. This allows me to invoke the delegate that I get from the class under test*. I can execute it and then observe the effects.

On a more general level, this allows you to execute your own code from the mocked object, without writing much code. It's nice, but very much open to abuse, and more over, I'm not so sure that I'm not abusing it myself right now.

For instance, here is my current test, I setup quite a bit of expectations that it needs, and then run the tests, waiting until after the method is called. Verify()ing the mock is done on the TearDown() method.

[Test]

public void ExecuteQuery_NoParameters()

{

      ExpectNoError();

      DelegatingConstraintWithArgs cs = new DelegatingConstraintWithArgs(new ExecuteInUIThreadDeleagate(ExecuteInUIThread),

            2,"-not-relevant-");

      mockIQueryView.SetupResult("HqlQueryText",nonParametrized);

      mockIQueryView.SetupResult("Parameters",new Hashtable());

      mockIQueryView.Expect("StartWait",null,null,null);

      mockIQueryView.Expect("DisplayObjectGraph",

            objectGraphConstraint);

      mockIQueryView.Expect("DisplayDataSet",

            new And(new IsTypeOf(typeof(DataSet)),dataSetConstraint));

      mockIQueryView.Expect("ShowObjectGraph");

      mockIQueryView.Expect("EndWait", new IsTypeOf(typeof(string)));

      mockIQueryView.Expect("ExecuteInUIThread",cs,cs);

      context.ExecuteQuery();

      while(!cs.DelegateCalled)

            Thread.Sleep(100);

}

* As a side note, I've here two or three layers of delegates, spooky.

time to read 2 min | 321 words

The single bad thing that I've found in TiddlyWiki is that it doesn't warns you about unsaved changes when you leave the page, with a potential to lose those changes.

Here is the fix* Change the:

  1. <body> tag to:
    <body onload="main()" onunload="askSaveChanges()">
  2. Add the following function to the <script type="text/javascript">
    function askSaveChanges()
    {
      
    var save = confirm("Save wiki's changes?");
      
    if(save)
            saveChanges();
    }

Now it will ask you at any unloading if you want to save. Pretty good solution in my book for this problem.

* This will ask for any unloading, whatever there are changes or not, so it's not ideal.

FUTURE POSTS

No future posts left, oh my!

RECENT SERIES

  1. API Design (10):
    29 Jan 2026 - Don't try to guess
  2. Recording (20):
    05 Dec 2025 - Build AI that understands your business
  3. Webinar (8):
    16 Sep 2025 - Building AI Agents in RavenDB
  4. RavenDB 7.1 (7):
    11 Jul 2025 - The Gen AI release
  5. Production postmorterm (2):
    11 Jun 2025 - The rookie server's untimely promotion
View all series

Syndication

Main feed ... ...
Comments feed   ... ...