コード例 #1
0
ファイル: TestStudentQuery.cs プロジェクト: Alok-01/Triangle
        public void Test_FindStudentbyIdAndCheckByName(int id, string name)
        {
            var mockStudenteRepository = new Mock <IStudenteRepository>();
            var mockBusinessService    = new Mock <IStudentBusinessService>();
            var mockstudent            = new List <StudentEntity>
            {
                new StudentEntity {
                    StudentId = 1, StudentRollNumber = "B10", StudentName = "John", StudentFatherName = "Paul", StudentMotherName = "Lena"
                },
                new StudentEntity {
                    StudentId = 2, StudentRollNumber = "C10", StudentName = "Jack", StudentFatherName = "Pundit", StudentMotherName = "Kaul"
                },
                new StudentEntity {
                    StudentId = 3, StudentRollNumber = "X10", StudentName = "Om", StudentFatherName = "Karma", StudentMotherName = "Sadhana"
                }
            };

            IStudentEntity studentEntity = mockstudent.Where(s => s.StudentId == id).SingleOrDefault();

            mockBusinessService.Setup(d => d.GetStudentById(id)).Returns(studentEntity);

            if (id == 3)
            {
                Assert.NotEqual(name, mockBusinessService.Object.GetStudentById(id).StudentName);
            }
            else
            {
                Assert.Equal(name, mockBusinessService.Object.GetStudentById(id).StudentName);
            }
        }
コード例 #2
0
ファイル: TestStudentQuery.cs プロジェクト: Alok-01/Triangle
        public void Test_FinStudentbyId(int id)
        {
            var mockStudenteRepository = new Mock <IStudenteRepository>();
            var mockBusinessService    = new Mock <IStudentBusinessService>();
            var mockstudent            = new List <StudentEntity>
            {
                new StudentEntity {
                    StudentId = 1, StudentRollNumber = "B10", StudentName = "John", StudentFatherName = "Paul", StudentMotherName = "Lena"
                },
                new StudentEntity {
                    StudentId = 2, StudentRollNumber = "C10", StudentName = "Jack", StudentFatherName = "Pundit", StudentMotherName = "Kaul"
                }
            };

            IStudentEntity studentEntity = mockstudent.Where(s => s.StudentId == id).SingleOrDefault();

            mockBusinessService.Setup(d => d.GetStudentById(id)).Returns(studentEntity);
            Assert.Equal(id.ToString(), mockBusinessService.Object.GetStudentById(id).StudentId.ToString());
        }
コード例 #3
0
ファイル: StudentDbService.cs プロジェクト: Alok-01/Triangle
        /// <summary>
        /// Insert or Update Student
        /// </summary>
        /// <param name="studentEntity">The Student Entity</param>
        /// <returns> entity id</returns>
        //public static int InsertUpdate(IStudentEntity studentEntity)
        public static IStudentEntity InsertUpdate(IStudentEntity studentEntity)
        {
            try
            {
                using var comm   = GenericDataAccess.CreateCommand(Connections.Configuration.StudentV4Db);
                comm.CommandText = "Student_InsertUpdate";
                comm.AddParamWithValue("@StudentId", DbType.Int32, studentEntity.StudentId);
                comm.AddParamWithValue("@StudentName", DbType.String, studentEntity.StudentName);
                comm.AddParamWithValue("@StudentRollNumber", DbType.String, studentEntity.StudentRollNumber);
                comm.AddParamWithValue("@StudentFatherName", DbType.String, studentEntity.StudentFatherName);
                comm.AddParamWithValue("@StudentMotherName", DbType.String, studentEntity.StudentMotherName);
                var resu = GenericDataAccess.ExecuteNonQuery(comm);
                studentEntity.StudentId = resu;
            }
            catch (Exception ex)
            {
                DataErrorLogger.LogError(ex);
                throw ex;
            }

            return(studentEntity);
        }
コード例 #4
0
 public ValuesRepository(IStudentEntity entity)
 {
     _entity = entity;
 }
コード例 #5
0
        /// <summary>
        /// Create Student
        /// </summary>
        /// <param name="studentEntity">Student Entity</param>
        /// <returns>Entity Id</returns>
        //public int CreateStudent(IStudentEntity studentEntity)
        public async Task <IStudentEntity> CreateStudent(IStudentEntity studentEntity)
        {
            var result = StudentDbService.InsertUpdate(studentEntity);

            return(result);
        }
コード例 #6
0
        /// <summary>
        /// Create Student
        /// </summary>
        /// <param name="studentEntity">Student Entity</param>
        /// <returns>Entity Id</returns>
        //public int Createstudent(IStudentEntity studentEntity)
        public async Task <IStudentEntity> Createstudent(IStudentEntity studentEntity)
        {
            var result = await _studenteRepository.CreateStudent(studentEntity);

            return(result);
        }