public async Task GetTest_200OK()
        {
            _mockForecastService.Setup(x => x.GetWeatherForecastsAsync())
            .ReturnsAsync(new[]
            {
                new WeatherForecast {
                    Id = 1, Date = new DateTimeOffset(new DateTime(2000, 1, 1)), Summary = "s1", TemperatureC = 0
                },
                new WeatherForecast {
                    Id = 2, Date = new DateTimeOffset(new DateTime(2000, 2, 1)), Summary = "s2", TemperatureC = 1
                },
                new WeatherForecast {
                    Id = 3, Date = new DateTimeOffset(new DateTime(2000, 3, 1)), Summary = "s3", TemperatureC = 2
                },
            });
            var r = await _target.Get();

            Assert.Equal(3, r.Value.Count());

            var firstElement = r.Value.ElementAt(0);

            Assert.True(firstElement.Date == new DateTime(2000, 1, 1) &&
                        firstElement.Summary == "s1" &&
                        firstElement.TemperatureC == 0);
            var secondElement = r.Value.ElementAt(1);

            Assert.True(secondElement.Date == new DateTime(2000, 2, 1) &&
                        secondElement.Summary == "s2" &&
                        secondElement.TemperatureC == 1);
            var thirdElement = r.Value.ElementAt(2);

            Assert.True(thirdElement.Date == new DateTime(2000, 3, 1) &&
                        thirdElement.Summary == "s3" &&
                        thirdElement.TemperatureC == 2);
        }
        public void Get_WhenCalled_ReturnsCollection()
        {
            var result = _controller.Get();
            int count  = result.ToList().Count;

            Assert.Equal(5, count);
        }
Example #3
0
        public void GetReturnMyName()
        {
            var returnValue1 = controller.Get();
            var returnValue2 = controller.Get();

            Assert.Equal("Sree", "Sree");

            //CollectionAssert
        }
Example #4
0
        public void GetReturnsWeather()
        {
            int count       = 0;
            var returnvalue = controller.Get();

            foreach (var item in returnvalue)
            {
                count++;
            }
            Assert.Equal(5, count);
        }
Example #5
0
        public void WeatherForecastController_GET_Returns5Results()
        {
            int expectedValue = 5;
            IEnumerable <WeatherForecast> result = weatherForecastController.Get();

            Assert.Equal(expectedValue, result.Count());
        }
Example #6
0
        public void GetReturnsMyName()
        {
            var returnValue = controller.Get(1);

            // Equal 判断类型
            Assert.Equal("Test Name", returnValue);
        }
Example #7
0
        public void GetReturnsForecasts()
        {
            var result = controller.Get();

            Assert.True(result != null, "The controller should have returned something.");
            Assert.True(result.Any(), "The controller should have some items in the response.");
        }
Example #8
0
        public void GetReturnsMyName()
        {
            var id          = 1;
            var returnValue = controler.Get(id);

            Assert.Equal("WeatherForecast " + id.ToString(), returnValue.Value);
        }
Example #9
0
        public void GetReturnsIEnumerableWeatherForecast()
        {
            var returnValue = controller.Get();


            Assert.Equal("Less Jackson", returnValue.Value);
        }
Example #10
0
        public void GetForecastsWhenApiKeyIsProvided()
        {
            var controller = new WeatherForecastController(_settings);
            var forecasts  = controller.Get();

            Check.That(forecasts).As("Should return 5 forecasts").CountIs(5);
        }
Example #11
0
        public void GetTest()
        {
            var controller = new WeatherForecastController();
            var result     = controller.Get();

            Assert.IsNotNull(result);
        }
Example #12
0
        public void GEtTemprature()
        {
            var temps = _controller.Get();

            Assert.True(temps.ToList().Count > 0);
            Assert.Equal(5, temps.ToList().Count);
        }
        public void Test_WeatherForecastController_Get()
        {
            var controller = new WeatherForecastController(
                configuration: _configuration,
                logger: _logger,
                sqlConnectionBegonia: _sqlConnectionBegonia,
                aNNOUNCEMENT_GROUPRepository: _aNNOUNCEMENT_GROUPRepository,
                aNNOUNCEMENTRepository: _aNNOUNCEMENTRepository);


            var data  = controller.Get();
            var count = data.Count();

            Check.That(count).IsNotZero();

            /*
             * var announcementProvider = new Mock<IAnnouncementProvider>();
             * announcementProvider
             *  .Setup(x => x.GetList())
             *  .ReturnsAsync(Enumerable.Repeat(new Announcement(),1));
             *
             *
             *
             */
        }
Example #14
0
        public void Test1()
        {
            int expectedCount = 5;
            var arr           = controller.Get();

            Assert.Equal(arr.Count(), expectedCount);
        }
Example #15
0
        public void GIVEN_WeatherForecastController_WHEN_get_THEN_return_correct_List()
        {
            var expected = new WeatherForecast
            {
                Date        = new DateTime(2020, 01, 01),
                Temperature = 1,
                Summary     = "Warm"
            };

            var weatherForecastServiceMock = new Mock <IWeatherForecastService>();

            weatherForecastServiceMock
            .Setup(service => service.Get())
            .Returns(new List <WeatherForecast>
            {
                expected
            });

            var weatherForecastController = new WeatherForecastController(weatherForecastServiceMock.Object);
            var actualResult = weatherForecastController.Get();

            Assert.AreEqual(1, actualResult.Count());
            var actual = actualResult.First();

            Assert.AreEqual(expected.Date, actual.Date);
            Assert.AreEqual(expected.Summary, actual.Summary);
            Assert.AreEqual(expected.Temperature, actual.Temperature);
        }
        public void Test_Get()
        {
            WeatherForecastController wtc = new WeatherForecastController();
            var teststring = wtc.Get();

            Assert.IsTrue(teststring != null);
        }
        public void GetWeatherForecastForNextFiveDays()
        {
            var returnedWeatherForecast = controller.Get();

            Assert.Contains <WeatherForecast>(returnedWeatherForecast,
                                              item => item.Date.Day == DateTime.Today.AddDays(5).Day);
        }
        public void Login_Success()
        {
            ILogin login      = new CustomLogin();
            var    controller = new WeatherForecastController(login);// new Logger<TestMethod>);

            Assert.IsTrue(controller.Get().Count() > 0);
        }
        public void WeatherForecastGet_ReturnsCorrectly()
        {
            var logger = new Mock <ILogger <WeatherForecastController> >();
            WeatherForecastController weatherForecastController = new WeatherForecastController(logger.Object);

            Assert.IsNotNull(weatherForecastController.Get());
        }
Example #20
0
        public void GetReturnsValues()
        {
            var returnValue = controller.Get().ToList();

            Assert.NotNull(returnValue);
            Assert.DoesNotContain("Freezing", returnValue[0].Summary);
        }
Example #21
0
        public void Get()
        {
            WeatherForecastController     controller = new WeatherForecastController(null);
            IEnumerable <WeatherForecast> result     = controller.Get();

            Assert.AreEqual(result.ToList().Count, 10);//注意这里不能对比JSON格式的数据
        }
Example #22
0
        public void Get_Returns_Data()
        {
            var retVal = controller.Get();

            Assert.NotNull(retVal);
            Assert.Equal(5, (retVal as WeatherForecast[]).Length);
        }
Example #23
0
        public void GetReturnAny()
        {
            var result = _con.Get();

            _output.WriteLine(result.ToList().FirstOrDefault()?.Summary);
            Assert.IsType <WeatherForecast[]>(result);
        }
Example #24
0
        public void WeatherForecastGetTest()
        {
            //arrange
            var mockForecasts = new List<WeatherForecastViewModel> { 
                new WeatherForecastViewModel{
                    Date = DateTime.Now,
                    TemperatureC = 30,
                    Summary = "Cool"
                },
                new WeatherForecastViewModel{
                    Date = DateTime.Now,
                    TemperatureC = 55,
                    Summary = "Scorching"
                }
            };

            _mockWeatherForecastList.Object.AddRange(mockForecasts);

            //act
            var result = _weatherForecastController.Get();

            //assert
            var model = Assert.IsAssignableFrom<IEnumerable<WeatherForecastViewModel>>(result);
            Assert.Equal(5,model.ToList().Count);
        }
        public void TestGet()
        {
            _weatherForecastController = new WeatherForecastController();
            var result = _weatherForecastController.Get();

            Assert.IsType <OkObjectResult>(result.Result);
        }
Example #26
0
        public void TestGet()
        {
            WeatherForecastController lController = new WeatherForecastController(null);

            var lResult = lController.Get();

            Assert.AreEqual(6, lResult.ToList().Count);
        }
        public void Controller_Return_5_Elements()
        {
            var controller = new WeatherForecastController(null);

            var items = controller.Get().ToList();

            Assert.Equal(5, items.Count);
        }
Example #28
0
        public void Test()
        {
            var sut = new WeatherForecastController(null);

            var weathers = sut.Get();

            Assert.NotNull(weathers);
        }
Example #29
0
        public void GetWeatherList()
        {
            WeatherForecastController wfc = new WeatherForecastController(null);

            var retValue = wfc.Get();

            Assert.Equal("Test", "Test");
        }
Example #30
0
        public void WeatherForecast_ReturnsMoreThanOne()
        {
            var controller = new WeatherForecastController();
            IEnumerable <WeatherForecast> result = controller.Get();


            Assert.True(result.ToList().Count() > 1);
        }