コード例 #1
0
        public void TestData()
        {
            const string DATA = "Data to be intercepted";

            var byteStreamData = new ByteStreamData {
                Id = "data", Data = DATA
            };

            _databaseInstance.RegisterInterceptor <ByteInterceptor>();
            _databaseInstance.RegisterInterceptor <ByteInterceptor2>();

            _databaseInstance.SaveAsync(byteStreamData).Wait();

            var loadedByteStreamData = _databaseInstance.LoadAsync <ByteStreamData>("data").Result;

            Assert.AreEqual(DATA, loadedByteStreamData.Data, "Byte interceptor test failed: data does not match");

            _databaseInstance.UnRegisterInterceptor <ByteInterceptor2>();

            try
            {
                loadedByteStreamData = _databaseInstance.LoadAsync <ByteStreamData>("data").Result;
            }
            catch
            {
                loadedByteStreamData = null;
            }

            Assert.IsTrue(loadedByteStreamData == null || !(DATA.Equals(loadedByteStreamData.Data)),
                          "Byte interceptor test failed: Sterling deserialized intercepted data without interceptor.");

            _databaseInstance.RegisterInterceptor <ByteInterceptor2>();

            loadedByteStreamData = _databaseInstance.LoadAsync <ByteStreamData>("data").Result;

            Assert.AreEqual(DATA, loadedByteStreamData.Data, "Byte interceptor test failed: data does not match");
        }
コード例 #2
0
        public void TestData()
        {
            const string DATA = "Data to be intercepted";

            var byteStreamData = new ByteStreamData {Id = "data", Data = DATA};

            _databaseInstance.RegisterInterceptor<ByteInterceptor>();
            _databaseInstance.RegisterInterceptor<ByteInterceptor2>();

            _databaseInstance.SaveAsync( byteStreamData ).Wait();

            var loadedByteStreamData = _databaseInstance.LoadAsync<ByteStreamData>( "data" ).Result;

            Assert.AreEqual(DATA, loadedByteStreamData.Data, "Byte interceptor test failed: data does not match");

            _databaseInstance.UnRegisterInterceptor<ByteInterceptor2>();

            try
            {
                loadedByteStreamData = _databaseInstance.LoadAsync<ByteStreamData>( "data" ).Result;
            }
            catch
            {
                loadedByteStreamData = null;
            }

            Assert.IsTrue(loadedByteStreamData == null || !(DATA.Equals(loadedByteStreamData.Data)), 
                "Byte interceptor test failed: Sterling deserialized intercepted data without interceptor.");

            _databaseInstance.RegisterInterceptor<ByteInterceptor2>();

            loadedByteStreamData = _databaseInstance.LoadAsync<ByteStreamData>( "data" ).Result;

            Assert.AreEqual(DATA, loadedByteStreamData.Data, "Byte interceptor test failed: data does not match");
        }