public void Assign_MoreThan256Characters_to_SongTitleAlbumComposer_ReturnsError(string locale) { //arrange var lorem = new Bogus.DataSets.Lorem(locale: locale) { Random = new Randomizer(1080) }; Song fakeSong = new Song() { Title = lorem.Letter(257), Album = lorem.Letter(257), Composer = lorem.Letter(257) }; SongValidator validator = new SongValidator(); ValidationResult results = validator.Validate(fakeSong); bool isValid = results.IsValid; IList <ValidationFailure> failures = results.Errors; Assert.False(isValid); foreach (var failure in failures) { _output.WriteLine(failure.ErrorMessage); } }
static void Main() { var random = new Randomizer(); var lorem = new Bogus.DataSets.Lorem(); var addresses = new Bogus.DataSets.Address(); var order = new Order() { OrderId = random.Number(1, 100), Item = string.Join(" ", lorem.Letter(100)), Quantity = random.Number(1, 10), ZipCode = addresses.ZipCode() }; order.Dump(); Console.ReadLine(); var fruit = new[] { "apple", "banana", "orange", "strawberry", "kiwi", "grapefruit" }; var testOrders = new Faker <Order>() //Ensure all properties have rules. By default, StrictMode is false //Set a global policy by using Faker.DefaultStrictMode .StrictMode(true) //OrderId is deterministic .RuleFor(o => o.OrderId, f => f.Random.Number(1, 100)) //Pick some fruit from a basket .RuleFor(o => o.Item, f => f.PickRandom(fruit)) //A random quantity from 1 to 10 .RuleFor(o => o.Quantity, f => f.Random.Number(1, 10)) .RuleFor(o => o.ZipCode, f => f.Address.ZipCode()); testOrders.Generate(3).ToList().ForEach(o => o.Dump()); Console.ReadLine(); }
public void GameSong_MustBeAssociatedWith_EitherGameOrDlc(string locale) { var lorem = new Bogus.DataSets.Lorem(locale) { Random = new Randomizer(1080) }; Game fakeGame = new Game() { Title = lorem.Letter(1) }; Song fakeSong = new Song() { Title = lorem.Letter(1), Composer = lorem.Letter((1)), Album = lorem.Letter(1) }; var randomFluent = new Bogus.Faker() { Random = new Randomizer(1080) }; DifficultyMode fakeMode = new DifficultyMode(); fakeMode.Level = randomFluent.Random.Int(1, 20); fakeMode.Category = DifficultyCategory.Easy; Ez2OnGameTrack fakeGameTrack = new Ez2OnGameTrack(fakeSong, fakeGame, fakeMode); SongValidator fakeSongValidator = new SongValidator(); GameValidator fakeGameValidator = new GameValidator(); GameTrackValidator mockValidator = new GameTrackValidator(fakeSongValidator, fakeGameValidator); var gameMusicResults = mockValidator.Validate(fakeGameTrack); Assert.True(gameMusicResults.IsValid); }