public void Delete_A_Single_Entity_Using_Delete() { //arrange var bodyParameter = new EqualsBinaryOperatorParameters ( new MemberSelectorOperatorParameters("FullName", new ParameterOperatorParameters(parameterName)), new ConstantOperatorParameters("Carson Alexander") ); //act DoTest <StudentModel, Student> ( bodyParameter, null, null, parameterName, (StudentModel studentModel, ISchoolRepository repository) => { IExpressionParameter expressionParameter = GetFilterParameter <StudentModel>(bodyParameter, parameterName); Expression <Func <StudentModel, bool> > expression = ProjectionOperations <StudentModel, Student> .GetFilter ( serviceProvider.GetRequiredService <IMapper>().MapToOperator(expressionParameter) ); PersistenceOperations <StudentModel, Student> .Delete(repository, expression); }, returnValue => { Assert.Null(returnValue); }, "$it => ($it.FullName == \"Carson Alexander\")" ); }
void DoTest <TModel, TData>(IExpressionParameter bodyParameter, IExpressionParameter queryFunc, SelectExpandDefinitionParameters expansion, string parameterName, Action <TModel, ISchoolRepository> update, Action <TModel> assert, string expectedExpressionString) where TModel : LogicBuilder.Domain.BaseModel where TData : LogicBuilder.Data.BaseData { //arrange IMapper mapper = serviceProvider.GetRequiredService <IMapper>(); ISchoolRepository repository = serviceProvider.GetRequiredService <ISchoolRepository>(); IExpressionParameter expressionParameter = GetFilterParameter <TModel>(bodyParameter, parameterName); TestExpressionString(); TestReturnValue(); void TestReturnValue() { //act TModel returnValue = ProjectionOperations <TModel, TData> .Get ( repository, mapper, expressionParameter, queryFunc, expansion ); update(returnValue, repository); returnValue = ProjectionOperations <TModel, TData> .Get ( repository, mapper, expressionParameter, queryFunc, expansion ); //assert assert(returnValue); } void TestExpressionString() { //act Expression <Func <TModel, bool> > expression = ProjectionOperations <TModel, TData> .GetFilter ( mapper.MapToOperator(expressionParameter) ); //assert if (!string.IsNullOrEmpty(expectedExpressionString)) { AssertFilterStringIsCorrect(expression, expectedExpressionString); } } }