コード例 #1
0
        public void CanConvertTemperature_ToString()
        {
            // arrange
            Mock<IWeatherDao> mock = new Mock<IWeatherDao>();
            WeatherService service = new WeatherService(mock.Object);
            Temperature temp = new Temperature()
                                   {
                                       temp = 75,
                                       scale = "F"
                                   };
            mock.Setup(x => x.ConvertToString(It.IsAny<Temperature>())).Returns("75 F");

            // act
            string result = service.convert(temp);

            // assert
            Assert.AreEqual("75 F", result);
        }