Beispiel #1
0
        public async Task StationShouldBeSavedInMemory()
        {
            var logger = A.Fake <ILogger>();
            var configurationProvider = A.Fake <IConfigurationProvider>();

            A.CallTo(() => configurationProvider.Load()).Returns(new Configuration {
                DatabaseLink = "http://test"
            });

            var provider = new StationProvider(logger, configurationProvider, new StationValidator());

            using (var httpTest = new HttpTest())
            {
                httpTest.RespondWithJson(new[] { new {
                                                     Name     = "Station",
                                                     Uri      = new [] { "http:\\\\test" },
                                                     Country  = "Station",
                                                     Language = new [] { "Station" }
                                                 } });
                var result = await provider.Search();

                Assert.Contains(result, x => x.Id == 0);

                result = await provider.Search();

                Assert.Contains(result, x => x.Id == 0);
            }
        }
Beispiel #2
0
        public async Task SearchById()
        {
            var logger = A.Fake <ILogger>();
            var configurationProvider = A.Fake <IConfigurationProvider>();

            A.CallTo(() => configurationProvider.Load()).Returns(new Configuration {
                DatabaseLink = "http://test"
            });

            var provider = new StationProvider(logger, configurationProvider, new StationValidator());

            using (var httpTest = new HttpTest())
            {
                httpTest.RespondWithJson(new[] { new {
                                                     Name     = "Station",
                                                     Uri      = new [] { "http:\\\\test" },
                                                     Country  = "Station",
                                                     Language = new [] { "Station" }
                                                 } });
                var result = await provider.Search(0);

                Assert.Equal("Station", result.Name);
                Assert.Equal("Station", result.Country);
                Assert.Contains(result.Uri, x => x == "http:\\\\test");
                Assert.Contains(result.Language, x => x == "Station");
            }
        }
Beispiel #3
0
        public async Task IncorrecrStation()
        {
            var logger = A.Fake <ILogger>();
            var configurationProvider = A.Fake <IConfigurationProvider>();

            A.CallTo(() => configurationProvider.Load()).Returns(new Configuration {
                DatabaseLink = "http://test"
            });

            var provider = new StationProvider(logger, configurationProvider, new StationValidator());

            using (var httpTest = new HttpTest())
            {
                httpTest.RespondWithJson(new[] { new {
                                                     Name     = "",
                                                     Uri      = new [] { "http:\\\\test" },
                                                     Country  = "Station",
                                                     Language = new [] { "Station" }
                                                 } });
                var result = await provider.Search();

                Assert.True(!result.Any());
            }
            A.CallTo(() => logger.Error(A <string> ._)).MustHaveHappened();
        }