private ShowNameCache CreateShowNameCache()
        {
            var fileRepository     = mockRepository.Stub <IFileRepository>();
            var cacheSerialization = mockRepository.Stub <ICacheSerializer>();
            var showIdCache        = new ShowNameCache(fileRepository, cacheSerialization);

            return(showIdCache);
        }
        public void ShouldSerializeCacheOnSave()
        {
            var fileRepository     = mockRepository.Stub <IFileRepository>();
            var cacheSerialization = mockRepository.StrictMock <ICacheSerializer>();

            using (mockRepository.Record())
            {
                cacheSerialization.Expect(c => c.Serialize(dummyCache)).Return(string.Empty).IgnoreArguments();
            }

            using (mockRepository.Playback())
            {
                var showNameCache = new ShowNameCache(fileRepository, cacheSerialization);
                showNameCache.Save();
            }
        }
        public void ShouldDeserializeCacheOnInitialize()
        {
            var fileRepository     = mockRepository.Stub <IFileRepository>();
            var cacheSerialization = mockRepository.StrictMock <ICacheSerializer>();

            using (mockRepository.Record())
            {
                cacheSerialization.Expect(s => s.Deserialize(DummyContents)).IgnoreArguments().Return(dummyCache);
            }

            using (mockRepository.Playback())
            {
                var showNameCache = new ShowNameCache(fileRepository, cacheSerialization);
                showNameCache.Initialize();
            }
        }
        public void ShouldInitializeCacheByReadingFile()
        {
            var fileRepository  = mockRepository.StrictMock <IFileRepository>();
            var cacheSerializer = mockRepository.Stub <ICacheSerializer>();

            using (mockRepository.Record())
            {
                fileRepository.Expect(r => r.ReadFile(DummyFileName)).IgnoreArguments().Return(DummyContents);
            }

            using (mockRepository.Playback())
            {
                var showNameCache = new ShowNameCache(fileRepository, cacheSerializer);
                showNameCache.Initialize();
            }
        }
        public void ShouldSaveCacheContentsToFileSystemOnSave()
        {
            var fileRepository     = mockRepository.StrictMock <IFileRepository>();
            var cacheSerialization = mockRepository.Stub <ICacheSerializer>();

            using (mockRepository.Record())
            {
                cacheSerialization.Stub(c => c.Serialize(dummyCache)).IgnoreArguments().Return(DummyContents);
                fileRepository.Expect(f => f.SaveFile(DummyContents, DummyFileName)).IgnoreArguments();
            }

            using (mockRepository.Playback())
            {
                var showNameCache = new ShowNameCache(fileRepository, cacheSerialization);
                showNameCache.Save();
            }
        }