示例#1
0
        public void DownloadsAndPersistsTheStoreData()
        {
            var stores = StoreNumberFactory
                         .Create(10)
                         .Select(StoreInfoFactory.Create)
                         .ToArray();

            _downloader.Download(Arg.Any <ZipCode>())
            .Returns(stores);


            _processor.Process(_zipCode);


            _downloader
            .Received(1)
            .Download(_zipCode);

            _persistor
            .Received(1)
            .Persist(Arg.Is <IEnumerable <StoreInfo> >(_ => _.SequenceEqual(stores)));

            _zipCodeDataService
            .Received(1)
            .UpdateZipCode("55555");

            _deadlockDetector
            .Received(1)
            .UpdateStatus();
        }
示例#2
0
        public void Process(ZipCode zipCode)
        {
            Logger.LogInfo("Processing", nameof(zipCode), zipCode.Zip);

            Logger.LogInfo("Downloading Stores", nameof(zipCode), zipCode.Zip);

            StoreInfo[] stores;
            try
            {
                stores = _downloader.Download(zipCode).ToArray();
                Logger.LogInfo("Stores Data Downloaded", "storesCount", stores.Length, nameof(zipCode), zipCode.Zip);
            }
            catch (WebException ex)
            {
                if (_webExceptionHandler.ShouldBubbleUpException(ex))
                {
                    throw;
                }

                LogFailure(zipCode);
                return;
            }

            _storesPersistor.Persist(stores);

            _zipCodeDataService.UpdateZipCode(zipCode.Zip);

            LogSuccess(zipCode);

            _deadlockDetector.UpdateStatus();
        }