Esempio n. 1
0
        public async Task Given_PlaylistExists_When_TagIsDetected_Then_PlayCommandShouldBeSent()
        {
            var bootstrapper = new TestBootstrapper(new Application(), this.logger);
            await bootstrapper.StartAsync(true).ConfigureAwait(false);

            var playlistRepository = bootstrapper.RepositoriesModule.PlaylistRepository;

            playlistRepository.Setup(x => x.GetPlaylistAsync("01020304")).ReturnsAsync(new PlaylistEntity("01020304", "Numbers"));
            var mpcConnection = bootstrapper.MusicControlModule.MpcConnection;

            mpcConnection.Setup(x => x.SendAsync(It.IsAny <LoadCommand>())).ReturnsAsync(() =>
            {
                var mpdMessage = New.Mock <IMpdMessage <string> >();
                mpdMessage.SetupGet(x => x.IsResponseValid).Returns(true);
                return(mpdMessage);
            });
            var rfidTransceiver = (await bootstrapper.ControlsModuleFactory.ControlsModule.ConfigureAwait(false)).InputControls.RfidTransceiver;

            rfidTransceiver.Raise(x => x.TagDetected += null, new TagDetectedEventArgs(new Uid(1, 2, 3, 4)));

            mpcConnection.Verify(x => x.SendAsync(It.IsAny <PlayCommand>()), Times.Once);
        }