From a6fe8b276b8f4618dde67f1226c3a82d4e3a464f Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Sat, 4 Jun 2011 10:59:09 -0700 Subject: [PATCH] minor updates to test project --- NzbDrone.Core.Test/App.config | 4 ++ NzbDrone.Core.Test/Framework/MockLib.cs | 7 ++- NzbDrone.Core.Test/RepoTest.cs | 60 ++++++++++++++----------- 3 files changed, 43 insertions(+), 28 deletions(-) diff --git a/NzbDrone.Core.Test/App.config b/NzbDrone.Core.Test/App.config index a67132955..6e63be8ce 100644 --- a/NzbDrone.Core.Test/App.config +++ b/NzbDrone.Core.Test/App.config @@ -1,5 +1,9 @@  + + + + diff --git a/NzbDrone.Core.Test/Framework/MockLib.cs b/NzbDrone.Core.Test/Framework/MockLib.cs index 91d316551..08e9aba04 100644 --- a/NzbDrone.Core.Test/Framework/MockLib.cs +++ b/NzbDrone.Core.Test/Framework/MockLib.cs @@ -44,12 +44,15 @@ namespace NzbDrone.Core.Test.Framework Console.WriteLine("Creating an empty SQLite database"); var provider = ProviderFactory.GetProvider("Data Source=" + Guid.NewGuid() + ".db;Version=3;New=True", "System.Data.SQLite"); + + var repo = new SimpleRepository(provider, SimpleRepositoryOptions.RunMigrations); + ForceMigration(repo); + if (enableLogging) { provider.Log = new NlogWriter(); } - var repo = new SimpleRepository(provider, SimpleRepositoryOptions.RunMigrations); - ForceMigration(repo); + return repo; } diff --git a/NzbDrone.Core.Test/RepoTest.cs b/NzbDrone.Core.Test/RepoTest.cs index ba5470f35..55852a919 100644 --- a/NzbDrone.Core.Test/RepoTest.cs +++ b/NzbDrone.Core.Test/RepoTest.cs @@ -25,7 +25,7 @@ namespace NzbDrone.Core.Test var fakeEpisode = Builder.CreateNew().With(c => c.SeriesId = 69).Build(); //Act - var repo = MockLib.GetEmptyRepository(); + var repo = MockLib.GetEmptyRepository(true); repo.Add(fakeSeries); repo.Add(fakeEpisode); var fetchedSeries = repo.Single(fakeSeries.SeriesId); @@ -42,32 +42,40 @@ namespace NzbDrone.Core.Test } [Test] - public void ToString_test_over_castle_proxy() + [Ignore] + public void query_scratch_pad() { - //Arrange - var fakeSeries = Builder.CreateNew().With(s => s.SeriesId = 69).Build(); - var fakeEpisode = Builder.CreateNew().With(c => c.SeriesId = 69).Build(); - //Act var repo = MockLib.GetEmptyRepository(true); - repo.Add(fakeSeries); - repo.Add(fakeEpisode); - Console.WriteLine("Getting single"); - var fetchedEpisode = repo.Single(fakeEpisode.EpisodeId); + + repo.All().Where(e => !e.Ignored && e.AirDate <= DateTime.Today && e.AirDate.Year > 1900).Select( + s => s.Title).ToList(); + } + + + [Test] + [Ignore] + public void episode_proxy_to_string() + { + var episode = Builder.CreateNew() + .Build(); + var series = Builder.CreateNew() + .With(s => s.SeriesId = episode.SeriesId) + .Build(); + + var repo = MockLib.GetEmptyRepository(true); + repo.Add(episode); + repo.Add(series); + + //Act + + var result = repo.Single(episode.EpisodeId).ToString(); //Assert - Console.WriteLine("Doing assert"); - Assert.AreEqual(fakeEpisode.EpisodeId, fetchedEpisode.EpisodeId); - Console.WriteLine("Doing assert"); - Assert.AreEqual(fakeEpisode.Title, fetchedEpisode.Title); - - Console.WriteLine("======================="); - var ttt = fetchedEpisode.Series; - Console.WriteLine("======================="); - var tttd = fetchedEpisode.Series; - Console.WriteLine("======================="); - - //Assert.Contains(fetchedEpisode.ToString(), fakeSeries.Title); + Console.WriteLine(result); + result.Should().Contain(series.Title); + result.Should().Contain(episode.EpisodeNumber.ToString()); + result.Should().Contain(episode.SeasonNumber.ToString()); } @@ -78,7 +86,7 @@ namespace NzbDrone.Core.Test public void tvdbid_is_preserved() { //Arrange - var sonicRepo = MockLib.GetEmptyRepository(); + var sonicRepo = MockLib.GetEmptyRepository(true); var series = Builder.CreateNew().With(c => c.SeriesId = 18).Build(); //Act @@ -105,7 +113,7 @@ namespace NzbDrone.Core.Test //setup var message = Guid.NewGuid().ToString(); - var sonicRepo = MockLib.GetEmptyRepository(); + var sonicRepo = MockLib.GetEmptyRepository(true); var sonicTarget = new SubsonicTarget(sonicRepo); @@ -138,7 +146,7 @@ namespace NzbDrone.Core.Test //setup var message = Guid.NewGuid().ToString(); - var sonicRepo = MockLib.GetEmptyRepository(); + var sonicRepo = MockLib.GetEmptyRepository(true); var sonicTarget = new SubsonicTarget(sonicRepo); LogManager.Configuration.AddTarget("DbLogger", sonicTarget); @@ -171,7 +179,7 @@ namespace NzbDrone.Core.Test //setup var message = String.Empty; - var sonicRepo = MockLib.GetEmptyRepository(); + var sonicRepo = MockLib.GetEmptyRepository(true); var sonicTarget = new SubsonicTarget(sonicRepo); LogManager.Configuration.AddTarget("DbLogger", sonicTarget);