//Health_Info public void addHealthEveryRegisterInfo(HealthEveryAddViewModel healthEveryAddViewModel) { var insertInfo = _IMapper.Map <HealthEveryAddViewModel, Health_Info>(healthEveryAddViewModel); healthRepository.Add(insertInfo); healthRepository.SaveChanges();//添加每日健康信息 //var isexist = healthRepository.existhealthInfo(healthEveryAddViewModel); //if (!isexist) //{ // healthRepository.Add(insertInfo); // healthRepository.SaveChanges();//添加每日健康信息 // //hc注释 // //var insertHealth = healthRepository.getByidNumber(insertInfo.IdNumber);//查询插入的 mapper中加密 // //var facultystaff = facultystaffInfoRepository.getByidNumber(insertInfo.IdNumber);//查询白绑定的基础信息 // //var studentInfo = studentInfoRepository.getByidNumber(insertInfo.IdNumber); // //if (facultystaff != null)//不复制键值 // //{ // // insertInfo.facultystaff_InfoId = facultystaff.id; // // healthRepository.Update(insertInfo); // //} // //if (studentInfo != null) // //{ // // insertInfo.Student_InfoId = studentInfo.id; // // healthRepository.Update(insertInfo); // //} // //healthRepository.SaveChanges(); //} }
public void HealthRepository_AddHealthRecord_ValidCall() { //Arrange List <Health> healthList = CreateTestData.GetListOfHealth(); var mockSet = new Mock <DbSet <Health> >() .SetupData(healthList, o => { return(healthList.Single(x => x.Character_id.CompareTo(o.First()) == 0)); }); using (var mockContext = AutoMock.GetLoose()) { var expected = CreateTestData.GetSampleHealth(); var id = Guid.Parse("b346eee6-eba7-4ea7-be2e-911bb9034233"); expected.Character_id = id; mockContext.Mock <CharacterContext>() .Setup(x => x.Set <Health>()).Returns(mockSet.Object); //Act IHealthRepository toTest = mockContext.Create <HealthRepository>(); toTest.Add(expected); var actual = toTest.Get(id); actual.Should().NotBeNull(); expected.Should().NotBeNull(); actual.Should().BeOfType <Health>(); expected.Should().BeOfType <Health>(); actual.Should().BeEquivalentTo(expected); } }