public void GET_GetGroups_ReturnsBadRequestIfInvalidParametersSent()
        {
            ActionResult <IEnumerable <Group> > actionResult = controller.Get(invalidGroupsParam);

            Assert.NotNull(actionResult);
            Assert.IsType <ActionResult <IEnumerable <Group> > >(actionResult);
            Assert.IsType <BadRequestObjectResult>(actionResult.Result);
        }
Exemple #2
0
        public void Get_ShouldGetTheAdmissionContestResults()
        {
            //Arrange
            var mockIAdmissionGradesManager = new Mock <IAdmissionGradesManager>();
            var student = new Student {
                AdmissionGrade = 8.5, Cnp = 1, FirstName = "John", LastName = "Doe"
            };
            var students = new List <Student> {
                student
            };

            var result = new Result {
                AdmissionGrade = 8.5, Clasification = Categories.Budget, Cnp = 1, FirstName = "John", LastName = "Doe"
            };
            var expectedResults = new List <Result> {
                result
            };

            mockIAdmissionGradesManager.Setup(manager => manager.GetResults(students)).Returns(expectedResults);
            var resultsController = new ResultsController(mockIAdmissionGradesManager.Object);

            //Act
            var actualResults = resultsController.Get();

            //Assert
            Assert.IsNotNull(actualResults);
            Assert.AreEqual(expectedResults.Count, actualResults.Count);
            mockIAdmissionGradesManager.Verify(mock => mock.GetResults(students), Times.Once());
        }
        public async Task GetExamResults_Return_Expected_Object_Type()
        {
            // Arrange
            // Act
            var results = await resultsController.Get();

            // Assert
            Assert.IsInstanceOf <OkObjectResult>(results);
            var okObjectResult = results as OkObjectResult;

            Assert.True(okObjectResult != null);
            var okResult = okObjectResult.Value as List <ExamSubjectViewModel>;

            Assert.True(okResult.Count() == 2);
        }
        public void Get_ReturnsResults()
        {
            var service = Substitute.For <IResultsService>();

            service.GetResults().Returns(new[]
            {
                new SubjectResult
                {
                    Subject = "Subject",
                    Results = new[] { new Result {
                                          Year = 2020, Grade = "Pass"
                                      } }
                }
            });

            var controller = new ResultsController(service);

            var result = controller.Get();

            Assert.NotEmpty(result);
            Assert.Contains(result, item => item.Subject == "Subject" &&
                            item.Results.Any());
        }
Exemple #5
0
        public void Test_Get()
        {
            //arrange
            HttpRequestMessage request   = GetRequest("aql.eco/Test/all_objects/odata/Results");
            IPrincipal         principal = GetPrincipal();

            ResultsController controller = new ResultsController(_mock.Object)
            {
                Request = request,
                User    = principal
            };

            ODataQueryOptions opts = new ODataQueryOptions <DscQData>(new ODataQueryContext(GetEdmModel(), typeof(DscQData), new ODataPath()), request);


            HttpRequestMessage request1 = GetRequest("aql.eco/Test/all_objects/odata/Results");

            ColumnsController controller1 = new ColumnsController(_mock.Object)
            {
                Request = request1,
                User    = principal
            };

            ODataQueryOptions opts1 = new ODataQueryOptions <DscQColumn>(new ODataQueryContext(GetEdmModel(), typeof(DscQColumn), new ODataPath()), request);

            //act
            IQueryable <DscQData>   result  = controller.Get(DataSource, Path);
            IQueryable <DscQColumn> columns = controller1.Get(DataSource, Path);

            //assert
            Assert.IsNotNull(result);
            Assert.AreEqual(result.Count(), 1);
            Assert.AreEqual(result.FirstOrDefault()?.DynamicProperties?.Count, columns.Count());

            _mock.Verify(d => d.Dispatch <DscQDataQuery, DscQDataQueryResult>(It.IsAny <DscQDataQuery>()), Times.Once());
        }