public void Init() { var nameProviderFactoryMock = new Mock <INameProviderFactory>(); var nameProviderMock = new Mock <INameProvider>(); var mappingProviderFactoryMock = new Mock <IMarketMappingProviderFactory>(); nameProviderFactoryMock.Setup(m => m.BuildNameProvider(It.IsAny <ISportEvent>(), It.IsAny <int>(), It.IsAny <IReadOnlyDictionary <string, string> >())).Returns(nameProviderMock.Object); var namedValuesCacheMock = new Mock <INamedValueCache>(); namedValuesCacheMock.Setup(x => x.IsValueDefined(It.IsAny <int>())).Returns(true); namedValuesCacheMock.Setup(x => x.GetNamedValue(It.IsAny <int>())).Returns((int id) => new NamedValue(id, "somevalue")); var namedValuesProviderMock = new Mock <INamedValuesProvider>(); namedValuesProviderMock.Setup(x => x.VoidReasons).Returns(namedValuesCacheMock.Object); namedValuesProviderMock.Setup(x => x.BetStopReasons).Returns(namedValuesCacheMock.Object); namedValuesProviderMock.Setup(x => x.BettingStatuses).Returns(namedValuesCacheMock.Object); _mapper = new FeedMessageMapper(new TestSportEventFactory(), nameProviderFactoryMock.Object, mappingProviderFactoryMock.Object, namedValuesProviderMock.Object, ExceptionHandlingStrategy.THROW, TestProducerManager.Create(), new Mock <IMarketCacheProvider>().Object, namedValuesCacheMock.Object); _deserializer = new Deserializer <FeedMessage>(); _validator = new TestFeedMessageValidator(); }
public void Init() { _cacheManager = new CacheManager(); _dataRouterManager = new TestDataRouterManager(_cacheManager); _variantMemoryCache = new MemoryCache("VariantCache"); _invariantMemoryCache = new MemoryCache("InVariantCache"); _variantDescriptionsMemoryCache = new MemoryCache("VariantDescriptionListCache"); _timer = new SdkTimer(_timerInterval, _timerInterval); _mappingValidatorFactory = new MappingValidatorFactory(); _inVariantMdCache = new InvariantMarketDescriptionCache(_invariantMemoryCache, _dataRouterManager, _mappingValidatorFactory, _timer, TestData.Cultures, _cacheManager); _variantMdCache = new VariantMarketDescriptionCache(_variantMemoryCache, _dataRouterManager, _mappingValidatorFactory, _cacheManager); _variantDescriptionListCache = new VariantDescriptionListCache(_variantDescriptionsMemoryCache, _dataRouterManager, _mappingValidatorFactory, _timer, TestData.Cultures, _cacheManager); var dataFetcher = new TestDataFetcher(); var betStopReasonsCache = new NamedValueCache(new NamedValueDataProvider(FileHelper.FindFile("betstop_reasons.xml"), dataFetcher, "betstop_reason"), ExceptionHandlingStrategy.THROW); var bettingStatusCache = new NamedValueCache(new NamedValueDataProvider(FileHelper.FindFile("betting_status.xml"), dataFetcher, "betting_status"), ExceptionHandlingStrategy.THROW); var namedValueProviderMock = new Mock <INamedValuesProvider>(); namedValueProviderMock.Setup(x => x.BetStopReasons).Returns(betStopReasonsCache); namedValueProviderMock.Setup(x => x.BettingStatuses).Returns(bettingStatusCache); _validator = new FeedMessageValidator( new MarketCacheProvider(_inVariantMdCache, _variantMdCache, _variantDescriptionListCache), TestData.Culture, namedValueProviderMock.Object, TestProducerManager.Create()); }
public void ProducerManagerExistsByNameTest() { var producerManager = TestProducerManager.Create(); var result = producerManager.Exists("lo"); Assert.IsTrue(result); }
public void ProducerManagerInitTest() { var producerManager = TestProducerManager.Create(); Assert.IsNotNull(producerManager); Assert.IsNotNull(producerManager.Producers); Assert.IsTrue(producerManager.Producers.Any()); }
public void ProducerManagerNotExistsByIdTest() { var producerManager = TestProducerManager.Create(); var result = producerManager.Exists(11); Assert.IsTrue(!result); }
public void ProducerManagerGetByNameTest() { var producerManager = TestProducerManager.Create(); var producer1 = producerManager.Get("lo"); Assert.IsNotNull(producer1); Assert.AreEqual(1, producer1.Id); }
public void UnknownProducerTest() { var producerManager = TestProducerManager.Create(); var producer = producerManager.Get(50); Assert.IsNotNull(producer); Assert.AreEqual(99, producer.Id); Assert.AreEqual(true, producer.IsAvailable); Assert.AreEqual(false, producer.IsDisabled); Assert.AreEqual(true, producer.IsProducerDown); Assert.AreEqual("Unknown", producer.Name); }
public void ProducerManagerUpdateLocked01Test() { var producerId = 1; var producerManager = TestProducerManager.Create(); var producer = producerManager.Get(producerId); CheckLiveOddsProducer(producer); ((ProducerManager)producerManager).Lock(); producerManager.DisableProducer(producerId); Assert.AreEqual(true, producer.IsDisabled); }
private void TestEntityValues(IBetSettlement <ICompetition> entity, bet_settlement record, AssertHelper assertHelper) { assertHelper.AreEqual(() => entity.Event.Id.ToString(), record.event_id); var rProduct = TestProducerManager.Create().Get(record.product); assertHelper.AreEqual(() => entity.Producer, rProduct); assertHelper.AreEqual(() => entity.RequestId, record.request_idSpecified ? (long?)record.request_id : null); assertHelper.AreEqual(() => entity.Timestamps.Created, record.timestamp); TestMarketOutcomes(entity.Markets.ToList(), record.outcomes, assertHelper); }
public void ProducerManagerUpdateLocked02Test() { var producerId = 1; var date = DateTime.Now; var producerManager = TestProducerManager.Create(); var producer = producerManager.Get(producerId); CheckLiveOddsProducer(producer); ((ProducerManager)producerManager).Lock(); producerManager.AddTimestampBeforeDisconnect(producerId, date); Assert.AreEqual(date, producer.LastTimestampBeforeDisconnect); }
public void CompareProducersTest() { var producerManager = TestProducerManager.Create(); var producer1 = producerManager.Get(1); var producer2 = new Producer(1, "Lo", "Live Odds", "lo", true, 60, 3600, "live"); Assert.IsNotNull(producer1); Assert.AreEqual(1, producer1.Id); Assert.IsNotNull(producer2); Assert.AreEqual(1, producer2.Id); Assert.AreEqual(producer1.IsAvailable, producer2.IsAvailable); Assert.AreEqual(producer1.IsDisabled, producer2.IsDisabled); Assert.AreEqual(producer1.IsProducerDown, producer2.IsProducerDown); Assert.AreEqual(producer1.Name, producer2.Name, true); Assert.IsTrue(producer1.Name.Equals(producer2.Name, StringComparison.InvariantCultureIgnoreCase)); Assert.AreEqual(producer1, producer2); }
static MapEntityTestBase() { var nameProviderFactoryMock = new Mock <INameProviderFactory>(); var nameProviderMock = new Mock <INameProvider>(); nameProviderFactoryMock.Setup(m => m.BuildNameProvider(It.IsAny <ICompetition>(), It.IsAny <int>(), It.IsAny <IReadOnlyDictionary <string, string> >())).Returns(nameProviderMock.Object); var voidReasonCache = new NamedValueCache(new NamedValueDataProvider(TestData.RestXmlPath + @"\void_reasons.xml", new TestDataFetcher(), "void_reason"), ExceptionHandlingStrategy.THROW); var namedValuesProviderMock = new Mock <INamedValuesProvider>(); namedValuesProviderMock.Setup(x => x.VoidReasons).Returns(voidReasonCache); Mapper = new FeedMessageMapper( new TestSportEventFactory(), nameProviderFactoryMock.Object, new Mock <IMarketMappingProviderFactory>().Object, namedValuesProviderMock.Object, ExceptionHandlingStrategy.THROW, TestProducerManager.Create(), new Mock <IMarketCacheProvider>().Object, voidReasonCache); }
protected void TestMessageProperties(AssertHelper assertHelper, IMessage message, long timestamp, int productId) { assertHelper.AreEqual(() => message.Timestamps.Created, timestamp); assertHelper.AreEqual(() => message.Producer, TestProducerManager.Create().Get(productId)); }
public void Init() { var deserializer = new Deserializer <FeedMessage>(); var keyParser = new RegexRoutingKeyParser(); _mock = new Mock <IRabbitMqChannel>(); _messageReceiver = new RabbitMqMessageReceiver(_mock.Object, deserializer, keyParser, TestProducerManager.Create(), false); }