public async Task ScrobbleTest()
        {
            Scrobble expected = new Scrobble("TestArtist", "TestAlbum", "TestTrack", DateTime.Now)
            {
                AlbumArtist = "TestAlbumArtist", Duration = TimeSpan.FromSeconds(30)
            };

            Mock <IAuthScrobbler> scrobblerMock = new Mock <IAuthScrobbler>();
            Scrobble actual = null;

            scrobblerMock.Setup(i => i.ScrobbleAsync(It.IsAny <Scrobble>())).Callback <Scrobble>(s => actual = s);

            ManualScrobbleViewModel vm = new ManualScrobbleViewModel(null)
            {
                Scrobbler      = scrobblerMock.Object,
                UseCurrentTime = false,

                Artist      = expected.Artist,
                Album       = expected.Album,
                Track       = expected.Track,
                Time        = expected.TimePlayed.DateTime,
                AlbumArtist = expected.AlbumArtist,
                Duration    = expected.Duration.Value
            };

            await vm.Scrobble();

            Assert.That(actual.IsEqualScrobble(expected), Is.True);
        }
示例#2
0
        public async Task ScrobbleTest()
        {
            Scrobble expected = new Scrobble("TestArtist", "TestAlbum", "TestTrack", DateTime.Now)
            {
                AlbumArtist = "TestAlbumArtist", Duration = TimeSpan.FromSeconds(30)
            };

            Mock <IUserScrobbler> scrobblerMock = new Mock <IUserScrobbler>();
            Scrobble actual = null;

            scrobblerMock.Setup(i => i.ScrobbleAsync(It.IsAny <Scrobble>(), false)).Callback <Scrobble, bool>((s, c) => actual = s)
            .Returns(Task.Run(() => new ScrobbleResponse(LastResponseStatus.Successful)));

            Mock <IExtendedWindowManager> windowManagerMock = new Mock <IExtendedWindowManager>(MockBehavior.Strict);

            ManualScrobbleViewModel vm = new ManualScrobbleViewModel(windowManagerMock.Object)
            {
                Scrobbler   = scrobblerMock.Object,
                Artist      = expected.Artist,
                Album       = expected.Album,
                Track       = expected.Track,
                AlbumArtist = expected.AlbumArtist,
                Duration    = expected.Duration.Value
            };

            vm.ScrobbleTimeVM.UseCurrentTime = false;
            vm.ScrobbleTimeVM.Time           = expected.TimePlayed.DateTime;

            await vm.Scrobble();

            Assert.That(actual.IsEqualScrobble(expected), Is.True);
        }