public async Task Can_Load_In_Descending_order()
        {
            var LowestUsedWord  = WordsDictionary.First().Key;
            var HighestUsedWord = WordsDictionary.Last().Key;

            using (var context = TestsHelper.CreateInMemoryDbContext())
            {
                var repository = new WordDictionaryRepository(context, TestsHelper.HasingProvider, TestsHelper.EncryptionProvider);

                await repository.SaveWordsAsync(WordsDictionary);

                var result = repository.GetAll();

                Assert.Equal(result.First().Key, HighestUsedWord);
                Assert.Equal(result.Last().Key, LowestUsedWord);
            }
        }
Ejemplo n.º 2
0
        public void TestsDictionaryMergingStringArrays()
        {
            Dictionary <string, object> dict1 = new Dictionary <string, object>();

            string[] array1 = { "a", "b", "c" };
            dict1.Add("a", array1);

            Dictionary <string, object> dict2 = new Dictionary <string, object>();

            string[] array2 = { "1", "2", "3" };
            dict2.Add("a", array2);

            Dictionary <string, object> dict1Cleaned = Utils.Sanitized(dict1);
            Dictionary <string, object> dict2Cleaned = Utils.Sanitized(dict2);

            Dictionary <string, object> dictFinal    = Utils.MergeDictionary(dict1Cleaned, dict2Cleaned);
            Dictionary <string, object> expectedDict = new Dictionary <string, object>();

            string[] arrayExpected = { "1", "2", "3" };
            expectedDict.Add("a", arrayExpected);

            string dict2String = "";

            foreach (KeyValuePair <string, object> kvp in dict2)
            {
                dict2String += string.Format("\n\tKey = {0}, Value = {1}", kvp.Key, kvp.Value);
            }
            string dictFinalString = "";

            foreach (KeyValuePair <string, object> kvp in dictFinal)
            {
                dictFinalString += string.Format("\n\tKey = {0}, Value = {1}", kvp.Key, kvp.Value);
            }
            string expectedDictString = "";

            foreach (KeyValuePair <string, object> kvp in expectedDict)
            {
                expectedDictString += string.Format("\n\tKey = {0}, Value = {1}", kvp.Key, kvp.Value);
            }

            bool areEqual = TestsHelper.AreDictionariesEqual(expectedDict, dict2);

            Assert.True(areEqual == true, "Unexpected dictionary returned: " + dict2String + "\nexpectedDict:" + expectedDictString);
        }