Exemple #1
0
        public void ShouldCacheShowNameAfterFind()
        {
            var deserializer     = repository.Stub <SubtitleServiceResponseDeserializer>();
            var bierdopjeService = repository.Stub <IBierdopje>();
            var logger           = repository.Stub <ILogger>();

            const string ShowName = "Lie To Me";
            const int    ShowId   = 50;

            var showNameCache = repository.StrictMock <ShowNameCache>(new object[] { null, null });

            using (repository.Record())
            {
                deserializer.Expect(d => d.GetTvShows(string.Empty)).IgnoreArguments().Return(
                    new List <TvShow>()
                {
                    new TvShow {
                        id = ShowId, showName = ShowName
                    }
                });

                int outShowId;
                showNameCache.Expect(s => s.TryGetShowId(ShowName, out outShowId)).Return(false);
                showNameCache.Expect(s => s.Add(ShowName, ShowId));
                showNameCache.Expect(s => s.Save());
            }

            using (repository.Playback())
            {
                var showService = new ShowService(deserializer, bierdopjeService, showNameCache, logger);
                showService.FindShowByName(ShowName);
            }
        }