예제 #1
0
 public void TestInitialize()
 {
     _trackingParser     = TestFactory.CreateTrackingDataParser();
     _summaryParser      = TestFactory.CreateElectionResultsDataParser();
     _repo               = TestFactory.CreateElectionResultsRepository();
     _hostingEnvironment = TestFactory.CreateHostingEnvironment();
     _loggerFactory      = TestFactory.CreateLoggerFactory(LoggerTypes.List);
 }
예제 #2
0
        public async Task GetBallotMatchingPattern_PopulatesRepoWithTestDataIfEmptyWhenInDevelopment()
        {
            _hostingEnvironment = TestFactory.CreateHostingEnvironment("Development");
            _repo.Setup(m => m.ImportBallotStatusTrackingData(It.IsAny <IEnumerable <BallotStatus> >(), It.IsAny <bool>()))
            .Callback <IEnumerable <BallotStatus>, bool>((statuses, onlyIfEmpty) =>
            {
                var list = statuses.ToList();

                Assert.IsTrue(onlyIfEmpty);
                var record = list.Single(s =>
                {
                    return(s.TrackingId == "shipyard JTGDK blood 3YGKK moat 3V9M8 brass BHJPB salami MMDYF pot GQ4W6 chord MFHKD moonshine" &&
                           s.Location == "Precinct 1" &&
                           s.ApproximateCastTime == DateTime.Parse("7/14/2019 13:43"));
                });
            });
            var tp = new TrackingDataParser(_loggerFactory.Object);

            await GetService(trackingParser : tp).GetBallotsMatchingPattern("something");

            _repo.Verify(r => r.GetBallotStatusForTokenPattern("something"), Times.Once);
            _repo.Verify(r => r.ImportBallotStatusTrackingData(It.IsAny <IEnumerable <BallotStatus> >(), true), Times.Once);
        }