Example #1
0
        public void TestGenericStructAndPersistenBlobDictionary()
        {
            try
            {
                using (var dictionary = new PersistentDictionary <int, ContainingStruct>(DictionaryPath))
                {
                    var blob       = new PersistentBlob(new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });
                    var nestedBlob = new ContainingStruct()
                    {
                        Key = 3, Blob = blob,
                    };

                    RunDictionaryTests(dictionary, 1, nestedBlob);
                    RunDictionaryTests(dictionary, 2, new ContainingStruct());
                    RunDictionaryTests(dictionary,
                                       3,
                                       new ContainingStruct()
                    {
                        Key = 4, Blob = new PersistentBlob(new byte[0])
                    });
                }
            }
            catch (ArgumentOutOfRangeException ex)
            {
                var expectedMessage = (new ArgumentOutOfRangeException("TColumn", typeof(ContainingStruct), "Not supported for SetColumn")).Message;
                Assert.AreEqual(expectedMessage, ex.Message);
            }
        }
        public void TestGenericStructAndPersistenBlobDictionary()
        {
            try
            {
                using (var dictionary = new PersistentDictionary <int, ContainingStruct>(DictionaryPath))
                {
                    var blob       = new PersistentBlob(new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 });
                    var nestedBlob = new ContainingStruct()
                    {
                        Key = 3, Blob = blob,
                    };

                    RunDictionaryTests(dictionary, 1, nestedBlob);
                    RunDictionaryTests(dictionary, 2, new ContainingStruct());
                    RunDictionaryTests(dictionary,
                                       3,
                                       new ContainingStruct()
                    {
                        Key = 4, Blob = new PersistentBlob(new byte[0])
                    });
                }
            }
            catch (ArgumentOutOfRangeException ex)
            {
#if NETCOREAPP3_0
                Assert.AreEqual("Not supported for SetColumn (Parameter 'TColumn')\r\nActual value was EsentCollectionsTests.GenericDictionaryTests+ContainingStruct.", ex.Message);
#else
                Assert.AreEqual("Not supported for SetColumn\r\nParameter name: TColumn\r\nActual value was EsentCollectionsTests.GenericDictionaryTests+ContainingStruct.", ex.Message);
#endif
            }
        }