Esempio n. 1
0
        public void Get(string key, object val)
        {
            var dictionary  = new Dictionary <string, string>();
            var watcherMock = new Mock <IWatcher>();

            watcherMock.Setup(m => m.Properties)
            .Returns(dictionary);
            var timeWatcherMock = new Mock <ITimeWatcher>();


            timeWatcherMock.Setup(r => r.StartWatcher(It.IsAny <string>(), It.IsAny <bool>()))
            .Callback(() => dictionary.Clear())
            .Returns(() => watcherMock.Object);

            var obj = new RepositoryCache();

            Assert.IsNotNull(obj);
            obj.Set(timeWatcherMock.Object, key, val);

            var result = obj.Get <object>(timeWatcherMock.Object, key);

            timeWatcherMock.Verify(foo => foo.StartWatcher("RepositoryCache.Get", It.IsAny <bool>()), Times.Once());
            Assert.AreEqual(val, result);
        }