public PackageControllerTest() { this.mockStorage = new Mock <IStorage>(); this.mockHttpContext = new Mock <HttpContext> { DefaultValue = DefaultValue.Mock }; this.mockHttpRequest = new Mock <HttpRequest> { DefaultValue = DefaultValue.Mock }; this.mockHttpRequest.Setup(m => m.HttpContext).Returns(this.mockHttpContext.Object); this.mockHttpContext.Setup(m => m.Request).Returns(this.mockHttpRequest.Object); this.controller = new PackagesController(this.mockStorage.Object) { ControllerContext = new ControllerContext() { HttpContext = this.mockHttpContext.Object, }, }; this.contextItems = new Dictionary <object, object> { { RequestExtension.ContextKeyTenantId, TenantId }, }; this.mockHttpContext.Setup(m => m.Items).Returns(this.contextItems); this.rand = new Random(); this.any = new AnonymousValueFixture(); }
public ICustomer CreateCustomer(Gender gender) { ICustomer customer = new Customer(); var value = new AnonymousValueFixture(); switch (gender) { case Gender.Male: customer.Title = GetRandomMaleTitle(); customer.FirstName = value.Person.NameFirstMale(); customer.Gender = "Male"; break; case Gender.Female: customer.Title = GetRandomFemaleTitle(); customer.FirstName = value.Person.NameFirstFemale(); customer.Gender = "Female"; break; } customer.Initial = value.Person.NameSuffix(); customer.MiddleName = value.Person.Username(); customer.LastName = value.Person.NameLast(); customer.Email = value.Person.EmailAddress(); customer.UserName = customer.Initial + "_" + value.Person.Username(); customer.Password = value.Person.Password(); customer.Country = GetRandomCountry(); return(customer); }
public PackageControllerTest() { this.mockStorage = new Mock <IStorage>(); this.mockHttpContext = new Mock <HttpContext> { DefaultValue = DefaultValue.Mock }; this.mockHttpRequest = new Mock <HttpRequest> { DefaultValue = DefaultValue.Mock }; this.mockHttpRequest.Setup(m => m.HttpContext).Returns(this.mockHttpContext.Object); this.mockHttpContext.Setup(m => m.Request).Returns(this.mockHttpRequest.Object); this.claims = new List <Claim>(); this.claims.Add(new Claim("sub", "Admin")); this.claims.Add(new Claim("email", "*****@*****.**")); this.controller = new PackagesController(this.mockStorage.Object) { ControllerContext = new ControllerContext() { HttpContext = this.mockHttpContext.Object, }, }; this.contextItems = new Dictionary <object, object> { { RequestExtension.ContextKeyTenantId, TenantId }, { RequestExtension.ContextKeyUserClaims, this.claims }, }; this.mockHttpContext.Setup(m => m.Items).Returns(this.contextItems); this.rand = new Random(); this.any = new AnonymousValueFixture(); }
/// <inerhitdoc /> public object GenerateAnonymousValue(AnonymousValueFixture any, Type type, string propertyName) { // http://autofixture.codeplex.com/workitem/4229 var context = new SpecimenContext(any.Fixture); var specimen = context.Resolve(type); return specimen; }
/// <summary> /// Generate and return a country code. /// </summary> /// <param name="fixture">The fixture to generate a country code for</param> /// <returns>The generated country code</returns> public static string CountryCode(this AnonymousValueFixture fixture) { if (_geoCountryCodeSource == null) { _geoCountryCodeSource = new GeoCountryCodeSource(); } return(_geoCountryCodeSource.Next()); }
/// <summary> /// Generate and return a longitude coordinate. /// </summary> /// <param name="fixture">The fixture to generate a longitude for</param> /// <returns>The generated longitude</returns> public static string Longitude(this AnonymousValueFixture fixture) { if (_geoLongitudeSource == null) { _geoLongitudeSource = new GeoLongitudeSource(); } return(_geoLongitudeSource.Next()); }
/// <summary> /// Generate and return a language name. /// </summary> /// <param name="fixture">The fixture to generate a language for</param> /// <returns>The generated language</returns> public static string Language(this AnonymousValueFixture fixture) { if (_personLanguageSource == null) { _personLanguageSource = new PersonLanguageSource(); } return(_personLanguageSource.Next()); }
/// <inerhitdoc /> public object GenerateAnonymousValue(AnonymousValueFixture any, Type type, string propertyName) { // http://autofixture.codeplex.com/workitem/4229 var context = new SpecimenContext(any.Fixture); var specimen = context.Resolve(type); return(specimen); }
/// <summary> /// Generate and return a male or female first name. /// </summary> /// <param name="fixture">The fixture to generate a first name for</param> /// <returns>The generated first name</returns> public static string FirstName(this AnonymousValueFixture fixture) { if (_personNameFirstSource == null) { _personNameFirstSource = new PersonNameFirstSource(); } return(_personNameFirstSource.Next()); }
/// <summary> /// Generate and return a continent name. /// </summary> /// <param name="fixture">The fixture to generate a continent for</param> /// <returns>The generated continent</returns> public static string Continent(this AnonymousValueFixture fixture) { if (_geoContinentSource == null) { _geoContinentSource = new GeoContinentSource(); } return(_geoContinentSource.Next()); }
/// <summary> /// Generate and return an email address. /// </summary> /// <param name="fixture">The fixture to generate a email for</param> /// <returns>The generated email</returns> public static string EmailAddress(this AnonymousValueFixture fixture) { if (_personEmailAddressSource == null) { _personEmailAddressSource = new PersonEmailAddressSource(); } return(_personEmailAddressSource.Next()); }
/// <inheritdoc /> public object GenerateAnonymousValue(AnonymousValueFixture any, Type type, string propertyName) { // See stackoverflow: http://stackoverflow.com/questions/325426/programmatic-equivalent-of-defaulttype if (type.IsValueType) { return(Activator.CreateInstance(type)); } return(null); }
/// <inheritdoc /> public object GenerateAnonymousValue(AnonymousValueFixture any, Type type, string propertyName) { // See stackoverflow: http://stackoverflow.com/questions/325426/programmatic-equivalent-of-defaulttype if (type.IsValueType) { return Activator.CreateInstance(type); } return null; }
/// <summary> /// Generate and return an integer except for the passed in integer(s). /// </summary> /// <param name="fixture">The fixture to generate an integer for</param> /// <param name="exceptFor">A list of integers to not return</param> /// <returns>The generated integer</returns> public static int IntegerExcept(this AnonymousValueFixture fixture, params int[] exceptFor) { int result; do { result = fixture.PositiveInteger(); } while (exceptFor.Contains(result)); return(result); }
/// <summary> /// Generate and return a string of the given length. /// </summary> /// <param name="fixture">The fixture to generate a string for</param> /// <param name="length">The length of string to generate</param> /// <returns>The generated string</returns> public static string StringOfLength(this AnonymousValueFixture fixture, int length) { var sb = new StringBuilder(); while (sb.Length < length) { sb.Append(String(fixture)); } return(sb.ToString().Substring(0, length)); }
/// <summary> /// Generate and return an enum from any values in the enum except the provided exceptions. /// </summary> /// <param name="fixture">The fixture to generate an enum for</param> /// <param name="except">A list of exceptions; recommend you specify by label for readability</param> /// <returns>The generated enum</returns> public static TEnum Except <TEnum>(this AnonymousValueFixture fixture, params TEnum[] except) where TEnum : struct, IComparable, IFormattable, IConvertible { var value = fixture.Fixture.Create <TEnum>(); while (except.Contains(value)) { value = fixture.Fixture.Create <TEnum>(); } return(value); }
public DeviceGroupsConfigClientTest() { this.logger = new Mock <ILogger <DeviceGroupsConfigClient> >(); this.mockExternalRequestHelper = new Mock <IExternalRequestHelper> { DefaultValue = DefaultValue.Mock }; this.mockAppConfig = new Mock <AppConfig> { DefaultValue = DefaultValue.Mock }; this.any = new AnonymousValueFixture(); this.tenantId = this.any.String(); this.deviceGroupsConfigClient = new DeviceGroupsConfigClient(this.mockAppConfig.Object, this.mockExternalRequestHelper.Object); }
/// <summary> /// Generate and return a unique email address (within the fixture). /// </summary> /// <param name="fixture">The fixture to generate a unique email for</param> /// <returns>The generated unique email</returns> public static string UniqueEmailAddress(this AnonymousValueFixture fixture) { if (_uniquePersonEmailAddressSource == null) { if (_personEmailAddressSource == null) { _personEmailAddressSource = new PersonEmailAddressSource(); } var generator = new SequentialGenerator(0, _personEmailAddressSource.Data.Count, listShouldBeUnique: true); _uniquePersonEmailAddressSource = new PersonEmailAddressSource(generator); } return(_uniquePersonEmailAddressSource.Next()); }
public void WhenGettingUniqueEmail_ThenReturnUniqueEmailsAcrossFixtureInstances() { var source = new PersonEmailAddressSource(); var generatedValues = new List <string>(); var any2 = new AnonymousValueFixture(); generatedValues.Add(any2.UniqueEmailAddress()); for (var i = 0; i < source.Data.Count - 1; i++) { generatedValues.Add(Any.UniqueEmailAddress()); } generatedValues.Distinct().Count() .ShouldBe(generatedValues.Count); }
public void WhenGettingUniqueEmail_ThenReturnUniqueEmailsAcrossFixtureInstances() { var source = new PersonEmailAddressSource(); var generatedValues = new List<string>(); var any2 = new AnonymousValueFixture(); generatedValues.Add(any2.UniqueEmailAddress()); for (var i = 0; i < source.Data.Count - 1; i++) { generatedValues.Add(Any.UniqueEmailAddress()); } generatedValues.Distinct().Count() .ShouldBe(generatedValues.Count); }
internal ListBuilder(int size) { _list = new List <TBuilder>(); BuilderProxy = (TBuilder)ListBuilderGenerator.Generator .CreateClassProxy(typeof(TBuilder), new ProxyGenerationOptions(new EnsureAllMethodsVirtual()), new ListBuilderInterceptor <TObject, TBuilder>(this)); BuilderProxy.ListBuilder = this; var fixture = new AnonymousValueFixture(); for (var i = 0; i < size; i++) { _list.Add(new TBuilder { Any = fixture }); } }
public IdentityGatewayClientTests() { this.logger = new Mock <ILogger <IdentityGatewayClient> >(); this.mockExternalRequestHelper = new Mock <IExternalRequestHelper> { DefaultValue = DefaultValue.Mock }; this.mockAppConfig = new Mock <AppConfig> { DefaultValue = DefaultValue.Mock }; this.any = new AnonymousValueFixture(); this.tenantId = this.any.String(); this.userId = this.any.String(); this.roles = this.any.String(); this.value = this.any.String(); this.identityGatewayClient = new IdentityGatewayClient(this.mockAppConfig.Object, this.mockExternalRequestHelper.Object); }
public void WhenGettingUniqueEmail_ThenReturnUniqueEmailsAcrossFixtureInstances() { var source = new Words(FromDictionary.PersonEmailAddress); var generatedValues = new List<string>(); var any2 = new AnonymousValueFixture(); PersonEquivalenceExtensions.InitializeUniqueEmailAddressSource(); generatedValues.Add(any2.Person.UniqueEmailAddress()); for (var i = 0; i < source.Data.Count - 1; i++) { generatedValues.Add(Any.Person.UniqueEmailAddress()); } generatedValues.Distinct().Count() .ShouldBe(generatedValues.Count); }
public void WhenGettingUniqueEmail_ThenReturnUniqueEmailsAcrossFixtureInstances() { var source = new Words(FromDictionary.PersonEmailAddress); var generatedValues = new List <string>(); var any2 = new AnonymousValueFixture(); PersonEquivalenceExtensions.InitializeUniqueEmailAddressSource(); generatedValues.Add(any2.Person.UniqueEmailAddress()); for (var i = 0; i < source.Data.Count - 1; i++) { generatedValues.Add(Any.Person.UniqueEmailAddress()); } generatedValues.Distinct().Count() .ShouldBe(generatedValues.Count); }
/// <summary> /// Generate and return a string starting with the given prefix. /// </summary> /// <param name="fixture">The fixture to generate a string for</param> /// <param name="prefix">String to prefix the returned anonymous string with</param> /// <returns>The generated string</returns> public static string StringStartingWith(this AnonymousValueFixture fixture, string prefix) { return(fixture.Fixture.Create(prefix)); }
/// <summary> /// Generate and return a string matching the given regex. /// Only a limited subset of regex expressions are supported: http://www.brics.dk/automaton/faq.html. /// </summary> /// <param name="fixture">The fixture to generate a string for</param> /// <param name="regexPattern">The regex pattern to match</param> /// <returns>The generated string</returns> public static string StringMatching(this AnonymousValueFixture fixture, string regexPattern) { return(fixture.RegexGenerator.Create(new RegularExpressionRequest(regexPattern), new DummyContext()).ToString()); }
/// <summary> /// Generate and return a string. /// </summary> /// <param name="fixture">The fixture to generate a string for</param> /// <returns>The generated string</returns> public static string String(this AnonymousValueFixture fixture) { return(fixture.Fixture.Create <string>()); }
/// <inheritdoc /> public TValue GenerateAnonymousValue <TObject, TValue>(AnonymousValueFixture any, string propertyName) { return((TValue)(object)any.FirstName()); }
/// <inheritdoc /> public TValue GenerateAnonymousValue <TObject, TValue>(AnonymousValueFixture any, string propertyName) { return((TValue)(object)any.StringStartingWith(propertyName)); }
/// <inheritdoc /> public object GenerateAnonymousValue(AnonymousValueFixture any, Type type, string propertyName) { return any.Person.NameFirst(); }
/// <inheritdoc /> public object GenerateAnonymousValue(AnonymousValueFixture any, Type type, string propertyName) { return any.StringStartingWith(propertyName); }
/// <inheritdoc /> public object GenerateAnonymousValue(AnonymousValueFixture any, Type type, string propertyName) { return(any.LastName()); }
/// <summary> /// Generate and return a string ending with the given suffix. /// </summary> /// <param name="fixture">The fixture to generate a string for</param> /// <param name="suffix">String to end the returned anonymous string with</param> /// <returns>The generated string</returns> public static string StringEndingWith(this AnonymousValueFixture fixture, string suffix) { return(string.Format("{0}{1}", fixture.Fixture.Create <string>(), suffix)); }
public TValue GenerateAnonymousValue <TObject, TValue>(AnonymousValueFixture any, string propertyName) { return((TValue)(object)_year++); }
/// <inheritdoc /> public object GenerateAnonymousValue(AnonymousValueFixture any, Type type, string propertyName) { return any.EmailAddress(); }
public IntegerEquivalenceClassesTests() { Any = new AnonymousValueFixture(); }
public object GenerateAnonymousValue(AnonymousValueFixture any, Type type, string propertyName) { return(_year++); }
public StringEquivalenceClassesTests() { Any = new AnonymousValueFixture(); }
/// <inheritdoc /> public object GenerateAnonymousValue(AnonymousValueFixture any, Type type, string propertyName) { return any.LastName(); }
public GeoEquivalenceClassesTests() { Any = new AnonymousValueFixture(); }
public PersonEquivalenceClassesTests() { Any = new AnonymousValueFixture(); }