Beispiel #1
0
        public void Calling_DstService_Should_ReturnAllDst()
        {
            // Arrage
            var expectedReturnedCount = 129;

            // Act
            var service       = new DSTService(Config.AccessKey, Config.SecretKey);
            var result        = service.GetDaylightSavingTime();
            var sampleCountry = result.SingleOrDefault(x => x.Region.Country.Name == "Norway");

            // Assert
            Assert.AreEqual(expectedReturnedCount, result.Count);

            HasValidSampleCountry(sampleCountry);
        }
Beispiel #2
0
        public void Calling_DstService_Should_ReturnAllDst()
        {
            // Arrage
            var expectedReturnedCount = 139;

            // Act
            var service = new DSTService (Config.AccessKey, Config.SecretKey);
            var result = service.GetDaylightSavingTime ();
            var sampleCountry = result.SingleOrDefault (x => x.Region.Country.Name == "Norway");

            // Assert
            Assert.AreEqual (expectedReturnedCount, result.Count);

            HasValidSampleCountry (sampleCountry);
        }
Beispiel #3
0
        public void Calling_DstService_WithCountry_And_WithYear_Should_ReturnAllDst()
        {
            // Arrage
            var countryCode = "no";
            var year = 2014;

            // Act
            var service = new DSTService (Config.AccessKey, Config.SecretKey);
            var result = service.GetDaylightSavingTime (countryCode, year);
            var sampleCountry = result.SingleOrDefault (x => x.Region.Country.Name == "Norway");

            // Assert
            Assert.IsFalse (service.IncludeOnlyDstCountries);
            Assert.IsTrue (result.Count == 1);
            HasValidSampleCountry (sampleCountry);
        }
Beispiel #4
0
        public void Calling_DstService_WithCountry_And_WithYear_Should_ReturnAllDst()
        {
            // Arrage
            var countryCode = "no";
            var year        = 2014;

            // Act
            var service       = new DSTService(Config.AccessKey, Config.SecretKey);
            var result        = service.GetDaylightSavingTime(countryCode, year);
            var sampleCountry = result.SingleOrDefault(x => x.Region.Country.Name == "Norway");

            // Assert
            Assert.IsFalse(service.IncludeOnlyDstCountries);
            Assert.IsTrue(result.Count == 1);
            HasValidSampleCountry(sampleCountry);
        }
Beispiel #5
0
        public void Calling_DstService_WithPlacesForEveryCountry_Should_ReturnAnyDstWithPlaces()
        {
            // Arrage
            var year = 2014;

            // Act
            var service       = new DSTService(Config.AccessKey, Config.SecretKey);
            var result        = service.GetDaylightSavingTime(year);
            var sampleCountry = result.SingleOrDefault(x => x.Region.Country.Name == "Norway");

            // Assert
            Assert.IsTrue(service.IncludePlacesForEveryCountry);
            Assert.IsTrue(result.Any(x => x.Region.Locations.ToList().Count > 0));

            HasValidSampleCountry(sampleCountry);
        }
Beispiel #6
0
        public void Calling_DstService_WithOnlyDstCountries_Should_ReturnOnlyDstCountries()
        {
            // Arrage
            var year = 2014;

            // Act
            var service = new DSTService (Config.AccessKey, Config.SecretKey);
            service.IncludeOnlyDstCountries = true;
            var result = service.GetDaylightSavingTime (year);
            var sampleCountry = result.SingleOrDefault (x => x.Region.Country.Name == "Norway");

            // Assert
            Assert.IsTrue (service.IncludeOnlyDstCountries);
            Assert.AreEqual (139, result.Count);

            HasValidSampleCountry (sampleCountry);
        }
Beispiel #7
0
        public void Calling_DstService_WithOnlyDstCountries_Should_ReturnOnlyDstCountries()
        {
            // Arrage
            var year = 2014;

            // Act
            var service = new DSTService(Config.AccessKey, Config.SecretKey);

            service.IncludeOnlyDstCountries = true;
            var result        = service.GetDaylightSavingTime(year);
            var sampleCountry = result.SingleOrDefault(x => x.Region.Country.Name == "Norway");

            // Assert
            Assert.IsTrue(service.IncludeOnlyDstCountries);
            Assert.AreEqual(133, result.Count);

            HasValidSampleCountry(sampleCountry);
        }
Beispiel #8
0
        public void Calling_DstService_WithoutTimeChanges_Should_NotReturnAnyTimeChanges()
        {
            // Arrage
            var year = 2014;

            // Act
            var service = new DSTService(Config.AccessKey, Config.SecretKey);

            service.IncludeTimeChanges = false;
            var result        = service.GetDaylightSavingTime(year);
            var sampleCountry = result.SingleOrDefault(x => x.Region.Country.Name == "Norway");

            // Assert
            Assert.IsFalse(service.IncludeTimeChanges);
            Assert.IsTrue(result.All(x => x.TimeChanges.ToList().Count == 0));

            HasValidSampleCountry(sampleCountry);
        }
Beispiel #9
0
        public void Calling_DstService_WithoutOnlyDstCountries_Should_ReturnAllCountries()
        {
            // Arrage
            var year = 2014;

            // Act
            var service = new DSTService(Config.AccessKey, Config.SecretKey);

            service.IncludeOnlyDstCountries = false;
            var result        = service.GetDaylightSavingTime(year);
            var dstAllYear    = result.Where(x => x.Special == DSTSpecialType.DaylightSavingTimeAllYear);
            var noDstAllYear  = result.Where(x => x.Special == DSTSpecialType.NoDaylightSavingTime);
            var sampleCountry = result.SingleOrDefault(x => x.Region.Country.Name == "Norway");

            // Assert
            Assert.IsFalse(service.IncludeOnlyDstCountries);
            Assert.AreEqual(349, result.Count);
            Assert.Greater(dstAllYear.Count(), 0);
            Assert.Greater(noDstAllYear.Count(), 0);

            HasValidSampleCountry(sampleCountry);
        }
Beispiel #10
0
        public void Calling_DstService_WithoutOnlyDstCountries_Should_ReturnAllCountries()
        {
            // Arrage
            var year = 2014;

            // Act
            var service = new DSTService (Config.AccessKey, Config.SecretKey);
            service.IncludeOnlyDstCountries = false;
            var result = service.GetDaylightSavingTime (year);
            var dstAllYear = result.Where (x => x.Special == DSTSpecialType.DaylightSavingTimeAllYear);
            var noDstAllYear = result.Where (x => x.Special == DSTSpecialType.NoDaylightSavingTime);
            var sampleCountry = result.SingleOrDefault (x => x.Region.Country.Name == "Norway");

            // Assert
            Assert.IsFalse (service.IncludeOnlyDstCountries);
            Assert.AreEqual (320, result.Count);
            Assert.Greater (dstAllYear.Count(), 0);
            Assert.Greater (noDstAllYear.Count(), 0);

            HasValidSampleCountry (sampleCountry);
        }
Beispiel #11
0
        public void Calling_DstService_WithTimeChanges_Should_ReturnAnyTimeChanges()
        {
            // Arrage
            var year = 2014;

            // Act
            var service = new DSTService (Config.AccessKey, Config.SecretKey);
            service.IncludeTimeChanges = true;
            var result = service.GetDaylightSavingTime (year);
            var sampleCountry = result.SingleOrDefault (x => x.Region.Country.Name == "Norway");

            // Assert
            Assert.IsTrue (service.IncludeTimeChanges);
            Assert.IsTrue (result.Any (x => x.TimeChanges.ToList().Count > 0));

            HasValidSampleCountry (sampleCountry);
        }
Beispiel #12
0
        public void Calling_DstService_WithoutPlacesForEveryCountry_Should_ReturnAllDstWithoutPlaces()
        {
            // Arrage
            var year = 2014;

            // Act
            var service = new DSTService (Config.AccessKey, Config.SecretKey);
            service.IncludePlacesForEveryCountry = false;
            var result = service.GetDaylightSavingTime (year);
            var sampleCountry = result.SingleOrDefault (x => x.Region.Country.Name == "Norway");

            // Assert
            Assert.IsFalse (service.IncludePlacesForEveryCountry);
            Assert.IsTrue (result.All (x => x.Region.Locations.ToList().Count == 0));

            HasValidSampleCountry (sampleCountry);
        }