public void AddNewSitcom() { string name = "foo"; string fileName = "fooFile"; Sitcom sitcom = null; _EpisodeParserMock.Setup(e => e.Parse(It.Is <string>(s => s == fileName))).Returns(_Episodes); _SitcomRepository.Setup(r => r.Add(It.IsAny <Sitcom>())).Callback((Sitcom s) => { sitcom = s; }); _SitcomManager.Add(name, null, fileName); _SitcomRepository.Verify(r => r.Add(It.Is <Sitcom>(s => s.Name == name))); Assert.IsNotNull(sitcom); Assert.AreEqual(0, _Episodes.Except(sitcom.Episodes).Count()); Assert.AreEqual(0, sitcom.Episodes.Except(_Episodes).Count()); }
public void AddNewSeasonToSitcom_SpecifySeason() { string name = "foo"; string fileName = "fooFile"; int seasonNumber = 5; Sitcom sitcom = new Sitcom() { Name = name }; _EpisodeParserMock.Setup(e => e.Parse(It.Is <string>(s => s == fileName))).Returns(_Episodes); _SitcomRepository.Setup(r => r.Find(It.IsAny <PredicateType>())).Returns(new List <Sitcom>() { sitcom }); _SitcomManager.Add(name, seasonNumber, fileName); _SitcomRepository.Verify(r => r.Add(It.Is <Sitcom>(s => s.Name == name)), Times.Never); Assert.IsTrue(sitcom.Episodes.Select(e => e.Season).All(s => s == seasonNumber)); }
public void AddNewSeasonToSitcom() { string name = "foo"; string fileName = "fooFile"; Sitcom sitcom = new Sitcom() { Name = name }; _EpisodeParserMock.Setup(e => e.Parse(It.Is <string>(s => s == fileName))).Returns(_Episodes); _SitcomRepository.Setup(r => r.Find(It.IsAny <PredicateType>())).Returns(new List <Sitcom>() { sitcom }); _SitcomManager.Add(name, null, fileName); _SitcomRepository.Verify(r => r.Add(It.Is <Sitcom>(s => s.Name == name)), Times.Never); Assert.AreEqual(0, _Episodes.Except(sitcom.Episodes).Count()); Assert.AreEqual(0, sitcom.Episodes.Except(_Episodes).Count()); Assert.IsTrue(sitcom.Episodes.Select(e => e.Season).All(s => s == 1)); // Check that sitcomManger didn't changed defualt season number }
public void Add(string name, int?season, string sourceFile) { var parser = new EpisodeParsers.IMDBEpisodeParser(); var episodes = _EpisodeParser.Parse(sourceFile); var sitcom = _UnitOfWork.SitcomRepository.Find(s => s.Name == name).SingleOrDefault(); if (sitcom == null) { sitcom = new Sitcom() { Name = name }; _UnitOfWork.SitcomRepository.Add(sitcom); } foreach (var episode in episodes) { episode.Season = season ?? episode.Season; sitcom.Episodes.Add(episode); } _UnitOfWork.Complete(); }
private static void PlaySitcom() { var s = new Sitcom(); s.PlaySitcomDelegate((string s) => { Console.WriteLine(s); }); }