コード例 #1
0
        public void testProcessWithExistingFilePath()
        {
            string   filePath     = "abc.csv";
            DateTime date         = DateTime.Now;
            string   expectedJson = "json{}";

            Mock <Jester>    mockJester    = new Mock <Jester>();
            Mock <Ingester>  mockIngester  = new Mock <Ingester>();
            Mock <Outgester> mockOutgester = new Mock <Outgester>();
            Mock <HistoricalPrecipitation> precipitation = new Mock <HistoricalPrecipitation>();

            mockJester.Setup(x => x.predict(date)).Returns(() => precipitation.Object);
            mockOutgester.Setup(outg => outg.serialize(precipitation.Object)).Returns(expectedJson);
            mockIngester.Setup(ing => ing.ingest(It.IsAny <string>())).Throws(new AssertionException(""));

            DigestionProcess processor = new DigestionProcess(mockJester.Object, mockIngester.Object, mockOutgester.Object);

            processor.LastFilePath = filePath;
            string actualJson = processor.process(date, filePath);

            Assert.AreEqual(expectedJson, actualJson);
            mockJester.Verify(jes => jes.predict(date));
            mockOutgester.Verify(outg => outg.serialize(precipitation.Object));
            mockIngester.Verify(ing => ing.ingest(filePath), Times.Never);
        }
コード例 #2
0
        public void IntegrationTestSuccess()
        {
            string           filePath = "../../../../data.csv";
            DigestionProcess process  = new DigestionProcess();
            string           json     = process.process(DateTime.Now, filePath);

            Assert.IsNotEmpty(json);
        }
コード例 #3
0
        public void testProcessNewFilePath()
        {
            string   filePath     = "abc.csv";
            DateTime date         = DateTime.Now;
            string   expectedJson = "json{}";

            Mock <Jester>    mockJester    = new Mock <Jester>();
            Mock <Ingester>  mockIngester  = new Mock <Ingester>();
            Mock <Outgester> mockOutgester = new Mock <Outgester>();
            Mock <HistoricalPrecipitation> precipitation = new Mock <HistoricalPrecipitation>();

            mockJester.Setup(x => x.predict(date)).Returns(() => precipitation.Object);
            mockOutgester.Setup(outg => outg.serialize(precipitation.Object)).Returns(expectedJson);
            mockIngester.Setup(ing => ing.ingest(filePath)).Verifiable();

            DigestionProcess processor  = new DigestionProcess(mockJester.Object, mockIngester.Object, mockOutgester.Object);
            string           actualJson = processor.process(date, filePath);

            Assert.AreEqual(expectedJson, actualJson);
            mockJester.Verify(jes => jes.predict(date));
            mockIngester.Verify(ing => ing.ingest(filePath));
            mockOutgester.Verify(outg => outg.serialize(precipitation.Object));
        }