[longomatch] Fix retrieve from file storage with filters



commit 3f83ef9ad1e8cc9ad08ae6ce768b99a8fa7e48dd
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Tue Mar 31 18:41:08 2015 +0200

    Fix retrieve from file storage with filters

 LongoMatch.Services/Services/FileStorage.cs |    4 ++--
 Tests/Services/TestFileStorage.cs           |   18 +++++++++++++++++-
 2 files changed, 19 insertions(+), 3 deletions(-)
---
diff --git a/LongoMatch.Services/Services/FileStorage.cs b/LongoMatch.Services/Services/FileStorage.cs
index adb772c..cdf7d3a 100644
--- a/LongoMatch.Services/Services/FileStorage.cs
+++ b/LongoMatch.Services/Services/FileStorage.cs
@@ -165,8 +165,8 @@ namespace LongoMatch.Services.Services
                                        }
 
                                        if (ret.GetType () == entry.Value.GetType ()) {
-                                               if (Object.Equals (ret, entry.Value)) {
-                                                       matches = true;
+                                               if (!Object.Equals (ret, entry.Value)) {
+                                                       matches = false;
                                                }
                                        }
                                }
diff --git a/Tests/Services/TestFileStorage.cs b/Tests/Services/TestFileStorage.cs
index d840453..8f8252f 100644
--- a/Tests/Services/TestFileStorage.cs
+++ b/Tests/Services/TestFileStorage.cs
@@ -105,7 +105,23 @@ namespace Tests.Services
                        Assert.IsNotNull (ts2);
                        Assert.AreEqual (ts1.ID, ts2.ID);
 
-                       Assert.IsNull (fs.Retrieve<TestStorable> (Guid.NewGuid()));
+                       Assert.IsNull (fs.Retrieve<TestStorable> (Guid.NewGuid ()));
+               }
+
+               [Test ()]
+               public void TestRetrieveFiltered ()
+               {
+                       TestStorable ts1 = new TestStorable ("first");
+                       fs.Store<TestStorable> (ts1);
+
+                       /* Test with a dictionary combination that exists */
+                       Dictionary<string, object> dict = new Dictionary<string, object> ();
+                       dict.Add ("memberString", "first");
+                       Assert.AreEqual (1, fs.Retrieve<TestStorable> (dict).Count);
+
+                       /* Test with a dictionary combination that doesn't exist */
+                       dict ["memberString"] = "second";
+                       Assert.AreEqual (0, fs.Retrieve<TestStorable> (dict).Count);
                }
        }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]