public void SetUp() { var builderSetup = new BuilderSettings(); reflectionUtil = Substitute.For<IReflectionUtil>(); generator = Substitute.For<IRandomGenerator>(); propertyNamer = new RandomValuePropertyNamer(generator, reflectionUtil, false,builderSetup); }
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 void SetUp() { var builderSetup = new BuilderSettings(); reflectionUtil = Substitute.For <IReflectionUtil>(); generator = Substitute.For <IRandomGenerator>(); propertyNamer = new RandomValuePropertyNamer(generator, reflectionUtil, false, builderSetup); }
public void Configuration_2() { var namer = new RandomValuePropertyNamer(new RandomGenerator(), new ReflectionUtil(), true, DateTime.Now, DateTime.Now.AddDays(10), true); BuilderSetup.SetDefaultPropertyNamer(namer); }
public void SpecifyingADifferentDefaultPropertyNamer() { var builderSetup = new BuilderSettings(); var propertyNamer = new RandomValuePropertyNamer(new RandomGenerator(), new ReflectionUtil(), true, DateTime.Now, DateTime.Now.AddDays(10), true, new BuilderSettings()); builderSetup.SetDefaultPropertyNamer(propertyNamer); var products = new Builder(builderSetup).CreateListOfSize <Product>(10).Build(); products[0].Title.ShouldNotBe("StringOne1"); products[9].Title.ShouldNotBe("StringOne10"); }
public void SpecifyingADifferentDefaultPropertyNamer() { var builderSetup = new BuilderSettings(); var propertyNamer = new RandomValuePropertyNamer(builderSetup); builderSetup.SetDefaultPropertyNamer(propertyNamer); var products = new Builder(builderSetup).CreateListOfSize <Product>(10).Build(); products[0].Title.ShouldNotBe("StringOne1"); products[9].Title.ShouldNotBe("StringOne10"); }
public void SetValuesOfAllIn_ClassWithNullCharConst_CharConstantIsNotSetByNamer() { var propertyNamer = new RandomValuePropertyNamer(); List<MyClassWithCharConst> list = new List<MyClassWithCharConst>() { new MyClassWithCharConst() }; propertyNamer.SetValuesOfAllIn(list); foreach (var item in list) { Assert.That(item.GetNullCharConst(), Is.EqualTo(MyClassWithCharConst.NullCharConst)); Assert.That(item.GetNonNullCharConst(), Is.EqualTo(MyClassWithCharConst.NonNullCharConst)); } Assert.Pass("A System.FieldAccessException was not thrown because NBuilder didn't try to set the value of the constant"); }
public void SetValuesOfAllIn_ClassWithNullCharConst_CharConstantIsNotSetByNamer() { var builderSetup = new BuilderSettings(); var propertyNamer = new RandomValuePropertyNamer(builderSetup); List <MyClassWithCharConst> list = new List <MyClassWithCharConst>() { new MyClassWithCharConst() }; propertyNamer.SetValuesOfAllIn(list); foreach (var item in list) { item.GetNullCharConst().ShouldBe(MyClassWithCharConst.NullCharConst); item.GetNonNullCharConst().ShouldBe(MyClassWithCharConst.NonNullCharConst); } }
public void SetValuesOfAllIn_ClassWithNullCharConst_CharConstantIsNotSetByNamer() { var propertyNamer = new RandomValuePropertyNamer(); List <MyClassWithCharConst> list = new List <MyClassWithCharConst>() { new MyClassWithCharConst() }; propertyNamer.SetValuesOfAllIn(list); foreach (var item in list) { Assert.That(item.GetNullCharConst(), Is.EqualTo(MyClassWithCharConst.NullCharConst)); Assert.That(item.GetNonNullCharConst(), Is.EqualTo(MyClassWithCharConst.NonNullCharConst)); } Assert.Pass("A System.FieldAccessException was not thrown because NBuilder didn't try to set the value of the constant"); }
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(); }
private static void GenerateFizzWare() { // var generator = new UniqueRandomGenerator(); var namer = new RandomValuePropertyNamer(new RandomGenerator(), new ReflectionUtil(), true, DateTime.Now, DateTime.Now.AddDays(5), true); BuilderSetup.SetDefaultPropertyNamer(namer); int sequenceNumber = 1; var products = Builder<Product>.CreateListOfSize(20) .WhereAll() .Have(q => q.Description = "Description") .And(x => x.ProductCode = "AA-" + sequenceNumber++) .Build(); Action<Product> action = new Action<Product>((q) => Console.WriteLine(q.ProductCode)); products.ToList().ForEach(action); }
public void SetUp() { reflectionUtil = Substitute.For <IReflectionUtil>(); generator = Substitute.For <IRandomGenerator>(); propertyNamer = new RandomValuePropertyNamer(generator, reflectionUtil, false); }
public void SetUp() { reflectionUtil = Substitute.For<IReflectionUtil>(); generator = Substitute.For<IRandomGenerator>(); propertyNamer = new RandomValuePropertyNamer(generator, reflectionUtil, false); }
private static void GenerateTestData(IContainer container) { const string LONG_QUESTION = @"1. An anonymous user requests a protected resource 2. In the `AuthorizeRequest` step, the `WSFederationAuthenticationModule` determines that the user is not authorized to access the resource and returns a `401 Not Authorized` 3. In the `EndRequest` step, the `401` is changed to a `302 Redirect` to the Security Token Service 4. The Security Token Service authenticates the user and returns a security token 5. In the `AuthenticateRequest` step, the token is validated, claims transformation takes place and a session is established with a `SessionSecurityToken` as a session cookie 6. Once the session has been established, the `SessionSecurityToken` is sent with each request and the `SessionAuthenticationModule` validates the `SessionSecurityToken` in the `AuthenticateRequest` step"; const string LONG_ANSWER = @" 1. `ClaimsAuthenticationManager` - Reject requests based on missing or invalid identity information 2. URL authorization module - Specify authorization elements in the `Web.config` files <location path='staff'> <system.web> <authorization> <allow roles='Marketing' /> <deny users='*' /> </authorization> </system.web> </location> 3. `ClaimsAuthorizationModule` - Also uses the URL but is claims-based. <modules runAllManagedModulesForAllRequests='true'> <add name='ClaimsAuthorizationModule' type=System.IdentityModel.Services.ClaimsAuthorizationModule, ...' /> </modules> <system.identityModel> <identityConfiguration> <claimsAuthorizationManager type='AuthorizationManager, ...' /> <identityConfiguration> </system.identityModel>"; new AzureInitializer().Initialize(); var config = new HttpConfiguration { DependencyResolver = new StructureMapWebApiResolver(container), }; config.Formatters.JsonFormatter.MediaTypeMappings.Add(new UriPathExtensionMapping("json", "application/json")); config.Formatters.XmlFormatter.MediaTypeMappings.Add(new UriPathExtensionMapping("xml", "application/xml")); WebApiConfig.Configure(config); var server = new HttpServer(config); var client = new HttpClient(server); client.DefaultRequestHeaders.Add(HttpHeaders.X_CLIENT_DATE, DateTime.Now.ToLongDateString()); client.DefaultRequestHeaders.Add(HttpHeaders.X_TEST, "true"); var randomizer = new RandomGenerator(); var namer = new RandomValuePropertyNamer(new RandomGenerator(), new ReflectionUtil(), true, DateTime.Now, DateTime.Now.AddDays(10), true); BuilderSetup.SetDefaultPropertyNamer(namer); var cards = Builder<Card>.CreateListOfSize(10000) .All() .With(x => x.PartitionKey = null) .And(x => x.RowKey = null) .And(x => x.Timestamp = TypeValues.MIN_SQL_DATETIME) .TheFirst(1000) .With(x => x.DeckName = "Foundations of Medicine I (large)") .And(x => x.Question = LONG_QUESTION) .And(x => x.Answer = LONG_ANSWER) .TheNext(1000).With(x => x.DeckName = "Foundations of Medicine II") .TheNext(1000).With(x => x.DeckName = "Human Health & Disease II - Pulmonary") .TheNext(1000).With(x => x.DeckName = "Human Health & Disease II - Cardiovascular") .TheNext(1000).With(x => x.DeckName = "Practice of Medicine III") .TheNext(1000).With(x => x.DeckName = "Human Health & Disease III - Gastrointestinal") .TheNext(1000).With(x => x.DeckName = "Human Health & Disease IV - Multi-systemic Diseases") .TheNext(1000).With(x => x.DeckName = "Analysis of Structures") .TheNext(1000).With(x => x.DeckName = "Aircraft and Rocket Propulsion") .TheNext(1000).With(x => x.DeckName = "Multivariable Feedback Systems") .Build(); foreach(var card in cards) { var response = client.PostAsJsonAsync(TestUrls.CARDS, card).Result; if (!response.IsSuccessStatusCode) break; Thread.Sleep(200); } }