Ejemplo n.º 1
0
        public void GetPrediction_With_Date_Supplied()
        {
            //Arrange
            //date is in September
            string date       = "2020-09-14";
            var    controller = new PredictionController(MockWeatherEngine);

            //Act
            IHttpActionResult actionResult = controller.Get(date);
            var contentResult = actionResult as OkNegotiatedContentResult <RainfallResultViewModel>;

            //Assert
            Assert.IsNotNull(contentResult);
            Assert.IsNotNull(contentResult.Content);
            Assert.AreEqual(MockRainfallResultViewModel1.MeanPrcp, contentResult.Content.MeanPrcp);
            Assert.AreEqual(MockRainfallResultViewModel1.StdDev, contentResult.Content.StdDev);

            //Arrange
            //date is in January
            date = "01-31-2021";

            //Act
            actionResult  = controller.Get(date);
            contentResult = actionResult as OkNegotiatedContentResult <RainfallResultViewModel>;

            //Assert
            Assert.IsNotNull(contentResult);
            Assert.IsNotNull(contentResult.Content);
            Assert.AreEqual(MockRainfallResultViewModel2.MeanPrcp, contentResult.Content.MeanPrcp);
            Assert.AreEqual(MockRainfallResultViewModel2.StdDev, contentResult.Content.StdDev);
        }
Ejemplo n.º 2
0
        public void GetPrediction_With_Invalid_Date_Supplied()
        {
            //Arrange
            string date       = "2020-02-30";
            var    controller = new PredictionController(MockWeatherEngine);

            // Act
            IHttpActionResult actionResult = controller.Get(date);

            // Assert
            Assert.AreEqual(actionResult.ToString(), "System.Web.Http.Results.BadRequestErrorMessageResult");
            Console.WriteLine(actionResult);
        }
Ejemplo n.º 3
0
        public void GetPrediction_No_Date_Supplied()
        {
            //Arrange
            var controller = new PredictionController(MockWeatherEngine);

            // Act
            IHttpActionResult actionResult = controller.Get();
            var contentResult = actionResult as OkNegotiatedContentResult <RainfallResultViewModel>;

            // Assert
            Assert.IsNotNull(contentResult);
            Assert.IsNotNull(contentResult.Content);

            //since current date varies, we will just assert that we have some values for mean and std
            Assert.IsTrue(contentResult.Content.MeanPrcp > 0);
            Assert.IsTrue(contentResult.Content.StdDev > 0);
        }
Ejemplo n.º 4
0
 public void TestController()
 {
     PredictionController.Get();
     Assert.Pass();
 }