public void Init() { this.dbHelper = new Mock<IGeneralDataHelper>(); this.dbHelper.Setup(o => o.Create(It.IsAny<ApplicationForm>())).Callback<ApplicationForm>(o => this.callbackVal = o); this.dbHelper.Setup(o => o.Update(It.IsAny<ApplicationForm>())).Callback<ApplicationForm>(o => this.callbackVal = o); this.dbHelper.Setup(o => o.Get(It.IsAny<Expression<Func<ApplicationForm, bool>>>())) .Returns(new ApplicationForm()); this.formsLogic = new FormsCommonLogic(this.dbHelper.Object); }
public void ErrorCountTest() { ApplicationForm appF = new ApplicationForm { IsExtension = true }; this.dbMock.Setup(o => o.Get<ApplicationForm>(It.IsAny<Expression<Func<ApplicationForm, bool>>>())) .Returns<Expression<Func<ApplicationForm, bool>>>(predicate => appF); this.model.DurationOfStudies = string.Empty; var result = this.validator.Validate(this.model); result.IsValid.Should().Be(false); result.Errors.Count.Should().Be(1); }
public void ValidModelTest() { ApplicationForm appF = new ApplicationForm { IsExtension = true }; this.dbMock.Setup(o => o.Get<ApplicationForm>(It.IsAny<Expression<Func<ApplicationForm, bool>>>())) .Returns<Expression<Func<ApplicationForm, bool>>>(predicate => appF); var result = this.validator.Validate(this.model); result.IsValid.Should().Be(true); }