Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 2 commits
  • 10 files changed
  • 0 commit comments
  • 1 contributor
View
4 Play.Tests/IntegrationTestUrl.cs
@@ -10,14 +10,14 @@ public static class IntegrationTestUrl
{
public static string Current {
get {
- //return "https://play.yourcompany.com";
+ return "https://play.githubapp.com";
throw new Exception("Configure IntegrationTestUrl.cs first");
}
}
public static string Token {
get {
- //return "a04d03";
+ return "f07c8b";
throw new Exception("Configure IntegrationTestUrl.cs first");
}
}
View
1  Play.Tests/Play.Tests.csproj
@@ -125,6 +125,7 @@
<Compile Include="Models\PlayApiTests.cs" />
<Compile Include="Models\PusherHelper.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="ViewModels\BackgroundTaskTileViewModel.cs" />
<Compile Include="ViewModels\PlayViewModel.cs" />
<Compile Include="ViewModels\SearchViewModel.cs" />
<Compile Include="ViewModels\SongTileViewModelTests.cs" />
View
71 Play.Tests/ViewModels/BackgroundTaskTileViewModel.cs
@@ -0,0 +1,71 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reactive;
+using System.Reactive.Linq;
+using System.Text;
+using System.Windows.Media.Imaging;
+using Akavache;
+using FluentAssertions;
+using Moq;
+using Ninject;
+using Ninject.MockingKernel.Moq;
+using Play.Models;
+using Play.ViewModels;
+using ReactiveUI;
+using Xunit;
+
+namespace Play.Tests.ViewModels
+{
+ public class BackgroundTaskTileViewModelTests
+ {
+ [Fact]
+ public void DownloadAlbumShouldQueueABackgroundTask()
+ {
+ var kernel = new MoqMockingKernel();
+ var taskHost = new BackgroundTaskHostViewModel();
+ kernel.Bind<IBackgroundTaskHostViewModel>().ToConstant(taskHost);
+
+ var fixture = setupStandardFixture(Fakes.GetSong(), kernel);
+
+ var list = new List<int>();
+ taskHost.BackgroundTasks.CollectionCountChanged.Subscribe(list.Add);
+ fixture.DownloadAlbum.Execute(null);
+
+ list.Contains(1).Should().BeTrue();
+ }
+
+ [Fact]
+ public void DownloadSongShouldQueueABackgroundTask()
+ {
+ var kernel = new MoqMockingKernel();
+ var taskHost = new BackgroundTaskHostViewModel();
+ kernel.Bind<IBackgroundTaskHostViewModel>().ToConstant(taskHost);
+
+ var fixture = setupStandardFixture(Fakes.GetSong(), kernel);
+
+ var list = new List<int>();
+ taskHost.BackgroundTasks.CollectionCountChanged.Subscribe(list.Add);
+ fixture.DownloadSong.Execute(null);
+
+ list.Contains(1).Should().BeTrue();
+ }
+
+ static ISongTileViewModel setupStandardFixture(Song song, MoqMockingKernel kernel)
+ {
+ kernel.Bind<IBlobCache>().To<TestBlobCache>().Named("UserAccount");
+ kernel.Bind<IBlobCache>().To<TestBlobCache>().Named("LocalMachine");
+ RxApp.ConfigureServiceLocator((t,s) => kernel.Get(t,s), (t,s) => kernel.GetAll(t,s));
+
+ kernel.GetMock<IPlayApi>().Setup(x => x.FetchImageForAlbum(It.IsAny<Song>()))
+ .Returns(Observable.Return(new BitmapImage()));
+
+ kernel.GetMock<IPlayApi>().Setup(x => x.DownloadAlbum(It.IsAny<string>(), It.IsAny<string>()))
+ .Returns(Observable.Return<Tuple<string, byte[]>>(null));
+ kernel.GetMock<IPlayApi>().Setup(x => x.DownloadSong(It.IsAny<Song>()))
+ .Returns(Observable.Return<Tuple<string, byte[]>>(null));
+
+ return new SongTileViewModel(song, kernel.Get<IPlayApi>());
+ }
+ }
+}
View
3  Play/ViewModels/AppBootstrapper.cs
@@ -118,12 +118,13 @@ IKernel createDefaultKernel()
ret.Bind<ILoginMethods>().ToConstant(this);
ret.Bind<IWelcomeViewModel>().To<WelcomeViewModel>();
ret.Bind<IPlayViewModel>().To<PlayViewModel>();
- ret.Bind<IBackgroundTaskHostViewModel>().To<BackgroundTaskHostViewModel>();
ret.Bind<ISearchViewModel>().To<SearchViewModel>();
+ ret.Bind<IBackgroundTaskHostViewModel>().To<BackgroundTaskHostViewModel>();
ret.Bind<IViewForViewModel<WelcomeViewModel>>().To<WelcomeView>();
ret.Bind<IViewForViewModel<PlayViewModel>>().To<PlayView>();
ret.Bind<IViewForViewModel<SearchViewModel>>().To<SearchView>();
ret.Bind<IViewForViewModel<SongTileViewModel>>().To<SongTileView>().InTransientScope();
+ ret.Bind<IViewForViewModel<BackgroundTaskHostViewModel>>().To<BackgroundTaskHostView>();
#if DEBUG
var testBlobCache = new TestBlobCache();
View
4 Play/ViewModels/SongTileViewModel.cs
@@ -177,14 +177,14 @@ IObservable<Unit> postProcessAlbum(Tuple<string, byte[]> fileAndData, string roo
if (!targetDir.Exists) targetDir.Create();
// NB: https://github.com/play/play/issues/169
+ /*
using (var archive = TarArchive.CreateInputTarArchive(new MemoryStream(fileAndData.Item2))) {
archive.ExtractContents(targetDir.FullName);
}
+ */
- /*
var zip = new FastZip();
zip.ExtractZip(new MemoryStream(fileAndData.Item2), targetDir.FullName, FastZip.Overwrite.Always, null, null, null, true, true);
- */
}, RxApp.TaskpoolScheduler);
}
}
View
18 Play/Views/BackgroundTaskHostView.xaml
@@ -5,10 +5,10 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:Routing="clr-namespace:ReactiveUI.Routing;assembly=ReactiveUI.Routing" mc:Ignorable="d"
x:Class="Play.BackgroundTaskHostView"
- x:Name="UserControl"
+ x:Name="theHostView"
d:DesignWidth="640" d:DesignHeight="480">
- <Grid x:Name="LayoutRoot">
+ <Grid x:Name="LayoutRoot" DataContext="{Binding Path=ViewModel, ElementName=theHostView}" Visibility="{Binding ShouldShowBackgroundTaskPane}">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="32"/>
@@ -17,12 +17,14 @@
<ImageBrush ImageSource="/Play;component/Images/carbon_fibre_big.png" Stretch="None" TileMode="Tile" Viewport="0,0,20,22" ViewportUnits="Absolute" />
</Grid.Background>
- <ScrollViewer ScrollViewer.VerticalScrollBarVisibility="Disabled">
- <ItemsControl ItemsSource="{Binding BackgroundTasks}">
- <Routing:ViewModelViewHost ViewModel="{Binding}" />
- </ItemsControl>
- </ScrollViewer>
-
+ <ItemsControl ItemsSource="{Binding BackgroundTasks}" Grid.RowSpan="2">
+ <ItemsControl.ItemTemplate>
+ <DataTemplate>
+ <Routing:ViewModelViewHost ViewModel="{Binding}" />
+ </DataTemplate>
+ </ItemsControl.ItemTemplate>
+ </ItemsControl>
+
<Rectangle Grid.Row="1" Stroke="Black">
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
View
8 Play/Views/BackgroundTaskHostView.xaml.cs
@@ -18,20 +18,20 @@ namespace Play
/// <summary>
/// Interaction logic for BackgroundTaskView.xaml
/// </summary>
- public partial class BackgroundTaskHostView : UserControl, IViewForViewModel<IBackgroundTaskHostViewModel>
+ public partial class BackgroundTaskHostView : UserControl, IViewForViewModel<BackgroundTaskHostViewModel>
{
public BackgroundTaskHostView()
{
this.InitializeComponent();
}
- public IBackgroundTaskHostViewModel ViewModel {
- get { return (IBackgroundTaskHostViewModel)GetValue(ViewModelProperty); }
+ public BackgroundTaskHostViewModel ViewModel {
+ get { return (BackgroundTaskHostViewModel)GetValue(ViewModelProperty); }
set { SetValue(ViewModelProperty, value); }
}
public static readonly DependencyProperty ViewModelProperty =
DependencyProperty.Register("ViewModel", typeof(IBackgroundTaskHostViewModel), typeof(BackgroundTaskHostView), new UIPropertyMetadata(null));
- object IViewForViewModel.ViewModel { get { return ViewModel; } set { ViewModel = (IBackgroundTaskHostViewModel)value; } }
+ object IViewForViewModel.ViewModel { get { return ViewModel; } set { ViewModel = (BackgroundTaskHostViewModel)value; } }
}
}
View
6 Play/Views/BackgroundTaskTileView.xaml
@@ -5,10 +5,10 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="Play.BackgroundTaskTileView"
- x:Name="UserControl"
- d:DesignWidth="480" d:DesignHeight="128">
+ x:Name="UserControl" Height="64"
+ d:DesignWidth="480" d:DesignHeight="64">
- <Grid x:Name="LayoutRoot">
+ <Grid x:Name="LayoutRoot" DataContext="{Binding ViewModel, ElementName=UserControl}">
<StackPanel Margin="32,0" VerticalAlignment="Center">
<TextBlock TextWrapping="NoWrap" Text="{Binding CurrentText}" HorizontalAlignment="Center" FontWeight="Bold" Foreground="#D8FFFFFF"/>
<ProgressBar Style="{DynamicResource PlayProgressBarStyle}" Height="16" Maximum="100" Minimum="0" Value="{Binding CurrentProgress}" Margin="0,4,0,0"/>
View
13 Play/Views/BackgroundTaskTileView.xaml.cs
@@ -10,17 +10,28 @@
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
+using Play.ViewModels;
+using ReactiveUI.Routing;
namespace Play
{
/// <summary>
/// Interaction logic for BackgroundTaskTileView.xaml
/// </summary>
- public partial class BackgroundTaskTileView : UserControl
+ public partial class BackgroundTaskTileView : UserControl, IViewForViewModel<BackgroundTaskTileViewModel>
{
public BackgroundTaskTileView()
{
this.InitializeComponent();
}
+
+ public BackgroundTaskTileViewModel ViewModel {
+ get { return (BackgroundTaskTileViewModel)GetValue(ViewModelProperty); }
+ set { SetValue(ViewModelProperty, value); }
+ }
+ public static readonly DependencyProperty ViewModelProperty =
+ DependencyProperty.Register("ViewModel", typeof(BackgroundTaskTileViewModel), typeof(BackgroundTaskTileView), new UIPropertyMetadata(null));
+
+ object IViewForViewModel.ViewModel { get { return ViewModel; } set { ViewModel = (BackgroundTaskTileViewModel)value; } }
}
}
View
5 Play/Views/PlayView.xaml
@@ -9,6 +9,7 @@
<Grid DataContext="{Binding ViewModel, ElementName=theView}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
+ <RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
@@ -88,8 +89,10 @@
</StackPanel>
</Grid>
</Border>
+
+ <local:BackgroundTaskHostView Grid.Row="1" ViewModel="{Binding BackgroundTaskHost}" />
- <Grid Grid.Row="1" MinHeight="120" Background="#FFF3F3F3">
+ <Grid Grid.Row="2" MinHeight="120" Background="#FFF3F3F3">
<ScrollViewer VerticalScrollBarVisibility="Hidden" HorizontalScrollBarVisibility="Hidden" >
<ItemsControl ItemsSource="{Binding AllSongs}">
<ItemsControl.ItemTemplate>

No commit comments for this range

Something went wrong with that request. Please try again.