public void TestIndexViewWithNoLogin()
        {
            //AAA Arrange, Act and Assert
            //Arrange
            var controller = new BakeriesController();

            //Act and assert
            Assert.ThrowsException
            <NullReferenceException>
                (() => controller.Index());
        }
        public void TestIndexViewWithEmptyLogin()
        {
            //Arrange
            var controller = new BakeriesController();

            controller.UserName = string.Empty;

            //Act and Assert
            Assert.ThrowsException
            <NullReferenceException>
                (() => controller.Index());
        }
        public void TestIndexViewWithLogin()
        {
            //Arrange
            var controller = new BakeriesController();

            controller.UserName = "******";

            //Act
            var result = controller.Index() as ViewResult;

            //Assert
            var bakeries =
                (IEnumerable <Bakery>)result.ViewData.Model;
            var count = 0;

            foreach (var bakery in bakeries)
            {
                count++;
            }
            Assert.AreEqual <int>(3, count);
        }