public void EquivalentTo_Dictionary_Ordered()
        {
            var a = new Dictionary <string, int>
            {
                { "A", 1 },
                { "B", 2 },
                { "C", 3 },
            };
            var b = new ConcurrentDictionary <string, int>();

            b["A"] = 1;
            b["B"] = 2;
            b["C"] = 3;

            Assert.That(a.EquivalentTo(b));
        }
        public void EquivalentTo_Dictionary_Unordered()
        {
            var a = new Dictionary <string, int>
            {
                { "A", 1 },
                { "B", 2 },
                { "C", 3 },
            };
            var b = new Dictionary <string, int>
            {
                { "C", 3 },
                { "A", 1 },
                { "B", 2 },
            };

            Assert.That(a.EquivalentTo(b));
        }
Example #3
0
        public void Can_IncrementItemInSortedSet()
        {
            stringDoubleMap.ForEach(x => Redis.AddItemToSortedSet(SetId, x.Key, x.Value));

            var currentScore = Redis.IncrementItemInSortedSet(SetId, "one", 2);

            stringDoubleMap["one"] = stringDoubleMap["one"] + 2;
            Assert.That(currentScore, Is.EqualTo(stringDoubleMap["one"]));

            currentScore            = Redis.IncrementItemInSortedSet(SetId, "four", -2);
            stringDoubleMap["four"] = stringDoubleMap["four"] - 2;
            Assert.That(currentScore, Is.EqualTo(stringDoubleMap["four"]));

            var map = Redis.GetAllWithScoresFromSortedSet(SetId);

            Assert.That(stringDoubleMap.EquivalentTo(map));
            Debug.WriteLine(map.Dump());
        }
        public void Can_serialize_ModelWithFieldsOfDifferentTypes_to_StringDictionary()
        {
            var model = new ModelWithFieldsOfDifferentTypes
            {
                Id       = 1,
                Name     = "Name1",
                LongId   = 1000,
                Guid     = new Guid("{7da74353-a40c-468e-93aa-7ff51f4f0e84}"),
                Bool     = false,
                DateTime = new DateTime(2010, 12, 20),
                Double   = 2.11d,
            };

            Console.WriteLine(model.Dump());

            /* Prints out:
             *      {
             *              Id: 1,
             *              Name: Name1,
             *              LongId: 1000,
             *              Guid: 7da74353a40c468e93aa7ff51f4f0e84,
             *              Bool: False,
             *              DateTime: 2010-12-20,
             *              Double: 2.11
             *      }
             */

            Dictionary <string, string> map = model.ToStringDictionary();

            Assert.That(map.EquivalentTo(
                            new Dictionary <string, string>
            {
                { "Id", "1" },
                { "Name", "Name1" },
                { "LongId", "1000" },
                { "Guid", "7da74353a40c468e93aa7ff51f4f0e84" },
                { "Bool", "False" },
                { "DateTime", "2010-12-20" },
                { "Double", "2.11" },
            }));
        }
	    public void EquivalentTo_Dictionary_Ordered()
	    {
            var a = new Dictionary<string, int>
            {
                {"A",1},
                {"B",2},
                {"C",3},
            };
	        var b = new ConcurrentDictionary<string, int>();
	        b["A"] = 1;
	        b["B"] = 2;
	        b["C"] = 3;

            Assert.That(a.EquivalentTo(b));
	    }
        public void EquivalentTo_Dictionary_Unordered()
        {
            var a = new Dictionary<string, int>
            {
                {"A",1},
                {"B",2},
                {"C",3},
            };
            var b = new Dictionary<string, int>
            {
                {"C",3},
                {"A",1},
                {"B",2},
            };

            Assert.That(a.EquivalentTo(b));
        }