public async Task Get_WhenCalled_ReturnsOkResultAsync()
        {
            // Act
            var okResult = await studentsController.GetSubjects();

            // Assert
            Assert.IsType <OkObjectResult>(okResult.Result);
        }
        public async System.Threading.Tasks.Task GetAllSubjectsSuccesfull()
        {
            var context = TestingUtilities.CreateInMemoryDatabaseContext("TestDatabaseGetSubjects");
            var data    = new List <Subject>
            {
                new Subject()
                {
                    Id = 1
                },
                new Subject()
                {
                    Id = 2
                }
            };

            context.Subjects.AddRange(data);
            context.SaveChanges();
            var controller = new SubjectsController(context);
            //Act
            var result = await controller.GetSubjects();

            var resValue  = result.Value;
            var resResult = result.Result;

            //Assert
            Assert.Equal(data, resValue);
        }
        public void GetSubjects_ReturnsSubjectDtoList()
        {
            // arrange
            FakeSubjectOrderRepository fake = new FakeSubjectOrderRepository();
            SubjectsController         sc   = new SubjectsController(fake);

            // act
            var result = sc.GetSubjects(null).Result as OkObjectResult;

            // Assert
            Assert.IsInstanceOf <List <SubjectDto> >(result.Value);
        }
        public void GetSubjects_ReturnsOkResult()
        {
            // arrange
            FakeSubjectOrderRepository fake = new FakeSubjectOrderRepository();
            SubjectsController         sc   = new SubjectsController(fake);

            // act
            var result = sc.GetSubjects(null);

            // assert
            Assert.IsInstanceOf <OkObjectResult>(result.Result);
        }
        public void GetSubjects_ReturnsAllItems()
        {
            // arrange
            FakeSubjectOrderRepository fake = new FakeSubjectOrderRepository();
            SubjectsController         sc   = new SubjectsController(fake);

            // act
            var result = sc.GetSubjects(null).Result as OkObjectResult;
            List <SubjectDto> subjects = result.Value as List <SubjectDto>;

            // assert
            Assert.AreEqual(5, subjects.Count);
        }
        public void DeleteSubject_ValidSubject_ReturnsNoContext()
        {
            // arrange
            FakeSubjectOrderRepository fake = new FakeSubjectOrderRepository();
            SubjectsController         sc   = new SubjectsController(fake);

            // act
            var deleteResult           = sc.DeleteSubject(1);
            var getresult              = sc.GetSubjects(null).Result as OkObjectResult;
            List <SubjectDto> subjects = getresult.Value as List <SubjectDto>;

            // assert
            Assert.IsInstanceOf <NoContentResult>(deleteResult);
            Assert.AreEqual(4, subjects.Count);
        }
        public async Task GetSubjects_WithSujectId_RetunrsSubjectsList()
        {
            //Arrange
            var userId   = AutoFaker.Generate <int>();
            var subjects = AutoFaker.Generate <List <Subject> >();

            _subjectService.Setup(x => x.GetSubjects(It.IsAny <int>()))
            .ReturnsAsync(subjects);

            //Act
            var result = await _sut.GetSubjects(userId);

            //Assert
            result.Should().BeOfType <OkObjectResult>();
            ((OkObjectResult)result).StatusCode.Should().Be(StatusCodes.Status200OK);
            ((OkObjectResult)result).Value.Should().BeEquivalentTo(subjects);
        }