using System; using System.Linq; using FluentAssertions; using NUnit.Framework; using NzbDrone.Common; using NzbDrone.Core.Notifications.Xbmc; using NzbDrone.Core.Test.Framework; namespace NzbDrone.Core.Test.NotificationTests.Xbmc.Http { [TestFixture] public class ActivePlayersFixture : CoreTest { private XbmcSettings _settings; private string _expectedUrl; private void WithNoActivePlayers() { Mocker.GetMock() .Setup(s => s.DownloadString(_expectedUrl, _settings.Username, _settings.Password)) .Returns("
  • Filename:[Nothing Playing]"); } private void WithVideoPlayerActive() { var activePlayers = @"
  • Filename:C:\Test\TV\2 Broke Girls\Season 01\2 Broke Girls - S01E01 - Pilot [SDTV].avi" + "
  • PlayStatus:Playing
  • VideoNo:0
  • Type:Video
  • Thumb:special://masterprofile/Thumbnails/Video/a/auto-a664d5a2.tbn" + "
  • Time:00:06
  • Duration:21:35
  • Percentage:0
  • File size:183182590
  • Changed:True"; Mocker.GetMock() .Setup(s => s.DownloadString(_expectedUrl, _settings.Username, _settings.Password)) .Returns(activePlayers); } [SetUp] public void Setup() { _settings = new XbmcSettings { Host = "localhost", Port = 8080, Username = "xbmc", Password = "xbmc", AlwaysUpdate = false, CleanLibrary = false, UpdateLibrary = true }; _expectedUrl = String.Format("http://{0}/xbmcCmds/xbmcHttp?command={1}", _settings.Address, "getcurrentlyplaying"); } [Test] public void _should_be_empty_when_no_active_players() { WithNoActivePlayers(); Subject.GetActivePlayers(_settings).Should().BeEmpty(); } [Test] public void should_have_active_video_player() { WithVideoPlayerActive(); var result = Subject.GetActivePlayers(_settings); result.Should().HaveCount(1); result.First().Type.Should().Be("video"); } } }