コード例 #1
0
ファイル: UnitTest1.cs プロジェクト: hebert26/MVC.5
        public void WhenNothingHasHappenedTotalAndGoalAreZero()
        {
            var proteinTrackingService = Mock.Create<IProteinTrackingService>();

            ProteinTrackerController controller = new ProteinTrackerController(proteinTrackingService);

            ViewResult result = controller.Index() as ViewResult;

            Assert.AreEqual(0, result?.ViewBag.Total);
            Assert.AreEqual(0, result?.ViewBag.Goal);
        }
コード例 #2
0
ファイル: UnitTest1.cs プロジェクト: hebert26/MVC.5
        public void WhenTotalIsNotZero_and_AddProtein()
        {
            var proteinTrackingService = Mock.Create<IProteinTrackingService>();

            proteinTrackingService.Total = 10;


            ProteinTrackerController controller = new ProteinTrackerController(proteinTrackingService);

            ViewResult result = controller.AddProtein(15) as ViewResult;

            Assert.AreEqual(25, result?.ViewBag.Total);
            Assert.AreEqual(0, result?.ViewBag.Goal);
        }