public void Setup() { TagRepository tagRepository = new TagRepository(); tagRepository.FilePath = "data/initial_tags.json"; tagRepository.InitializeFromFile(); ILocationProvider locationProvider = new MockLocationProvider(); _parser = new RegexMessageParser(tagRepository, locationProvider); }
public void SerializeDemoMessagesToFile() { ILocationProvider locationProvider = new MockLocationProvider(); IMessageParser realMessageParser = new RegexMessageParser(_singletonTagProvider, locationProvider); MessageRepository tempMessageRepository = new MessageRepository(); TagRepository tempTagRepository = new TagRepository(); IncomingMessageProcessor incomingMessageProcessor = new IncomingMessageProcessor(tempMessageRepository, tempTagRepository, realMessageParser); IRawMessageProvider rawMessageProvider = new DemoMessageProvider(incomingMessageProcessor); rawMessageProvider.Update(); tempMessageRepository.FilePath = "../../data/demo_offers.json"; tempMessageRepository.SerializeToFile(); }
public TestSerialization() { _singletonTagProvider = new TagRepository(); _singletonTagProvider.FilePath = "data/initial_tags.json"; _singletonTagProvider.InitializeFromFile(); ILocationProvider locationProvider = new MockLocationProvider(); IMessageParser realMessageParser = new RegexMessageParser(_singletonTagProvider, locationProvider); _messageRepository = new MessageRepository(); _tagRepository = new TagRepository(); IncomingMessageProcessor incomingMessageProcessor = new IncomingMessageProcessor(_messageRepository, _tagRepository, realMessageParser); IRawMessageProvider rawMessageProvider = new MockRawMessageProvider(incomingMessageProcessor); rawMessageProvider.Update(); }
public void InitializeTwitterProvider() { //for this test create real objects all the way down the line - so...more of an integration test really // (which is why this is disabled) TagRepository singletonTagProvider = new TagRepository(); singletonTagProvider.FilePath = "data/initial_tags.json"; singletonTagProvider.InitializeFromFile(); ILocationProvider locationProvider = new MockLocationProvider(); RegexMessageParser realMessageParser = new RegexMessageParser(singletonTagProvider, locationProvider); _messageRepository = new MessageRepository(); _tagRepository = new TagRepository(); IncomingMessageProcessor target = new IncomingMessageProcessor(_messageRepository, _tagRepository, realMessageParser); TwitterRawMessageProvider twitterProvider = new TwitterRawMessageProvider((IRawMessageReceiver)target, new MockWebRequestFactory()); twitterProvider.Update(); }
public void TestVariableTypeSerialization() { MessageRepository messageRepository = new MessageRepository(); // need to keep this seperate so as not to mess up other tests TagRepository tempTagRepository = new TagRepository(); //ditto IMessageParser messageParser = new RegexMessageParser(_singletonTagProvider, new MockLocationProvider()); IRawMessageReceiver messageReceiver = new IncomingMessageProcessor(messageRepository, tempTagRepository, messageParser); //add two messages of different types messageReceiver.Notify(DemoData.RawMessages[0]); messageReceiver.Notify(MockData.RawMessages[0]); var openSocialRawMessage = new OpenSocialRawMessage("ooooby", "i have vegetables available in wellington. for #free. #ooooby", "utunga", "", ""); messageReceiver.Notify(openSocialRawMessage); //serialize out string tempFileName = "testOffers.json"; messageRepository.FilePath = tempFileName; messageRepository.SerializeToFile(); // ok great now check that we can deserialize messageRepository = new MessageRepository(); // need to keep this seperate so as not to mess up other tests messageRepository.FilePath = tempFileName; messageRepository.InitializeFromFile(); Assert.AreEqual(messageRepository.MessageCount, 3, "expected to find 3 messages after deserialization"); //TwitterStatusXml twitterStatus = new TwitterStatusXml(); //twitterStatus.CreatedAt = DateUtils.TwitterTimeStampFromUTCDateTime(DateTime.Now); //twitterStatus. = DateUtils.TwitterTimeStampFromUTCDateTime(DateTime.Now); }