コード例 #1
0
        public void Test_ReturnOk_WhenAddressFoundById()
        {
            var   _logger = Mock.Of <ILogger <AddressController> >();
            Datas datas   = new Datas();

            _userRepository.Setup(r => r.GetAddress(1)).Returns(datas.SetAddressForTest);
            _controller = new AddressController(_logger, _userRepository.Object);

            IActionResult result = _controller.GetAddressById(1);

            Assert.IsType <OkObjectResult>(result);
        }
コード例 #2
0
        public void Test_ReturnAddress_WhenAddressFoundById()
        {
            var   _logger = Mock.Of <ILogger <AddressController> >();
            Datas datas   = new Datas();

            _userRepository.Setup(r => r.GetAddress(1)).Returns(datas.SetAddressForTest);
            _controller = new AddressController(_logger, _userRepository.Object);

            IActionResult  result         = _controller.GetAddressById(1);
            OkObjectResult okObjectResult = result as OkObjectResult;
            Address        resturnResult  = okObjectResult.Value as Address;

            Assert.Equal(datas.SetAddressForTest.Id, resturnResult.Id);
            Assert.Equal(datas.SetAddressForTest.UserName, resturnResult.UserName);
            Assert.Equal(datas.SetAddressForTest.AddressLine, resturnResult.AddressLine);
            Assert.Equal(datas.SetAddressForTest.AddressType, resturnResult.AddressType);
            Assert.Equal(datas.SetAddressForTest.City, resturnResult.City);
            Assert.Equal(datas.SetAddressForTest.State, resturnResult.State);
            Assert.Equal(datas.SetAddressForTest.ZipCode, resturnResult.ZipCode);
            Assert.Equal(datas.SetAddressForTest.Country, resturnResult.Country);
        }