示例#1
0
        public void Constructor_KeyPropertyIsNull_ThrowsException()
        {
            //Arrange
            Func <ITestObject, int> keyProperty = null;

            //Act
            var result = new PicnicCache <int, ITestObject>(keyProperty, _mockCacheable.Object);
        }
示例#2
0
        public void Constructor_KeyPropertyNameIsNull_ThrowsException()
        {
            //Arrange
            string keyPropertyName = null;

            //Act
            var result = new PicnicCache <int, ITestObject>(keyPropertyName, _mockCacheable.Object);
        }
示例#3
0
        public void Update_NullKeyPassed_ThrowsException()
        {
            //Arrange
            var    cache = new PicnicCache <string, ITestObject>(x => x.Name, new Mock <ICacheable <string, ITestObject> >().Object);
            string key   = null;

            //Act
            cache.Update(key, new object(), new Mock <Func <object, ITestObject, ITestObject> >().Object);
        }
示例#4
0
        public void Delete_NullKeyIsPassed_ThrowsException()
        {
            //Arrange
            var    cache = new PicnicCache <string, ITestObject>(x => x.Name, new Mock <ICacheable <string, ITestObject> >().Object);
            string key   = null;

            //Act
            cache.Delete(key);
        }
示例#5
0
        public void Constructor_ValidKeyPropertyName_FetchWorks()
        {
            //Arrange
            var cache = new PicnicCache <int, ITestObject>("Id", _mockCacheable.Object);
            var item  = GetTestList(1).First();

            _mockCacheable.Setup(c => c.Fetch(1)).Returns(item);

            //Act
            var result = cache.Fetch(1);

            //Assert
            Assert.AreEqual(item, result);
        }
示例#6
0
 public void Constructor_CacheableIsNull_ThrowsException()
 {
     //Act
     var result = new PicnicCache <int, ITestObject>("Test", null);
 }
示例#7
0
 public void Constructor_InvalidKeyPropertyName_ThrowsException()
 {
     //Act
     var result = new PicnicCache <int, ITestObject>("Test", _mockCacheable.Object);
 }