﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>meisinger commented on Find the issue</title><description>the exception type is wrong
  
either that or you have determined that writing unit tests are silly and not needed
</description><link>http://ayende.com/4553/find-the-issue#comment15</link><guid>http://ayende.com/4553/find-the-issue#comment15</guid><pubDate>Thu, 15 Jul 2010 17:11:04 GMT</pubDate></item><item><title>meo commented on Find the issue</title><description>TMM, it is strange design, when you have 'firstInstance' != 'secondInstance' due to same key and different values in it (in 3rd test), but adding second after the first one will fail with InvalidOperation. It's inconsistent
</description><link>http://ayende.com/4553/find-the-issue#comment14</link><guid>http://ayende.com/4553/find-the-issue#comment14</guid><pubDate>Tue, 13 Jul 2010 14:50:48 GMT</pubDate></item><item><title>Jon Norton commented on Find the issue</title><description>In CannotAddDuplicatedItems() the test could pass due to an InvalidOperationException being thown before the last Add where the test is actually expecting the exception to be thrown. The Arrange portion of the test is included in the Action and Assert section represented by the Assert.Throws.
</description><link>http://ayende.com/4553/find-the-issue#comment13</link><guid>http://ayende.com/4553/find-the-issue#comment13</guid><pubDate>Mon, 12 Jul 2010 20:59:53 GMT</pubDate></item><item><title>Frank Quednau commented on Find the issue</title><description>Just from the API perspective I don't like the asymmetry of adding ApplicationInstances and removing Guids. 
</description><link>http://ayende.com/4553/find-the-issue#comment12</link><guid>http://ayende.com/4553/find-the-issue#comment12</guid><pubDate>Mon, 12 Jul 2010 17:54:21 GMT</pubDate></item><item><title>Martin O'Keefe commented on Find the issue</title><description>'ApplicationInstance'
  
  
You need to maintain references to the GUID keys - the keys are required by consumers of values.
  
  
I would have suggested making the key the Type, but you are passing two strings as values - that's out.
  
  
I'm assuming that you chose GUID because the values are not user configurable - otherwise const string keys would appear to be better.
  
  
If the key is to be dynamic it seems that you need to make the key deterministic based on the type and its scope etc.
  
</description><link>http://ayende.com/4553/find-the-issue#comment11</link><guid>http://ayende.com/4553/find-the-issue#comment11</guid><pubDate>Mon, 12 Jul 2010 08:04:43 GMT</pubDate></item><item><title>Andrey Titov commented on Find the issue</title><description>You changed them to TryRemove, TryAdd and TryGet to support concurrency?
</description><link>http://ayende.com/4553/find-the-issue#comment10</link><guid>http://ayende.com/4553/find-the-issue#comment10</guid><pubDate>Mon, 12 Jul 2010 05:34:24 GMT</pubDate></item><item><title>Steve Py commented on Find the issue</title><description>If ApplicationInstanceDictionary extends Dictionary, then it would appear that you are testing the default behaviour of a Dictionary, though the types of exceptions thrown might be different.
</description><link>http://ayende.com/4553/find-the-issue#comment9</link><guid>http://ayende.com/4553/find-the-issue#comment9</guid><pubDate>Mon, 12 Jul 2010 01:29:12 GMT</pubDate></item><item><title>Rik Hemsley commented on Find the issue</title><description>When I said Dictionary, the blog software ate my angle brackets, because it's rubbish (it still fails to 'remember me' despite offering to). So I meant a dictionary of Guid =&gt; string.
  
  
  
</description><link>http://ayende.com/4553/find-the-issue#comment8</link><guid>http://ayende.com/4553/find-the-issue#comment8</guid><pubDate>Sun, 11 Jul 2010 20:52:52 GMT</pubDate></item><item><title>Kevin McCormick commented on Find the issue</title><description>Since this collection is tied to the class, the guid/key restrictions are kind of unnecessary.  The dictionary class should manage duplicates, keys, etc. internally, and you should be able to manipulate the collection via index, linq, and provide indexing by guid only as an added bonus (ie, myColl.FindByGuid() ) if it's really necessary.
</description><link>http://ayende.com/4553/find-the-issue#comment7</link><guid>http://ayende.com/4553/find-the-issue#comment7</guid><pubDate>Sun, 11 Jul 2010 19:32:57 GMT</pubDate></item><item><title>Rik Hemsley commented on Find the issue</title><description>Going by what I see in the tests, ApplicationInstanceDictionary is no different from Dictionary
&lt;guid,&gt;
, so you should use the .NET class and this means you don't need to test it.
  
</description><link>http://ayende.com/4553/find-the-issue#comment6</link><guid>http://ayende.com/4553/find-the-issue#comment6</guid><pubDate>Sun, 11 Jul 2010 17:51:33 GMT</pubDate></item><item><title>fschwiet commented on Find the issue</title><description>Just yesterday I hit a bug where within one session I read an item (discarding the result) then wrote an item with the same key.  This caused an exception, as would be expected by the last test.  I would've preferred it would just overwrite.  I assumed I was doing it wrong, maybe that will change.
  
  
The design problem may be that adding an item may throw an exception (if it has same key as existing), while the only way the caller can check if that will happen (by loading whatever has that key) could also throw an exception.  So any typical use then involves handling an exception.
  
  
Just feedback on the last test...  Its better to only have the one line that will throw an exception within the Assert.Throws() expression.  Otherwise this test may pass for the wrong reason when an earlier line fails inappropriately.
</description><link>http://ayende.com/4553/find-the-issue#comment5</link><guid>http://ayende.com/4553/find-the-issue#comment5</guid><pubDate>Sun, 11 Jul 2010 17:31:35 GMT</pubDate></item><item><title>Thomas Eyde commented on Find the issue</title><description>You found out that you wanted a set, not a dictionary?
  
  
More specifically, deleting a non existing item can be considered already deleted, adding an existing item can be considered as an overwrite, and retrieving a non existing item could return null.
  
  
I am not sure about the last one, but add and delete in this fashion should not throw. 
</description><link>http://ayende.com/4553/find-the-issue#comment4</link><guid>http://ayende.com/4553/find-the-issue#comment4</guid><pubDate>Sun, 11 Jul 2010 11:52:09 GMT</pubDate></item><item><title>Kristof Claes commented on Find the issue</title><description>Did it have something to do with the fact that before you add an item, you have to check if it already exists or not and trying to get an unregistered item throws an exeption?
</description><link>http://ayende.com/4553/find-the-issue#comment3</link><guid>http://ayende.com/4553/find-the-issue#comment3</guid><pubDate>Sun, 11 Jul 2010 09:05:11 GMT</pubDate></item><item><title>Anon commented on Find the issue</title><description>Issue is very simple. I am annoyed with you because you have not posted anything for 9 days. I hope all is well, but I'm annoyed anyway.
</description><link>http://ayende.com/4553/find-the-issue#comment2</link><guid>http://ayende.com/4553/find-the-issue#comment2</guid><pubDate>Sun, 11 Jul 2010 08:32:06 GMT</pubDate></item><item><title>Ryan Schipper commented on Find the issue</title><description>A couple of things that need consideration in my opinion.
  
  
1) in my opinion it is inappropriate to force your API consumer to use exception handlers for normal process flow as demonstrated in the first few tests
  
  
2) a dictionary is a reasonably established paradigm and standard practice (at least where I come from) would suggest that the add function should be add(key, value). Instead, you have an explicitly required container class.
  
  
One of these may even be what you are thinking of..
</description><link>http://ayende.com/4553/find-the-issue#comment1</link><guid>http://ayende.com/4553/find-the-issue#comment1</guid><pubDate>Sun, 11 Jul 2010 07:52:14 GMT</pubDate></item></channel></rss>