public DeputadoFederalTest() { var builderSettings = new BuilderSettings(); var builder = new Builder(builderSettings); var namer = new RandomValuePropertyNamer( new RandomGenerator(), new ReflectionUtil(), true, DateTime.Now, DateTime.Now.AddDays(10), true, builderSettings); builderSettings.SetPropertyNamerFor <DeputadoFederal>(namer); builderSettings.SetPropertyNamerFor <DeputadoFederalResponse>(namer); builderSettings.SetPropertyNamerFor <DeputadoFederalUltimoStatusResponse>(namer); builderSettings.SetPropertyNamerFor <DeputadoFederalUltimoStatusGabineteResponse>(namer); var random = new Random(); deputadoFederalBuilder = builder.CreateNew <DeputadoFederal>(); deputadoFederalResponseBuilder = builder.CreateNew <DeputadoFederalResponse>() .With(_ => _.ultimoStatus = builder.CreateNew <DeputadoFederalUltimoStatusResponse>().Build()) .With(_ => _.ultimoStatus.urlFoto = FizzWare.NBuilder.Generators.GetRandom.Phrase(15)) .With(_ => _.ultimoStatus.condicaoEleitoral = FizzWare.NBuilder.Generators.GetRandom.Phrase(15)) .With(_ => _.ultimoStatus.gabinete = builder.CreateNew <DeputadoFederalUltimoStatusGabineteResponse>().Build()); }
public NotaFiscalPeriodoTest() { var builderSettings = new BuilderSettings(); var builder = new Builder(builderSettings); var namer = new RandomValuePropertyNamer( new RandomGenerator(), new ReflectionUtil(), true, DateTime.Now, DateTime.Now.AddDays(10), true, builderSettings); builderSettings.SetPropertyNamerFor <DeputadoFederal>(namer); builderSettings.SetPropertyNamerFor <NotaFiscal>(namer); builderSettings.SetPropertyNamerFor <NotaFiscalResponse>(namer); deputadoFederalBuilder = builder.CreateNew <DeputadoFederal>(); notaFiscalBuilder = builder.CreateNew <NotaFiscal>(); notaFiscalResponseBuilder = builder.CreateNew <NotaFiscalResponse>() .With(_ => _.ano = 2019) .With(_ => _.mes = 11); }
public ParticipantSummaryResponseBuilder(UserRole role) { _participant = Builder <ParticipantSummaryResponse> .CreateNew() .With(x => x.Id = Guid.NewGuid()) .With(x => x.Status = ParticipantState.Available) .With(x => x.User_role = role); }
public CallbackEventRequestBuilder() { _request = Builder <CallbackEvent> .CreateNew() .With(x => x.EventId = Guid.NewGuid().ToString()) .With(x => x.TransferFrom = RoomType.WaitingRoom) .With(x => x.TransferTo = RoomType.WaitingRoom) .With(x => x.Reason = "Automated"); }
public ParticipantDetailsResponseBuilder(UserRole role, string caseTypeGroup) { _participant = Builder <ParticipantDetailsResponse> .CreateNew() .With(x => x.Id = Guid.NewGuid()) .With(x => x.Current_status = ParticipantState.Available) .With(x => x.Case_type_group = caseTypeGroup) .With(x => x.User_role = role); }
public PersistenceExtensionTests() { persistenceService = Substitute.For <IPersistenceService>(); listBuilderImpl = Substitute.For <IListBuilderImpl <MyClass> >(); operable = Substitute.For <IOperable <MyClass>, IDeclaration <MyClass> >(); singleObjectBuilder = Substitute.For <ISingleObjectBuilder <MyClass> >(); theList = new List <MyClass>(); }
public SingleObjectBuilderExtensionsTests() { objectBuilder = Substitute.For <IObjectBuilder <MyClass> >(); func = x => x.StringOne = "test"; propertyExpression = x => x.IntGetterOnly; action = x => x.DoSomething(); actionForAll = (x, y) => x.Add(y); actionList = new List <SimpleClass>(); }
public static T Persist <T>(this ISingleObjectBuilder <T> singleObjectBuilder) { var obj = singleObjectBuilder.Build(); IPersistenceService persistenceService = singleObjectBuilder.BuilderSettings.GetPersistenceService(); persistenceService.Create(obj); return(obj); }
public void SetUp() { mocks = new MockRepository(); persistenceService = mocks.DynamicMock<IPersistenceService>(); listBuilderImpl = mocks.DynamicMock<IListBuilderImpl<MyClass>>(); operable = mocks.DynamicMultiMock<IOperable<MyClass>>(typeof(IDeclaration<MyClass>)); singleObjectBuilder = mocks.DynamicMultiMock<ISingleObjectBuilder<MyClass>>(); theList = new List<MyClass>(); }
public void SetUp() { mocks = new MockRepository(); persistenceService = mocks.DynamicMock <IPersistenceService>(); listBuilderImpl = mocks.DynamicMock <IListBuilderImpl <MyClass> >(); operable = mocks.DynamicMultiMock <IOperable <MyClass> >(typeof(IDeclaration <MyClass>)); singleObjectBuilder = mocks.DynamicMultiMock <ISingleObjectBuilder <MyClass> >(); theList = new List <MyClass>(); }
public void SetUp() { mocks = new MockRepository(); objectBuilder = mocks.DynamicMock<IObjectBuilder<MyClass>>(); func = x => x.StringOne = "test"; propertyExpression = x => x.IntGetterOnly; action = x => x.DoSomething(); actionForAll = (x,y) => x.Add(y); actionList = new List<SimpleClass>(); }
public void SetUp() { mocks = new MockRepository(); objectBuilder = mocks.DynamicMock <IObjectBuilder <MyClass> >(); func = x => x.StringOne = "test"; propertyExpression = x => x.IntGetterOnly; action = x => x.DoSomething(); actionForAll = (x, y) => x.Add(y); actionList = new List <SimpleClass>(); }
public static ISingleObjectBuilder <AanbodResponse> WithDefaults( this ISingleObjectBuilder <AanbodResponse> aanbodResponseBuilder, bool hasTuin = false) { if (aanbodResponseBuilder == null) { throw new ArgumentNullException(nameof(aanbodResponseBuilder)); } var objects = new Builder().CreateListOfSize <Object>(5).WithDefaults(hasTuin).Build().ToArray(); return(aanbodResponseBuilder .With(x => x.objects = objects)); }
/// <summary> /// Sets the value of one of the type's private properties /// </summary> public static ISingleObjectBuilder <T> With <T, TProperty>(this ISingleObjectBuilder <T> objectBuilder, Expression <Func <T, TProperty> > property, TProperty value) { var member = ((MemberExpression)property.Body).Member; if (member is FieldInfo) { return(objectBuilder.Do(load => ((FieldInfo)member).SetValue(load, value))); } else { return(objectBuilder.Do(load => ((PropertyInfo)member).SetValue(load, value, null))); } }
public static ISingleObjectBuilder <GetTopMakelaarsResponse> WithDefaults( this ISingleObjectBuilder <GetTopMakelaarsResponse> getTopMakelaarResponseBuilder, bool hasTuin = false) { if (getTopMakelaarResponseBuilder == null) { throw new ArgumentNullException(nameof(getTopMakelaarResponseBuilder)); } var topMakelaars = new Builder().CreateListOfSize <TopMakelaar>(1).WithDefaults().Build().ToList(); return(getTopMakelaarResponseBuilder .With(x => x.topMakelaars = topMakelaars)); }
public void Validate_GiveValidUserData_ShouldNotFail() { // arrange Setup(); ISingleObjectBuilder <User> singleObjectBuilder = Builder <User> .CreateNew(); var user = singleObjectBuilder.WithValidData().Build(); // action var validationResult = _validator.Validate(user); // assert validationResult.Errors.Select(x => x.ErrorMessage).StringJoin().Should().BeEmpty(); validationResult.IsValid.Should().BeTrue(); }
public ParticipantDetailsResponseBuilder(UserRole role, string caseTypeGroup) { _participant = Builder <ParticipantDetailsResponse> .CreateNew() .With(x => x.Id = Guid.NewGuid()) .With(x => x.CurrentStatus = ParticipantState.Available) .With(x => x.CaseTypeGroup = caseTypeGroup) .With(x => x.UserRole = role) .With(x => x.LinkedParticipants = new List <LinkedParticipantResponse> { new LinkedParticipantResponse() { LinkedId = Guid.NewGuid(), Type = LinkedParticipantType.Interpreter } }); }
public ImportacaoTest() { BuilderSetup.ResetToDefaults(); var namer = new RandomValuePropertyNamer( new RandomGenerator(), new ReflectionUtil(), true, DateTime.Now, DateTime.Now.AddDays(10), true, new BuilderSettings()); BuilderSetup.SetPropertyNamerFor <Politico>(namer); BuilderSetup.DisablePropertyNamingFor <Politico, Importacao>(_ => _.Importacao); var random = new Random(); politicoBuilder = Builder <Politico> .CreateNew() .With(_ => _.DT_ELEICAO, DateTime.Now.AddDays(random.NextDouble() + 100).Date) .With(_ => _.DT_NASCIMENTO, DateTime.Now.AddDays(random.NextDouble() + 100).Date); importacaoBuilder = Builder <Importacao> .CreateNew(); }
public static ISingleObjectBuilder <T> WithValidData <T>(this ISingleObjectBuilder <T> value) { return(value.With(ValidData)); }
public static ISingleObjectBuilder <T> WithFactory <T>(this ISingleObjectBuilder <T> objectBuilder, Func <T, int> factory) { return(objectBuilder.WithFactory(factory)); }
public static ISingleObjectBuilder <T> WithConstructor <T>(this ISingleObjectBuilder <T> objectBuilder, Func <T> constructor) { return(objectBuilder.WithFactory(constructor)); }
/// <summary> /// Performs an action for each item in a list. /// </summary> public static ISingleObjectBuilder <T> DoForAll <T, U>(this ISingleObjectBuilder <T> objectBuilder, Action <T, U> func, IList <U> list) { ((IObjectBuilder <T>)objectBuilder).DoMultiple(func, list); return(objectBuilder); }
/// <summary> /// Performs an action on the type. /// Overloads With to provide a better syntax in some situations. /// </summary> public static ISingleObjectBuilder <T> And <T>(this ISingleObjectBuilder <T> objectBuilder, Action <T> func) { return(Do(objectBuilder, func)); }
/// <summary> /// Sets the value of one of the type's public properties. /// Overloads With to provide a better syntax in some situations. /// </summary> public static ISingleObjectBuilder <T> And <T, TFunc>(this ISingleObjectBuilder <T> objectBuilder, Func <T, TFunc> func) { return(With(objectBuilder, func)); }
/// <summary> /// Performs an action on the type. /// </summary> public static ISingleObjectBuilder <T> Do <T>(this ISingleObjectBuilder <T> objectBuilder, Action <T> func) { ((IObjectBuilder <T>)objectBuilder).Do(func); return(objectBuilder); }
/// <summary> /// Sets the value of the constructor to be used to build the type /// </summary> public static ISingleObjectBuilder <T> WithConstructor <T>(this ISingleObjectBuilder <T> objectBuilder, Expression <Func <T, int> > constructor) { ((IObjectBuilder <T>)objectBuilder).WithConstructor(constructor); return(objectBuilder); }
/// <summary> /// Sets the value of one of the type's public properties /// </summary> public static ISingleObjectBuilder <T> With <T, TFunc>(this ISingleObjectBuilder <T> objectBuilder, Func <T, TFunc> func) { ((IObjectBuilder <T>)objectBuilder).With(func); return(objectBuilder); }
public static ISingleObjectBuilder <T> WithConstructorArgs <T>(this ISingleObjectBuilder <T> objectBuilder, params object[] args) { ((IObjectBuilder <T>)objectBuilder).WithConstructorArgs(args); return(objectBuilder); }
/// <summary> /// Sets the value of one of the type's private properties or readonly fields /// Overloads With to provide a better syntax in some situations. /// </summary> public static ISingleObjectBuilder <T> And <T, TProperty>(this ISingleObjectBuilder <T> objectBuilder, Expression <Func <T, TProperty> > property, TProperty value) { return(With(objectBuilder, property, value)); }
/// <summary> /// Sets the value of the constructor to be used to build the type /// </summary> public static ISingleObjectBuilder <T> WithFactory <T>(this ISingleObjectBuilder <T> objectBuilder, Func <T> factory) { ((IObjectBuilder <T>)objectBuilder).WithFactory(factory); return(objectBuilder); }
public static ISingleObjectBuilder WithArguments(this ISingleObjectBuilder objectBuilder, Action <ParameterQueryString> arguments) { ((IObjectBuilder)objectBuilder).WithArguments(arguments); return(objectBuilder); }
public static T BuildNew <T>(this ISingleObjectBuilder <T> builder) where T : ModelBase, new() { return(builder.With(c => c.Id = 0).Build()); }