Exemplo n.º 1
0
 public void BackgroundListensForModelDispositionTest()
 {
     var container = new Athena.IoC.Container();
     string path = "myartpath";
     var persister = Substitute.For<IPersister<UserConfiguration>>();
     container.Register<IPersister<UserConfiguration>>().To(persister);
     persister.SelectBy(Arg.Any<int>()).Returns(new UserConfiguration { ServerUrl = string.Empty });
     var target = new BackgroundHandle(null, path, null, new AmpacheModel(), container);
     target.Start(new MemoryStream());
     target.Model.Dispose();
     Assert.That(target.FinalizedCalled, Is.True);
 }
Exemplo n.º 2
0
 public void BackgroundListensForConfigChangesTest()
 {
     var container = new Athena.IoC.Container();
     string path = "myartpath";
     var persister = Substitute.For<IPersister<UserConfiguration>>();
     container.Register<IPersister<UserConfiguration>>().To(persister);
     bool persisted = false;
     var config = new UserConfiguration();
     persister.When(x => x.Persist(config)).Do(p => persisted = true);
     var target = new BackgroundHandle(null, path, new AmpacheModel(), container);
     target.Start(new MemoryStream());
     System.Threading.Thread.Sleep(100);
     target.Model.Configuration = config;
     Assert.That(persisted, Is.True);
 }
Exemplo n.º 3
0
 public void BackgroundListensForPlayingChangesAndStartsShutOffTest()
 {
     var container = new Athena.IoC.Container();
     string path = "myartpath";
     var persister = Substitute.For<IPersister<UserConfiguration>>();
     container.Register<IPersister<UserConfiguration>>().To(persister);
     persister.SelectBy(Arg.Any<int>()).Returns(new UserConfiguration { ServerUrl = string.Empty });
     var target = new BackgroundHandle(null, path, new AmpacheModel(), container);
     target.Start(new MemoryStream());
     System.Threading.Thread.Sleep(100);
     target.Model.IsPlaying = true;
     Assert.That(target.StopShutOffCallCount, Is.EqualTo(1));
     target.Model.IsPlaying = false;
     Assert.That(target.AutoShutOffCallCount, Is.EqualTo(2));
 }
Exemplo n.º 4
0
 public void BackgroundStartPopulatesModelFactoryWhenUserConfigExistsTest()
 {
     var container = new Athena.IoC.Container();
     string path = "myartpath";
     var config = new UserConfiguration();
     config.ServerUrl = "test";
     config.User = "******";
     config.Password = "******";
     var persister = Substitute.For<IPersister<AmpacheSong>>();
     container.Register<IPersister<AmpacheSong>>().To(persister);
     var configpersist = Substitute.For<IPersister<UserConfiguration>>();
     container.Register<IPersister<UserConfiguration>>().To(configpersist);
     configpersist.SelectBy(Arg.Any<int>()).Returns(config);
     var sngs = new List<AmpacheSong>();
     sngs.Add(new AmpacheSong(){Url = "http://test"});
     sngs.Add(new AmpacheSong(){Url = "http://test"});
     persister.SelectAll().Returns(sngs);
     var factory = Substitute.For<AmpacheSelectionFactory>();
     factory.AuthenticateToServer(config).Returns(x => (Authenticate)null);
     var mockHs = new MockHandShake();
     mockHs.Setup("test", "test");
     factory.Handshake.Returns(mockHs);
     var target = new BackgroundHandle(config, path, factory, new AmpacheModel(), container);
     target.Start(new MemoryStream());
     System.Threading.Thread.Sleep(100);
     var exp = target.Model.Factory;
     Assert.That(exp, Is.Not.Null);
     var userMessage = target.Model.UserMessage;
     Assert.That(userMessage, Is.Not.Null);
     Assert.That(userMessage, Is.EqualTo(BackgroundHandle.SUCCESS_MESSAGE));
     Assert.That(target.Model.Playlist, Is.EquivalentTo(sngs));
 }
Exemplo n.º 5
0
 public void BackgroundStartPopulatesModelPlaylistWhenUserConfigExistsTest()
 {
     var container = new Athena.IoC.Container();
     string path = "myartpath";
     var config = new UserConfiguration();
     config.ServerUrl = "test";
     config.User = "******";
     config.Password = "******";
     var persister = Substitute.For<IPersister<UserConfiguration>>();
     persister.SelectBy(Arg.Any<int>()).Returns(config);
     container.Register<IPersister<UserConfiguration>>().To(persister);
     var factory = Substitute.For<AmpacheSelectionFactory>();
     factory.AuthenticateToServer(config).Returns(x => (Authenticate)null);
     container.Register<IPersister<UserConfiguration>>();
     var target = new BackgroundHandle(config, path, factory, new AmpacheModel(), container);
     target.Start(new MemoryStream());
     var exp = target.Model.Playlist;
     Assert.That(exp, Is.Not.Null);
 }
Exemplo n.º 6
0
 public void BackgroundStartPopulatesModelFactoryWhenNoUserConfigExistsTest()
 {
     var container = new Athena.IoC.Container();
     string path = "myartpath";
     var persister = Substitute.For<IPersister<UserConfiguration>>();
     container.Register<IPersister<UserConfiguration>>().To(persister);
     persister.SelectBy(Arg.Any<int>()).Returns(new UserConfiguration { ServerUrl = string.Empty });
     var target = new BackgroundHandle(null, path, new AmpacheModel(), container);
     target.Start(new MemoryStream());
     var exp = target.Model.Factory;
     Assert.That(exp, Is.Not.Null);
 }
Exemplo n.º 7
0
 public void BackgroundStartInitializesModelConfigurationTest()
 {
     var container = new Athena.IoC.Container();
     var persister = Substitute.For<IPersister<UserConfiguration>>();
     container.Register<IPersister<UserConfiguration>>().To(persister);
     persister.SelectBy(Arg.Any<int>()).Returns(new UserConfiguration { ServerUrl = string.Empty });
     var target = new BackgroundHandle(null, null, new AmpacheModel(), container);
     var initial = target.Model;
     target.Start(new MemoryStream());
     var after = target.Model.Configuration;
     Assert.That(after, Is.Not.Null);
 }
Exemplo n.º 8
0
 public void BackgroundStartFailsWithNullParameterTest()
 {
     var target = new BackgroundHandle(null, null);
     target.Start(null);
     Assert.Fail();
 }
Exemplo n.º 9
0
 public void BackgroundStartBeginsAutoShutOffTest()
 {
     var container = new Athena.IoC.Container();
     string path = "myartpath";
     var persister = Substitute.For<IPersister<UserConfiguration>>();
     container.Register<IPersister<UserConfiguration>>().To(persister);
     persister.SelectBy(Arg.Any<int>()).Returns(new UserConfiguration { ServerUrl = string.Empty });
     var target = new BackgroundHandle(null, path, new AmpacheModel(), container);
     target.Start(new MemoryStream());
     Assert.That(target.AutoShutOffCallCount, Is.EqualTo(1));
 }
Exemplo n.º 10
0
 public void BackgroundListensForPlaylistChangesTest()
 {
     var container = new Athena.IoC.Container();
     var persister = Substitute.For<IPersister<AmpacheSong>>();
     var sng = new AmpacheSong();
     container.Register<IPersister<AmpacheSong>>().To(persister);
     var usrp = Substitute.For<IPersister<UserConfiguration>>();
     container.Register<IPersister<UserConfiguration>>().To(usrp);
     bool persisted = false;
     persister.When(p => p.Persist(sng)).Do(p => persisted = true);
     string path = "myartpath";
     var target = new BackgroundHandle(null, path, new AmpacheModel(), container);
     target.Start(new MemoryStream());
     System.Threading.Thread.Sleep(100);
     var sngs = new List<AmpacheSong>();
     sngs.Add(sng);
     target.Model.Playlist = sngs;
     Assert.That(persisted, Is.True);
 }