public void StateTest() { var hydrator = new Hydrator<Address>(); var checkme = hydrator.GetSingle(); Assert.IsNotNull(checkme); }
public void SimpleTest() { var hydrator = new Hydrator<Address>().WithCustomGenerator(x=>x.State, new InjectedGenerator()); var checkme = hydrator.GetSingle(); Assert.IsNotNull(checkme); }
public void Seed(SiteDbContext context, int sampleSize) { // Return if there are already suppliers if (context.Suppliers.Any()) return; // Hydrate supplier var hydrator = new Hydrator<Supplier>() .WithAmericanAddress(e => e.Address) .WithAmericanCity(e => e.City) .WithAmericanState(e => e.Region) .WithCustomGenerator(e => e.Country, new CountryGenerator()) .WithCustomGenerator(e => e.ContactName, new ContactNameGenerator()) .WithEmailAddress(e => e.ContactEmail) .WithAmericanPostalCode(e => e.PostalCode, 4) .WithAmericanPhone(e => e.Phone) .WithCustomGenerator(e => e.ContactTitle, new TitleGenerator()) .Ignoring(e => e.CompanyName) .Ignoring(e => e.SupplierId) .Ignoring(e => e.Products) .GetList(sampleSize) .ToList(); // Make sure every company name is unique var usedCompanyNames = new List<string>(); foreach (var supplier in hydrator) { string name; do { name = new CompanyNameGenerator().Generate(); } while (usedCompanyNames.Contains(name)); usedCompanyNames.Add(name); supplier.CompanyName = name; // See if this works supplier.Products = new List<Product>(); // ReSharper disable once LoopCanBePartlyConvertedToQuery foreach (var i in Enumerable.Range(0, 4)) { var product = new Product { ProductName = new CatchPhraseGenerator().Generate(), QuantityPerUnit = new IntegerGenerator() {MaximumValue = 10, MinimumValue = 1}.Generate(), UnitPrice = new IntegerGenerator() { MaximumValue = 200, MinimumValue = 1 }.Generate(), }; // Add Product to supplier supplier.Products.Add(product); } // Add supplier to context context.Suppliers.Add(supplier); } // Save the changes context.SaveChanges(); }
public void SimpleTest() { var hydrator = new Hydrator <Address>().WithCustomGenerator(x => x.State, new InjectedGenerator()); var checkme = hydrator.GetSingle(); Assert.IsNotNull(checkme); }
public void WithUnitedKingdomCountyTest() { var hydrator = new Hydrator <SimpleCustomer>() .WithUnitedKingdomCounty(x => x.placeholderstring); var customer = hydrator.GetSingle(); Assert.IsNotNull(customer.placeholderstring); }
public void PasswordWithInferenceDefaultLength() { var hydrator = new Hydrator <SimpleCustomer>(); var customer = hydrator.GetSingle(); Assert.IsNotNull(customer.Password); Assert.AreEqual(10, customer.Password.Length); }
public void WithWebsite() { var hydrator = new Hydrator <SimpleCustomer>() .WithWebsite(x => x.placeholderstring); var customer = hydrator.GetSingle(); Assert.IsNotNull(customer.placeholderstring); }
public void AlphaNumericWithLength() { var hydrator = new Hydrator<SimpleCustomer>() .WithAlphaNumeric(x => x.placeholderstring, 10); var customer = hydrator.GetSingle(); Assert.IsNotNull(customer.placeholderstring); Assert.AreEqual(10, customer.placeholderstring.Length); }
public void CanGetTrackingNumberBySpecification() { var hydrator = new Hydrator <SimpleCustomer>() .WithTrackingNumber(x => x.TrackingNumber, "usps"); var customer = hydrator.GetSingle(); Assert.IsNotNull(customer.TrackingNumber); }
public void EmailAddressTest() { var hydrator = new Hydrator <SimpleCustomer>(); var customer = hydrator.GetSingle(); Assert.IsNotNull(customer.EmailAddress); Assert.IsTrue(IsEmailAddressValid(customer.EmailAddress)); }
public void CountryCodeTest() { var hydrator = new Hydrator <SimpleCustomer>(); var customer = hydrator.GetSingle(); Assert.IsNotNull(customer.Country); Assert.IsTrue(customer.Country.Length == 2); }
public void TestWebsiteAddress() { var hydrator = new Hydrator <SimpleCustomer>(); var customer = hydrator.GetSingle(); Assert.IsNotNull(customer.homepage); Assert.IsTrue(IsWebsiteAddressValid(customer.homepage)); }
public FriendRepository() { //install-package objectHydrator //Sirve para rellenar de datos clases Default Hydrator <Friend> _friendHydrator = new Hydrator <Friend>(); Friends = _friendHydrator.GetList(50); }
public void StateTest() { var hydrator = new Hydrator <Address>(); var checkme = hydrator.GetSingle(); Assert.IsNotNull(checkme); }
/// <summary> /// Creates a new instance of <see cref="BatchPlanner"/>. /// </summary> /// <param name="compiler">The <see cref="ISqlCompiler"/>.</param> /// <param name="hydrator">The <see cref="Hydrator"/>.</param> public BatchPlanner(ISqlCompiler compiler, Hydrator hydrator) { _compiler = compiler ?? throw new ArgumentNullException(nameof(compiler)); _hydrator = hydrator ?? throw new ArgumentNullException(nameof(hydrator)); _objectShaper = new ObjectShaper(new SqlAstValidator()); _arrayToConnectionConverter = new ArrayToConnectionConverter(); }
public void WithAmericanAddressTest() { var hydrator = new Hydrator <SimpleCustomer>() .WithAmericanAddress(x => x.placeholderstring); var customer = hydrator.GetSingle(); Assert.IsNotNull(customer.placeholderstring); }
public void BooleanGenerator() { var hydrator = new Hydrator<SimpleCustomer>(); var customer = hydrator.GetSingle(); Assert.IsNotNull(customer.IsActive); Assert.IsInstanceOfType(typeof (bool), customer.IsActive); TestUtilities.DumpSimpleCustomer(customer); }
public void CanGetCCV() { var hydrator = new Hydrator <SimpleCustomer>() .WithCCV(x => x.CCV, "visa"); var customer = hydrator.GetSingle(); Assert.IsNotNull(customer.CCV); Assert.IsTrue(customer.CCV.Length == 3); }
public IList <UserModel> GetMultiple(int recordsNumber) { IList <UserModel> users = new List <UserModel>(); Hydrator <UserModel> hydrator = new Hydrator <UserModel>(); users = hydrator.GetList(recordsNumber); return(users); }
public void CanGetSingleRestrictedDescriptionCustomer() { var hydrator = new Hydrator <RestrictedDescriptionCustomer>(); var customer = hydrator.GetSingle(); Assert.IsTrue(!String.IsNullOrEmpty(customer.Description), "Customer Description should exist."); Assert.IsTrue(customer.Description.Length <= 5, "Length not restricted"); DumpSimpleCustomer(customer); }
public void WithPhoneTest() { var hydrator = new Hydrator <SimpleCustomer>() .WithAmericanPhone(x => x.placeholderstring); var customer = hydrator.GetSingle(); Assert.IsNotNull(customer.placeholderstring); Assert.IsTrue(CheckPhone(customer.placeholderstring)); }
public void WithPostalCodeTest() { var hydrator = new Hydrator <SimpleCustomer>() .WithAmericanPostalCode(x => x.placeholderstring, 1); var customer = hydrator.GetSingle(); Assert.IsNotNull(customer.placeholderstring); Assert.IsTrue(IsAmericanPostalCodeValid(customer.placeholderstring)); }
public void CanOverrideGenerator() { var hydrator = new Hydrator <SimpleCustomer>() .With(x => x.FirstName, "Bob"); var customer = hydrator.GetSingle(); Assert.IsNotNull(customer); Assert.IsTrue(customer.FirstName == "Bob"); }
public void CanGetDescription() { var hydrator = new Hydrator <SimpleCustomer>(); var customer = hydrator.GetSingle(); Assert.IsTrue(!String.IsNullOrEmpty(customer.Description), "Customer Description should exist."); DumpSimpleCustomer(customer); }
public void AlphaNumericWithLength() { var hydrator = new Hydrator <SimpleCustomer>() .WithAlphaNumeric(x => x.placeholderstring, 10); var customer = hydrator.GetSingle(); Assert.IsNotNull(customer.placeholderstring); Assert.AreEqual(10, customer.placeholderstring.Length); }
public void PasswordUsingWithAndDefaultLength() { var hydrator = new Hydrator <SimpleCustomer>() .WithPassword(x => x.placeholderstring); var customer = hydrator.GetSingle(); Assert.IsNotNull(customer.placeholderstring); Assert.AreEqual(10, customer.placeholderstring.Length); }
public void BooleanGenerator() { var hydrator = new Hydrator <SimpleCustomer>(); var customer = hydrator.GetSingle(); Assert.IsNotNull(customer.IsActive); Assert.IsInstanceOfType(typeof(bool), customer.IsActive); TestUtilities.DumpSimpleCustomer(customer); }
public void Without_a_hydrate_header() { var response = Hydrator.MakeRequest("/candidate/ref/456", BuildMessage(new HttpRequestMessage())); var body = response.Content.ReadAsStringAsync().Result; body.ShouldNotBeEmpty(); body.ShouldBe(Resource.PersonWithOneRef); }
public void When_handling_a_delete_with_type_only() { var response = Hydrator.MakeRequest( "/manage/statement", new HttpRequestMessage { Method = HttpMethod.Delete }); response.StatusCode.ShouldBe(HttpStatusCode.OK); }
public void CanLoadSingleComplexCustomer() { int[] values = {1, 2, 3}; var args = new object[] {values}; var hydrator = new Hydrator<ComplexCustomer>() .With(x => x.HomeAddress, new TypeGenerator<Address>()); var customer = hydrator.GetSingle(); Assert.IsNotNull(customer); Assert.IsNotNull(customer.HomeAddress, "CustomerAddress is null"); }
public void CanGetNullableFields() { var hydrator = new Hydrator <SimpleCustomer>(false); var customer = hydrator.GetSingle(); Assert.IsNotNull(customer.RewardPoints); Assert.IsInstanceOf <int?>(customer.RewardPoints); DumpSimpleCustomer(customer); }
/// <summary> /// Creates a new instance of <see cref="JoinMonsterExecuter"/>. /// </summary> /// <param name="converter">The <see cref="QueryToSqlConverter"/>.</param> /// <param name="compiler">The <see cref="ISqlCompiler"/>.</param> /// <param name="batchPlanner">The <see cref="IBatchPlanner"/>.</param> /// <param name="hydrator">The <see cref="Hydrator"/>.</param> public JoinMonsterExecuter(QueryToSqlConverter converter, ISqlCompiler compiler, IBatchPlanner batchPlanner, Hydrator hydrator) { _converter = converter ?? throw new ArgumentNullException(nameof(converter)); _compiler = compiler ?? throw new ArgumentNullException(nameof(compiler)); _batchPlanner = batchPlanner ?? throw new ArgumentNullException(nameof(batchPlanner)); _hydrator = hydrator ?? throw new ArgumentNullException(nameof(hydrator)); _objectShaper = new ObjectShaper(new SqlAstValidator()); _arrayToConnectionConverter = new ArrayToConnectionConverter(); }
public void CanGetInteger() { var hydrator = new Hydrator <SimpleCustomer>(); var customer = hydrator.GetSingle(); Assert.IsTrue(customer.Locations >= 0, String.Format("Customer Locations is expected.")); DumpSimpleCustomer(customer); }
public void CanGetDouble() { var hydrator = new Hydrator <SimpleCustomer>(); var customer = hydrator.GetSingle(); Assert.IsTrue(customer.Revenue >= 0, String.Format("Customer Revenue is expected.")); DumpSimpleCustomer(customer); }
public void CanGetList() { var listCount = 50; var hydrator = new Hydrator <SimpleCustomer>(); var customers = hydrator.GetList(listCount); Assert.IsTrue(customers.Count == listCount, "Customer count is wrong."); //DumpCustomers(customers); }
public void BooleanGenerator() { var hydrator = new Hydrator <SimpleCustomer>(); var customer = hydrator.GetSingle(); Assert.IsNotNull(customer.IsActive); Assert.IsInstanceOf <bool>(customer.IsActive); DumpSimpleCustomer(customer); }
public void CanLoadSingleComplexCustomerWithCustumTypeMappers() { var lastNameDefault = "Lennon"; var hy = new Hydrator<ComplexCustomer>() .ForAll<Address>(new Hydrator<Address>()) .For<IList<Address>>(new Map<IList<Address>>().Using(new ListGenerator<Address>(10))) .For<string>(new Map<string>().Matching(info => info.Name.ToLower() == "lastname").Using(lastNameDefault)) .GetSingle(); Assert.AreEqual(lastNameDefault, hy.LastName); }
public void CanGetListOfComplexCustomer() { int[] values = {1, 2, 3}; var args = new object[] {values}; var hydrator = new Hydrator<ComplexCustomer>() .With(x => x.HomeAddress, new TypeGenerator<Address>()); var customerlist = hydrator.GetList(10); Assert.IsNotNull(customerlist); Assert.IsTrue(customerlist.Count == 10); Assert.IsNotNull(customerlist[1].HomeAddress, "CustomerAddress is null"); }
public void CanConstrainDoubleDecimalPlaces() { var decimalPlaces = 3; var hydrator = new Hydrator<SimpleCustomer>() .WithDouble(x => x.Revenue, decimalPlaces); var customer = hydrator.GetSingle(); var decimalPart = customer.Revenue - (int) customer.Revenue; Assert.IsTrue(decimalPart >= 0, String.Format("Customer Revenue decimal part is expected.")); TestUtilities.DumpSimpleCustomer(customer); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Hydrator<Customer> hydrator = new Hydrator<Customer>(); Customer startwithme = hydrator.GetSingle(); txtFirstName.Text = startwithme.FirstName; txtLastName.Text = startwithme.LastName; txtStreetAddress.Text = startwithme.StreetAddress; txtCity.Text = startwithme.City; txtState.Text = startwithme.State; txtZip.Text = startwithme.Zip; } }
public void CanConstrainDates() { var minimumValue = new DateTime(2009, 01, 01); var maximumValue = new DateTime(2009, 01, 10); var hydrator = new Hydrator<SimpleCustomer>() .With(x => x.IncorporatedOn, new DateTimeGenerator(minimumValue, maximumValue)); var customer = hydrator.GetSingle(); Assert.That(customer.IncorporatedOn, Is.InRange(minimumValue, maximumValue), String.Format("Customer IncorporatedOn [{0}] is outside expected range [{1}, {2}].", customer.IncorporatedOn, minimumValue, maximumValue)); TestUtilities.DumpSimpleCustomer(customer); }
public void CanChainWithDefaultDescription() { var defaultValue = "Testing123"; var minimumValue = 65; var maximumValue = 75; var hydrator = new Hydrator<SimpleCustomer>() .With(x => x.Description, defaultValue) .With(x => x.Locations, new IntegerGenerator(minimumValue, maximumValue)); var customer = hydrator.GetSingle(); Assert.IsTrue(defaultValue == customer.Description, String.Format("Default value is not as expected[{0}]", defaultValue)); Assert.That(customer.Locations, Is.InRange(minimumValue, maximumValue), String.Format("Customer Locations [{0}] is outside expected range [{1},{2}].", customer.Locations, minimumValue, maximumValue)); TestUtilities.DumpSimpleCustomer(customer); }
protected void Button1_Click(object sender, EventArgs e) { //Normally I wouldn't put code like this here //But I'm just doing this for simplicity //Ryan Hydrator<Customer> hydrator = new Hydrator<Customer>() .With(x=>x.FirstName, txtFirstName.Text) .With(x => x.LastName, txtLastName.Text) .With(x=>x.StreetAddress,txtStreetAddress.Text) .With(x=>x.City,txtCity.Text) .With(x=>x.State,txtState.Text) .With(x=>x.Zip,txtZip.Text); Customer savethis = hydrator.GetSingle(); CustomerRepository cr = new CustomerRepository(); cr.SaveCustomer(savethis); Response.Redirect("/"); }
public void CanLoadSingleComplexCustomerWithPhoneList() { var listSize = 6; var args = new object[] {listSize}; var customer = new Hydrator<ComplexCustomer>() .With(x => x.PhoneNumbers, new ArrayGenerator<string>(listSize, new AmericanPhoneGenerator())) .GetSingle(); Assert.IsNotNull(customer); Assert.IsTrue(customer.PhoneNumbers.Length == listSize, string.Format("customer.PhoneNumbers.Length [{0}] is not expected value of [{1}].", customer.PhoneNumbers.Length, listSize)); Trace.WriteLine("Addresses Generated..."); foreach (string ph in customer.PhoneNumbers) { Trace.WriteLine(ph); } }
protected void Application_Start(object sender, EventArgs e) { //Create a list of companies and tuck them away for later use Hydrator<Company> hydrator2=new Hydrator<Company>(); IList<Company> comps = hydrator2.GetList(10); Application["companies"] = comps; //Create our customer database using one of the companies created above as the Company property of the customer. //Whoa. int listSize = 4; var args = new object[] { listSize }; //Hydrator<Customer> hydrator = new Hydrator<Customer>() // .FromList("Company", System.Linq.Enumerable.Cast<object>((IList<Company>)Application["companies"])) // .WithChildEntityList("Companies",typeof(Company),args); Hydrator<Customer> hydrator = new Hydrator<Customer>() .With(x => x.Company, new FromListGetSingleGenerator<Company>((IList<Company>)Application["companies"])) .With(x => x.Companies, new ListGenerator<Company>(listSize)); Application["customers"] = hydrator.GetList(50); }
public void CanLoadSingleComplexCustomerWithAddressList() { var listSize = 6; var args = new object[] {listSize}; var customer = new Hydrator<ComplexCustomer>() .With(x => x.Addresses, new ListGenerator<Address>(listSize)) .With(x => x.FirstName, "Test") .GetSingle(); Assert.IsNotNull(customer); Assert.IsTrue(customer.Addresses.Count == listSize, string.Format("Customer.Address.Count [{0}] is not expected value of [{1}].", customer.Addresses.Count, listSize)); Trace.WriteLine("Addresses Generated..."); foreach (Address address in customer.Addresses) { Trace.WriteLine(address.AddressLine1); } }
public void Seed(SiteDbContext context, int sampleSize) { var hydrator = new Hydrator<Headline>() .Ignoring(e => e.HeadlineId) .Ignoring( e => e.EditedById) .Ignoring( (e => e.SubmitedById)) .WithCustomGenerator(e => e.Body, new CatchPhraseGenerator()) .WithCustomGenerator(e => e.Title, new CatchPhraseGenerator()) .WithDate(e => e.SubmittedOn, DateTime.Now.AddDays(-5), DateTime.Now.AddMinutes(-20)).GetList(sampleSize).ToList(); hydrator.ForEach(e => { e.HeadlineId = Guid.NewGuid().ToString(); e.Title = Truncate(e.Title, 15); e.EditedOn = DateTime.Now; e.EditedById = "Admin"; e.SubmitedById = "Admin"; context.Headlines.Add(e); }); context.SaveChanges(); }
public void FromListTest() { IList<string> mylist = new List<string>() {"red", "green", "blue", "orange"}; var hydrator = new Hydrator<SimpleCustomer>() .FromList(x => x.placeholderstring, mylist); var customer = hydrator.GetSingle(); Assert.IsNotNull(customer.placeholderstring); Assert.IsTrue(mylist.Contains(customer.placeholderstring)); }
public void GenderTest() { var hydrator = new Hydrator<SimpleCustomer>(); var customer = hydrator.GetSingle(); Assert.IsNotNull(customer.gender); }
public void IPAddressTest() { var hydrator = new Hydrator<SimpleCustomer>(); var customer = hydrator.GetSingle(); Assert.IsNotNull(customer.ipaddress); Assert.IsTrue(IsValidIPAddress(customer.ipaddress)); }
public void WithWebsite() { var hydrator = new Hydrator<SimpleCustomer>() .WithWebsite(x => x.placeholderstring); var customer = hydrator.GetSingle(); Assert.IsNotNull(customer.placeholderstring); }
public void PasswordWithInferenceDefaultLength() { var hydrator = new Hydrator<SimpleCustomer>(); var customer = hydrator.GetSingle(); Assert.IsNotNull(customer.Password); Assert.AreEqual(10, customer.Password.Length); }
public void TestWebsiteAddress() { var hydrator = new Hydrator<SimpleCustomer>(); var customer = hydrator.GetSingle(); Assert.IsNotNull(customer.homepage); Assert.IsTrue(IsWebsiteAddressValid(customer.homepage)); }
public void WithGenderTest() { var hydrator = new Hydrator<SimpleCustomer>() .WithGender(x => x.placeholderstring); var customer = hydrator.GetSingle(); Assert.IsNotNull(customer.placeholderstring); Assert.IsTrue(customer.placeholderstring.ToLower().Contains("male") || customer.placeholderstring.ToLower().Contains("female")); }
public void WithIPAddressTest() { var hydrator = new Hydrator<SimpleCustomer>() .WithIPAddress(x => x.placeholderstring); var customer = hydrator.GetSingle(); Assert.IsNotNull(customer.placeholderstring); Assert.IsTrue(IsValidIPAddress(customer.placeholderstring)); }
public void WithPhoneTest() { var hydrator = new Hydrator<SimpleCustomer>() .WithAmericanPhone(x => x.placeholderstring); var customer = hydrator.GetSingle(); Assert.IsNotNull(customer.placeholderstring); Assert.IsTrue(CheckPhone(customer.placeholderstring)); }
public void WithPostalCodeTest() { var hydrator = new Hydrator<SimpleCustomer>() .WithAmericanPostalCode(x => x.placeholderstring, 1); var customer = hydrator.GetSingle(); Assert.IsNotNull(customer.placeholderstring); Assert.IsTrue(IsAmericanPostalCodeValid(customer.placeholderstring)); }
public void WithUnitedKingdomPostCodeTest() { var hydrator = new Hydrator<SimpleCustomer>() .WithUnitedKingdomPostCode(x => x.placeholderstring); var customer = hydrator.GetSingle(); Assert.IsNotNull(customer.placeholderstring); }
public void PasswordUsingWithAndDefaultLength() { var hydrator = new Hydrator<SimpleCustomer>() .WithPassword(x => x.placeholderstring); var customer = hydrator.GetSingle(); Assert.IsNotNull(customer.placeholderstring); Assert.AreEqual(10, customer.placeholderstring.Length); }
public void CanConstrainDoubleRange() { var minimum = 15.76; var maximum = 76.43; var hydrator = new Hydrator<SimpleCustomer>() .WithDouble(x => x.Revenue, minimum, maximum); var customer = hydrator.GetSingle(); Assert.That(customer.Revenue, Is.InRange(minimum, maximum)); TestUtilities.DumpSimpleCustomer(customer); }