Beispiel #1
0
        public void SerializeTest()
        {
            var entity = SimpleEntityMock.CreateDefault();

            var expected = "{\"<Id>k__BackingField\":1,\"<Name>k__BackingField\":\"Test Entity\"}";
            var actual   = _serializer.Serialize(entity);

            Assert.AreEqual(expected, actual);
        }
Beispiel #2
0
        public void DeserializeTest()
        {
            var expected = SimpleEntityMock.CreateDefault();

            var entity = "{\"<Id>k__BackingField\":1,\"<Name>k__BackingField\":\"Test Entity\"}";
            var actual = _serializer.Deserialize <SimpleEntityMock>(entity);

            Assert.AreEqual(expected.Id, actual.Id);
            Assert.AreEqual(expected.Name, actual.Name);
        }
        public void SerializeTest()
        {
            var entity = SimpleEntityMock.CreateDefault();

            var expected = @"<SimpleEntityMock xmlns=""http://schemas.datacontract.org/2004/07/wslyvh.Core.Test.Mock"" " +
                           @"xmlns:i=""http://www.w3.org/2001/XMLSchema-instance"">" +
                           "<_x003C_Id_x003E_k__BackingField>1</_x003C_Id_x003E_k__BackingField>" +
                           "<_x003C_Name_x003E_k__BackingField>Test Entity</_x003C_Name_x003E_k__BackingField>" +
                           "</SimpleEntityMock>";
            var actual = _serializer.Serialize(entity);

            Assert.AreEqual(expected, actual);
        }
Beispiel #4
0
        public void SerializeTest()
        {
            var entity = SimpleEntityMock.CreateDefault();

            var expected = @"<?xml version=""1.0"" encoding=""utf-8""?>" +
                           "<SimpleEntityMock>" +
                           "<Id>1</Id>" +
                           "<Name>Test Entity</Name>" +
                           "</SimpleEntityMock>";
            var actual = _serializer.Serialize(entity);

            Assert.AreEqual(expected, actual);
        }
Beispiel #5
0
        public void DeserializeTest()
        {
            var expected = SimpleEntityMock.CreateDefault();

            var entity = @"<SimpleEntityMock>" +
                         "<Id>1</Id>" +
                         "<Name>Test Entity</Name>" +
                         "</SimpleEntityMock>";
            var actual = _serializer.Deserialize <SimpleEntityMock>(entity);

            Assert.AreEqual(expected.Id, actual.Id);
            Assert.AreEqual(expected.Name, actual.Name);
        }
        public void HttpRuntimeCachingInsertTest()
        {
            var id       = new Random().Next(0, 1000);
            var expected = new SimpleEntityMock()
            {
                Id   = id,
                Name = "Caching Entity"
            };
            var cacheKey = string.Format("UnitTests::simple.cache.entity_{0}", id);
            var actual   = _cachingProvider.Insert(cacheKey, expected);

            Assert.AreEqual(expected, actual);
            _cachingProvider.Remove(cacheKey);
        }
        public void HttpRuntimeCachingContainsTrueTest()
        {
            var cacheKey = "UnitTests::simple.cache.entity";
            var entity   = new SimpleEntityMock()
            {
                Id   = 1,
                Name = "Caching Entity"
            };

            _cachingProvider.Insert(cacheKey, entity);

            var actual = _cachingProvider.Contains(cacheKey);

            Assert.AreEqual(true, actual);
            _cachingProvider.Remove(cacheKey);
        }
        public void HttpRuntimeCachingRetrieveFlushTest()
        {
            var cacheKey = "UnitTests::simple.cache.entity";
            var entity   = new SimpleEntityMock {
                Id = 1, Name = "Caching Entity"
            };

            _cachingProvider.Insert(cacheKey, entity);
            var actual = _cachingProvider.Contains(cacheKey);

            Assert.AreEqual(true, actual);

            _cachingProvider.Flush();

            actual = _cachingProvider.Contains(cacheKey);
            Assert.AreEqual(false, actual);
        }
        public void HttpRuntimeCachingRetrieveFuncExistingTest()
        {
            var id       = new Random().Next(0, 1000);
            var expected = new SimpleEntityMock()
            {
                Id   = id,
                Name = "Caching Entity"
            };
            var cacheKey = string.Format("UnitTests::simple.cache.entity.Func_{0}", id);

            _cachingProvider.Insert(cacheKey, expected);

            var actual = _cachingProvider.Retrieve(cacheKey, new TimeSpan(1, 0, 0, 0), () => GetSimpleEntity(id));

            Assert.AreSame(expected, actual);
            _cachingProvider.Remove(cacheKey);
        }
        public void HttpRuntimeCachingRemoveRegexTest()
        {
            var cacheKey = "UnitTests::simple.cache.entity";
            var entity   = new SimpleEntityMock {
                Id = 1, Name = "Caching Entity"
            };

            _cachingProvider.Insert(cacheKey, entity);
            var actual = _cachingProvider.Contains(cacheKey);

            Assert.AreEqual(true, actual);

            var regex = new Regex("UnitTests::", RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.Compiled);

            _cachingProvider.Remove(regex);
            actual = _cachingProvider.Contains(cacheKey);

            Assert.AreEqual(false, actual);
        }