Exemple #1
0
        public void getClass()
        {
            // Arrange
            ClassController controller = new ClassController();

            var actResult = controller.Get(1);
            // Act
            var result = actResult as OkNegotiatedContentResult <Class>;

            // Assert
            Assert.IsNotNull(result);
            Assert.IsTrue(result.Content.ID == 1);
        }
Exemple #2
0
        public void GetOneById_WhereIdExists_DoesNotReturnNull([Values(1, 2)] int idToRetrieve)
        {
            // Arrange
            var expected = _mockClassList.FirstOrDefault(x => x.ClassId == idToRetrieve);

            Mock.Arrange(() => _classService.Get(idToRetrieve))
            .Returns(_mockClassList.FirstOrDefault(x => x.ClassId == idToRetrieve))
            .OccursOnce();
            var classController = new ClassController(_classService);

            //// Act
            var result = (OkNegotiatedContentResult <ClassDto>)classController.Get(idToRetrieve);

            var actualResult = result.Content;


            //Assert
            Mock.Assert(_classService);
            Assert.That(actualResult, Is.EqualTo(expected));
        }