public void HomeControllerIndexTest()
        {
            var expectedHomeViewModel = new LaborHomeViewModel
            {
                Modules = new List <Module>
                {
                    new Module {
                        Name = "Labor", Description = "Labor QS", ActionName = "Index", ControllerName = "LaborHome", Visible = true, AreaName = "Labor"
                    },
                    new Module
                    {
                        Name           = "Einstellungen",
                        Description    = "Einstellungen für die Shell",
                        ActionName     = "Index",
                        ControllerName = "Settings",
                        Visible        = true,
                        AreaName       = ""
                    }
                }
            };
            var laborHomeService    = MockHelperLaborControllerService.GetLaborHomeService(expectedHomeViewModel);
            var laborHomeController = new LaborHomeController(new NLogLoggerFactory())
            {
                LaborHomeService = laborHomeService
            };

            var result             = laborHomeController.Index() as ViewResult;
            var laborHomeViewModel = (LaborHomeViewModel)result?.ViewData.Model;

            Assert.Equal(expectedHomeViewModel, laborHomeViewModel);
        }
        public void CreateFailTest()
        {
            var babyDiaperRetentionService = MockHelperLaborControllerService.GetBabyDiaperRetentionService(new BabyDiaperRetentionEditViewModel());
            var controller = new BabyDiaperRetentionController(new NLogLoggerFactory())
            {
                BabyDiaperRetentionService = babyDiaperRetentionService
            };
            var result = controller.Create();

            Assert.IsType(typeof(HttpNotFoundResult), result);
        }
        public void HomeControllerIndexViewTest()
        {
            var laborHomeService    = MockHelperLaborControllerService.GetLaborHomeService(new LaborHomeViewModel());
            var laborHomeController = new LaborHomeController(new NLogLoggerFactory())
            {
                LaborHomeService = laborHomeService
            };

            var result = laborHomeController.Index() as ViewResult;

            Assert.Equal("Index", result?.ViewName);
        }
        public void CreateReturnsCorrectViewTest()
        {
            var viewModel = new BabyDiaperRetentionEditViewModel
            {
                TestValueId = -1,
                TestSheetId = 5
            };
            var babyDiaperRetentionService = MockHelperLaborControllerService.GetBabyDiaperRetentionService(viewModel);
            var controller = new BabyDiaperRetentionController(new NLogLoggerFactory())
            {
                BabyDiaperRetentionService = babyDiaperRetentionService
            };
            var result = controller.Create(5) as ViewResult;

            Assert.Equal("Edit", result?.ViewName);
        }
        public void EditTest()
        {
            var viewModel = new BabyDiaperRetentionEditViewModel
            {
                TestValueId = -1,
                TestSheetId = 5
            };
            var babyDiaperRetentionService = MockHelperLaborControllerService.GetBabyDiaperRetentionService(viewModel);
            var controller = new BabyDiaperRetentionController(new NLogLoggerFactory())
            {
                BabyDiaperRetentionService = babyDiaperRetentionService
            };
            var result       = controller.Edit(5) as ViewResult;
            var newViewModel = (BabyDiaperRetentionEditViewModel)result?.ViewData.Model;

            Assert.Equal(viewModel, newViewModel);
        }
        public void SaveTest()
        {
            var testVaule = new TestValue
            {
                TestValueId = 4,
                TestSheetId = 5
            };
            var babyDiaperRetentionService = MockHelperLaborControllerService.GetBabyDiaperRetentionServiceForDeleteAndSave(testVaule);
            var controller = new BabyDiaperRetentionController(new NLogLoggerFactory())
            {
                BabyDiaperRetentionService = babyDiaperRetentionService
            };

            var result = controller.Save(new BabyDiaperRetentionEditViewModel()) as RedirectToRouteResult;

            Assert.NotNull(result);
            Assert.Equal("Edit", result.RouteValues["action"]);
            Assert.Equal("LaborCreatorBaby", result.RouteValues["controller"]);
            Assert.Equal("Labor", result.RouteValues["area"]);
            Assert.Equal(5, result.RouteValues["id"]);
        }