Beispiel #1
0
        public void RaiseMessageWhenCreateRadio()
        {
            var stream      = new MemoryEventStream();
            var publisher   = new EventBus(stream);
            var radioEngine = RadioEngineBuilder.Create().Build();

            Radio.Create(stream, publisher, radioEngine, "djam", "http://djamradio.fr");

            Assert.IsTrue(stream.GetEvents().Contains(new RadioCreated("djam", new Uri("http://djamradio.fr"))));
        }
Beispiel #2
0
        public void RaiseMessageWhenParseRadioSong()
        {
            var stream      = new MemoryEventStream();
            var publisher   = new EventBus(stream);
            var radioEngine = RadioEngineBuilder
                              .Create()
                              .SetParser("title", "artist")
                              .Build();

            var radio = Radio.Create(stream, publisher, radioEngine, "djam", "http://djamradio.fr");

            radio.SearchSong();

            Assert.IsTrue(stream.GetEvents().Contains(new RadioSongParsed("djam", "title", "artist")));
        }
Beispiel #3
0
        public void RaiseMessageWhenParseRadioErrorOccured()
        {
            var stream = new MemoryEventStream();

            stream.Add(new RadioCreated("djam", new Uri("http://djamradio.fr")));
            var publisher   = new EventBus(stream);
            var radioEngine = RadioEngineBuilder
                              .Create()
                              .SetException(new Exception("error"))
                              .Build();

            var radio = new Radio(stream, publisher, radioEngine);

            radio.SearchSong();

            Assert.IsTrue(stream.GetEvents().Contains(new RadioSongError("djam", "error")));
        }
Beispiel #4
0
        public void NoRaiseMessageWhenParseRadioSongWithDeletedRadio()
        {
            var stream = new MemoryEventStream();

            stream.Add(new RadioCreated("djam", new Uri("http://djamradio.fr")));
            stream.Add(new RadioDeleted("djam"));
            var publisher   = new EventBus(stream);
            var radioEngine = RadioEngineBuilder
                              .Create()
                              .SetParser("title", "artist")
                              .Build();

            var radio = new Radio(stream, publisher, radioEngine);

            radio.SearchSong();

            Assert.AreEqual(0, stream.GetEvents().OfType <RadioSongParsed>().Count());
        }