예제 #1
0
        public async void All()
        {
            var mock    = new ServiceMockFacade <ITeacherRepository>();
            var records = new List <Teacher>();

            records.Add(new Teacher());
            mock.RepositoryMock.Setup(x => x.All(It.IsAny <int>(), It.IsAny <int>())).Returns(Task.FromResult(records));
            var service = new TeacherService(mock.LoggerMock.Object,
                                             mock.RepositoryMock.Object,
                                             mock.ModelValidatorMockFactory.TeacherModelValidatorMock.Object,
                                             mock.BOLMapperMockFactory.BOLTeacherMapperMock,
                                             mock.DALMapperMockFactory.DALTeacherMapperMock,
                                             mock.BOLMapperMockFactory.BOLRateMapperMock,
                                             mock.DALMapperMockFactory.DALRateMapperMock);

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

            response.Should().HaveCount(1);
            mock.RepositoryMock.Verify(x => x.All(It.IsAny <int>(), It.IsAny <int>()));
        }
예제 #2
0
        public void testAddStandaloneTeacher()
        {
            Assert.Null(serv.GetByUserName(USERNAME));
            // Arrange
            int count = serv.All().Count();


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

            if (result.Succeeded)
            {
                this.userManager.AddToRole(teacherUser.Id, GlobalConstants.TeacherRoleName);
            }
            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(teacherUser);
            Assert.Null(serv.GetByUserName(USERNAME));
        }