public void Index_HasCorrectModelType_SpecialityList()
        {
            //Arrange
            SpecialityController controller   = new SpecialityController();
            IActionResult        actionResult = controller.Index();
            ViewResult           indexView    = controller.Index() as ViewResult;

            //Act
            var result = indexView.ViewData.Model;

            //Assert
            Assert.IsInstanceOfType(result, typeof(List <Speciality>));
        }
Exemplo n.º 2
0
        public void Index_Contains_All_Specialities()
        {
            // Arrange (Организация)
            Mock <ISpecialityRepository> mock = new Mock <ISpecialityRepository>();

            mock.Setup(_ => _.Specialities).Returns(new List <Speciality>
            {
                new Speciality {
                    Id = 1, Name = "Spec1", Abbreviation = "S1", Code = "1", DepartmentId = 1
                },
                new Speciality {
                    Id = 2, Name = "Spec2", Abbreviation = "S2", Code = "2", DepartmentId = 2
                },
                new Speciality {
                    Id = 3, Name = "Spec3", Abbreviation = "S3", Code = "3", DepartmentId = 3
                },
                new Speciality {
                    Id = 4, Name = "Spec4", Abbreviation = "S4", Code = "4", DepartmentId = 4
                },
                new Speciality {
                    Id = 5, Name = "Spec5", Abbreviation = "S5", Code = "5", DepartmentId = 5
                }
            });

            // Act (Действие)
            SpecialityController controller = new SpecialityController(mock.Object);

            List <Speciality> result = ((IEnumerable <Speciality>)controller.Index().ViewData.Model).ToList();

            // Assert (Утверждение)
            Assert.AreEqual(result.Count, 5);
            Assert.AreEqual(result[0].Id, 1);
            Assert.AreEqual(result[2].Id, 3);
        }
        public void Index_ReturnsCorrectView_True()
        {
            //Arrange
            SpecialityController controller = new SpecialityController();

            //Act
            ActionResult indexView = controller.Index();

            //Assert
            Assert.IsInstanceOfType(indexView, typeof(ViewResult));
        }