Beispiel #1
0
        public void GetAvailabilitiesUrl_SecondtKeyNotInitiated_UrlNullAndException()
        {
            var container = TestRegistrator.Init();
            var config    = (EmulatedConfig)container.Resolve <IConfig>();

            config.Clean();
            config.Set("BS:BargainsEndPoint", "https://bargains.endpoint.net");

            var urlProvider = container.Resolve <IBargainsUrlProvider>();

            string url             = null;
            bool   throwsException = false;

            try
            {
                url = urlProvider.GetAvailabilitiesUrl(123, 4);
            }
            catch (Exception e)
            {
                throwsException = true;
            }

            Assert.IsTrue(throwsException);
            Assert.IsNull(url);
        }
Beispiel #2
0
        public void GetAvailabilitiesUrl_FirstKeyNotInitiated_UrlNullAndException()
        {
            var container = TestRegistrator.Init();
            var config    = (EmulatedConfig)container.Resolve <IConfig>();

            config.Clean();
            config.Set("BS:BargainsUserCode", "personalSecurityCode");

            var urlProvider = container.Resolve <IBargainsUrlProvider>();

            string url             = null;
            bool   throwsException = false;

            try
            {
                url = urlProvider.GetAvailabilitiesUrl(123, 4);
            }
            catch (Exception e)
            {
                throwsException = true;
            }

            Assert.IsTrue(throwsException);
            Assert.IsNull(url);
        }
Beispiel #3
0
        public void IsAcceptedResponse_BadBoardPrice_NotValid_ReturnFalse()
        {
            var container = TestRegistrator.Init();
            var validator = container.Resolve <IBSAvailabilityDtoValidator>();

            var dto = EmulateDtos.GetAvailabilityDtoByType(DtoTypes.BadPrice);

            Assert.IsFalse(validator.IsAcceptedResponse(dto));
        }
        public void Translate_BadBoardPrice_NotValid_ReturnNull()
        {
            var container  = TestRegistrator.Init();
            var translator = container.Resolve <IBSAvailabilityTranslator>();

            var dto = EmulateDtos.GetAvailabilityDtoByType(DtoTypes.BadPrice);

            Assert.IsNull(translator.Translate(dto, NIGHTS));
        }
        public void Translate_BadHotelName_ReturnNull()
        {
            var container  = TestRegistrator.Init();
            var translator = container.Resolve <IBSAvailabilityTranslator>();

            var calculatedItem = translator.Translate(EmulateDtos.GetAvailabilityDtoByType(DtoTypes.BadName), NIGHTS);

            Assert.IsNull(calculatedItem);
        }
        public void Log_LogOnlyMessage_JustNotGeneratesException()
        {
            var  container = TestRegistrator.Init();
            var  logger    = container.Resolve <ILogger>();
            bool ok        = true;

            try { logger.Log("Some Message"); }
            catch (Exception) { ok = false; }

            Assert.IsTrue(ok);
        }
        public void Translate_BadBoardPrice_Valid_EquivalentFields()
        {
            var container  = TestRegistrator.Init();
            var translator = container.Resolve <IBSAvailabilityTranslator>();

            var calculatedItem = translator.Translate(EmulateDtos.GetAvailabilityDtoByType(DtoTypes.Huggly), NIGHTS);

            var espectedItem = EmulateModels.GeValidWithBadBoardPrice(NIGHTS);

            CheckNotNullAsserts(calculatedItem, espectedItem);
        }
        public static IUnityContainer Init()
        {
            var container = TestRegistrator.Init();
            var config    = (EmulatedConfig)container.Resolve <IConfig>();

            config.Clean();
            config.Set("BS:BargainsEndPoint", "https://bargains.endpoint.net");
            config.Set("BS:BargainsUserCode", "personalSecurityCode");

            return(container);
        }
Beispiel #9
0
        public void IsCorrectRate_BadPrice_ReturnFalse()
        {
            var container = TestRegistrator.Init();
            var validator = container.Resolve <IBSAvailabilityDtoValidator>();

            foreach (var type in Enum.GetValues(typeof(AvailabilityRateType)))
            {
                var dto = EmulateDtos.GetRate("Board Type 1", (AvailabilityRateType)type, false);

                Assert.IsFalse(validator.IsCorrectRate(dto));
            }
        }
Beispiel #10
0
        public void IsAcceptedResponse_PerfectEachRateType_ReturnTrue()
        {
            var container = TestRegistrator.Init();
            var validator = container.Resolve <IBSAvailabilityDtoValidator>();

            foreach (var type in Enum.GetValues(typeof(AvailabilityRateType)))
            {
                var dto = EmulateDtos.GetAvailabilityDtoByType(DtoTypes.Perfect, (AvailabilityRateType)type);

                Assert.IsTrue(validator.IsAcceptedResponse(dto));
            }
        }
        public void Translate_PerfectEachRateType_EquivalentFields()
        {
            var container  = TestRegistrator.Init();
            var translator = container.Resolve <IBSAvailabilityTranslator>();

            foreach (var type in Enum.GetValues(typeof(AvailabilityRateType)))
            {
                var calculatedItem = translator.Translate(EmulateDtos.GetAvailabilityDtoByType(DtoTypes.Perfect, (AvailabilityRateType)type), NIGHTS);

                var espectedItem = EmulateModels.GetPerfect((AvailabilityRateType)type, NIGHTS);

                CheckNotNullAsserts(calculatedItem, espectedItem);
            }
        }
        public void GetBSHotelAvailabilities_CacheNotActive_NotExistingKey_ReturnsNull()
        {
            var container = TestRegistrator.Init();

            var config = (EmulatedConfig)container.Resolve <IConfig>();

            config.Clean();

            var cache = container.Resolve <IBSCache>();

            var result = cache.GetBSHotelAvailabilities(2, 2);

            Assert.IsNull(result);
        }
        public void GetBSHotelAvailabilities_CacheActive_NotExistingKey_ReturnsNull()
        {
            var container = TestRegistrator.Init();
            var config    = (EmulatedConfig)container.Resolve <IConfig>();

            config.Clean();
            //config.Set("BS:BargainsEndPoint", "https://webbedsdevtest.azurewebsites.net");
            //config.Set("BS:BargainsUserCode", "aWH1EX7ladA8C/oWJX5nVLoEa4XKz2a64yaWVvzioNYcEo8Le8caJw==");
            config.Set("BS:CacheMinutes", "5");

            var cache = container.Resolve <IBSCache>();

            var result = cache.GetBSHotelAvailabilities(1, 1);

            Assert.IsNull(result);
        }
        public void GetBSHotelAvailabilities_CacheActive_ExistingKey_ReturnsObject()
        {
            var container = TestRegistrator.Init();

            var config = (EmulatedConfig)container.Resolve <IConfig>();

            config.Clean();
            config.Set("BS:CacheMinutes", "5");

            var cache = container.Resolve <IBSCache>();

            cache.SetBSHotelAvailabilities(3, 3, new List <BSHotelAvailability>());

            var result = cache.GetBSHotelAvailabilities(3, 3);

            Assert.IsNotNull(result);
        }