コード例 #1
0
        public void CreateFailTest()
        {
            var babyDiaperRewetService = MockHelperLaborControllerService.GetBabyDiaperRewetService(new BabyDiaperRewetEditViewModel());
            var controller             = new BabyDiaperRewetController(new NLogLoggerFactory())
            {
                BabyDiaperRewetService = babyDiaperRewetService
            };
            var result = controller.Create();

            Assert.IsType(typeof(HttpNotFoundResult), result);
        }
コード例 #2
0
        public void CreateReturnsCorrectViewTest()
        {
            var viewModel = new BabyDiaperRewetEditViewModel
            {
                TestValueId = -1,
                TestSheetId = 5
            };
            var babyDiaperRewetService = MockHelperLaborControllerService.GetBabyDiaperRewetService(viewModel);
            var controller             = new BabyDiaperRewetController(new NLogLoggerFactory())
            {
                BabyDiaperRewetService = babyDiaperRewetService
            };
            var result = controller.Create(5) as ViewResult;

            Assert.Equal("Edit", result?.ViewName);
        }
コード例 #3
0
        public void CreateTest()
        {
            var viewModel = new BabyDiaperRewetEditViewModel
            {
                TestValueId = -1,
                TestSheetId = 5
            };
            var babyDiaperRewetService = MockHelperLaborControllerService.GetBabyDiaperRewetService(viewModel);
            var controller             = new BabyDiaperRewetController(new NLogLoggerFactory())
            {
                BabyDiaperRewetService = babyDiaperRewetService
            };
            var result       = controller.Create(5) as ViewResult;
            var newViewModel = (BabyDiaperRewetEditViewModel)result?.ViewData.Model;

            Assert.Equal(viewModel, newViewModel);
        }