Exemplo n.º 1
0
        public async void All()
        {
            var mock    = new ServiceMockFacade <IStudentRepository>();
            var records = new List <Student>();

            records.Add(new Student());
            mock.RepositoryMock.Setup(x => x.All(It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult(records));
            var service = new StudentService(mock.LoggerMock.Object,
                                             mock.RepositoryMock.Object,
                                             mock.ModelValidatorMockFactory.StudentModelValidatorMock.Object,
                                             mock.BOLMapperMockFactory.BOLStudentMapperMock,
                                             mock.DALMapperMockFactory.DALStudentMapperMock);

            List <ApiStudentResponseModel> response = await service.All();

            response.Should().HaveCount(1);
            mock.RepositoryMock.Verify(x => x.All(It.IsAny <int>(), It.IsAny <int>()));
        }
        // GET: Students
        public ActionResult All()
        {
            var student = _studentService.All();

            return(View("Index", student));
        }
 // GET: api/Students
 public async Task <ICollection <StudentResultViewModel> > GetStudents()
 {
     return((await _students.All())
            .Select(s => (StudentResultViewModel)s)
            .ToList());
 }
Exemplo n.º 4
0
        public void testAddStandaloneStudent()
        {
            Assert.Null(serv.GetByUserName(USERNAME));
            // Arrange
            int count = serv.All().Count();


            // Act
            var result = this.userManager.Create(studentUser, "testpassword");

            if (result.Succeeded)
            {
                this.userManager.AddToRole(studentUser.Id, GlobalConstants.StudentRoleName);
            }
            MichtavaResult res = serv.Add(entity);

            // Assert
            Assert.AreEqual(count + 1, serv.All().Count());
            Assert.NotNull(serv.GetByUserName(USERNAME));
            Assert.True(res is MichtavaSuccess);
            Assert.True(serv.HardDelete(entity) is MichtavaSuccess);
            this.userManager.Delete(studentUser);
            Assert.Null(serv.GetByUserName(USERNAME));
        }