public void Constructor_InvalidType_ShouldThrowArgumentException() { Assert.That(() => new FakeCharacteristic( NamesGenerator.CharacteristicName(), (ComponentType)12345), Throws.ArgumentException); }
public ComponentCharacteristic CreateRandomCharacteristic(int index) { return(CreateCharacteristic( NamesGenerator.CharacteristicName(index), ComponentType.PowerSupply) .WithPattern("bool pattern")); }
public void TestPlanetsNamesGenerator() { Console.WriteLine(NamesGenerator.GeneratePlanetName(1, 1)); Console.WriteLine(NamesGenerator.GeneratePlanetName(1, 2)); Console.WriteLine(NamesGenerator.GeneratePlanetName(1, 3)); Console.WriteLine(NamesGenerator.GeneratePlanetName(1, 4)); Console.WriteLine(NamesGenerator.GeneratePlanetName(1, 5)); Console.WriteLine(NamesGenerator.GeneratePlanetName(1, 6)); Console.WriteLine(NamesGenerator.GeneratePlanetName(2, 1)); Console.WriteLine(NamesGenerator.GeneratePlanetName(2, 2)); Console.WriteLine(NamesGenerator.GeneratePlanetName(2, 3)); Console.WriteLine(NamesGenerator.GeneratePlanetName(2, 4)); Console.WriteLine(NamesGenerator.GeneratePlanetName(2, 5)); Console.WriteLine(NamesGenerator.GeneratePlanetName(2, 6)); Console.WriteLine(NamesGenerator.GeneratePlanetName(3, 1)); Console.WriteLine(NamesGenerator.GeneratePlanetName(3, 2)); Console.WriteLine(NamesGenerator.GeneratePlanetName(3, 3)); Console.WriteLine(NamesGenerator.GeneratePlanetName(3, 4)); Console.WriteLine(NamesGenerator.GeneratePlanetName(3, 5)); Console.WriteLine(NamesGenerator.GeneratePlanetName(3, 6)); Console.WriteLine(NamesGenerator.GeneratePlanetName(4, 1)); Console.WriteLine(NamesGenerator.GeneratePlanetName(4, 2)); Console.WriteLine(NamesGenerator.GeneratePlanetName(4, 3)); Console.WriteLine(NamesGenerator.GeneratePlanetName(4, 4)); Console.WriteLine(NamesGenerator.GeneratePlanetName(4, 5)); Console.WriteLine(NamesGenerator.GeneratePlanetName(4, 6)); }
public void Constructor_CalledWithInvalidType_ShouldThrowArgumentException() { Assert.That(() => new PCComponent( NamesGenerator.ComponentName(), (ComponentType)234567), Throws.ArgumentException); }
public void Constructor_Called_CanCreatePCComponent() { //Arrange var componentName = NamesGenerator.ComponentName(); var component = new PCComponent(componentName, ValidComponentType); Assert.That(component.Name, Is.EqualTo(componentName)); }
protected static Mock <ComponentInterface> CreateInterface(int interfaceNameValue) { var interfaceMock = new Mock <ComponentInterface>(); interfaceMock.SetupGet(x => x.Id).Returns(Guid.NewGuid()); interfaceMock.Setup(x => x.Name).Returns(NamesGenerator.ComponentInterfaceName(interfaceNameValue)); return(interfaceMock); }
public void Constructor_Called_CanCreateComponentInterface() { //Arrange var name = NamesGenerator.ComponentInterfaceName(); var componentInterface = new ComponentInterface(name); //Assert Assert.That(componentInterface.Name, Is.EqualTo(name)); }
private static List <ComponentInterface> CreateSlots() { var slotsToInsert = new List <ComponentInterface>(); for (var i = 0; i < 5; i++) { slotsToInsert.Add(new ComponentInterface(NamesGenerator.ComponentInterfaceName(i))); } return(slotsToInsert); }
public void NamesGenerator_GetRandomFullName() { var val1 = NamesGenerator.GetRandomFullName(); var val2 = NamesGenerator.GetRandomFullName(3, 3); var val3 = NamesGenerator.GetRandomFullName(10, 10); Assert.True(!string.IsNullOrEmpty(val1)); Assert.True(!string.IsNullOrEmpty(val2)); Assert.True(!string.IsNullOrEmpty(val3)); }
public void StopwatchCollection_Stop_StopNotExistingStopwatch() { // Arrange var sut = CreateSUT(); var key = new NamesGenerator().GetRandomName(); // Act // Assert Assert.Equal(TimeSpan.Zero, sut[key]); }
public void SetName_Called_ShouldSetNewName() { //Arrange var newComponentName = NamesGenerator.ComponentName(2); //Act DefaultComponent.WithName(newComponentName); //Assert Assert.That(DefaultComponent.Name, Is.EqualTo(newComponentName)); }
public void StopwatchCollection_Start_AddNewStopwatch() { // Arrange var sut = CreateSUT(); var key = new NamesGenerator().GetRandomName(); // Act sut.Start(key); // Assert Assert.NotEqual(TimeSpan.Zero, sut[key]); }
public void Map_ComponentInterfaceVO() { var from = new ComponentInterfaceVO { Id = Guid.NewGuid(), Name = NamesGenerator.ComponentInterfaceName() }; var to = Mapper.Map <ComponentInterfaceModel>(from); AssertAllPropertiesSet(from, to); AssertLinksSet(to); }
public async Task <IActionResult> OnPostAsync(string returnUrl = null) { returnUrl = returnUrl ?? Url.Content("~/"); ExternalLogins = (await _signInManager.GetExternalAuthenticationSchemesAsync()).ToList(); if (ModelState.IsValid) { var user = new AppIdentityUser { Name = NamesGenerator.GenerateDoubleName((new Random()).Next()), UserName = Input.Email, Email = Input.Email }; var result = await _userManager.CreateAsync(user, Input.Password); if (result.Succeeded) { _logger.LogInformation("User created a new account with password."); var code = await _userManager.GenerateEmailConfirmationTokenAsync(user); code = WebEncoders.Base64UrlEncode(Encoding.UTF8.GetBytes(code)); await _userManager.AddClaimAsync(user, ClaimStaticManager.GetNewPlayerClaim()); var callbackUrl = Url.Page( "/Account/ConfirmEmail", pageHandler: null, values: new { area = "Identity", userId = user.Id, code = code }, protocol: Request.Scheme); await _emailSender.SendEmailAsync(Input.Email, "Confirm your email", $"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>."); if (_userManager.Options.SignIn.RequireConfirmedAccount) { return(RedirectToPage("RegisterConfirmation", new { email = Input.Email })); } else { await _signInManager.SignInAsync(user, isPersistent : false); return(LocalRedirect(returnUrl)); } } foreach (var error in result.Errors) { ModelState.AddModelError(string.Empty, error.Description); } } // If we got this far, something failed, redisplay form return(Page()); }
private void GeneratePlayers() { //TODO: currently generate random player names for now, should be provided by user on new game for (var i = 1; i <= _legionConfig.PlayersCount; i++) { _playersRepository.Players.Add(new Player { Id = i, Money = 5000, Name = NamesGenerator.Generate() }); } _playersRepository.UserPlayer = _playersRepository.Players[1]; _playersRepository.ChaosPlayer = _playersRepository.Players[_playersRepository.Players.Count - 1]; }
public void StopwatchCollection_Start_StartExistingStopwatch() { // Arrange var sut = CreateSUT(); var key = new NamesGenerator().GetRandomName(); sut.Start(key); // Act sut.Start(key); // Assert - Did not throw exception Assert.True(true); }
public void TestDoubleNamesGenerator() { Console.WriteLine(NamesGenerator.GenerateDoubleName(1)); Console.WriteLine(NamesGenerator.GenerateDoubleName(2)); Console.WriteLine(NamesGenerator.GenerateDoubleName(3)); Console.WriteLine(NamesGenerator.GenerateDoubleName(4)); Console.WriteLine(NamesGenerator.GenerateDoubleName(5)); Console.WriteLine(NamesGenerator.GenerateDoubleName(6)); Console.WriteLine(NamesGenerator.GenerateDoubleName(7)); Console.WriteLine(NamesGenerator.GenerateDoubleName(8)); Console.WriteLine(NamesGenerator.GenerateDoubleName(9)); Console.WriteLine(NamesGenerator.GenerateDoubleName(10)); Console.WriteLine(NamesGenerator.GenerateDoubleName(11)); Console.WriteLine(NamesGenerator.GenerateDoubleName(12)); }
public void TestNamesGenerator() { Console.WriteLine(NamesGenerator.GenerateName(1, 1)); Console.WriteLine(NamesGenerator.GenerateName(1, 2)); Console.WriteLine(NamesGenerator.GenerateName(1, 3)); Console.WriteLine(NamesGenerator.GenerateName(1, 4)); Console.WriteLine(NamesGenerator.GenerateName(1, 5)); Console.WriteLine(NamesGenerator.GenerateName(1, 6)); Console.WriteLine(NamesGenerator.GenerateName(2, 1)); Console.WriteLine(NamesGenerator.GenerateName(2, 2)); Console.WriteLine(NamesGenerator.GenerateName(2, 3)); Console.WriteLine(NamesGenerator.GenerateName(2, 4)); Console.WriteLine(NamesGenerator.GenerateName(2, 5)); Console.WriteLine(NamesGenerator.GenerateName(2, 6)); }
private City GenerateCity(Player owner) { var city = new City(); city.Name = NamesGenerator.Generate(); do { //city.X = GlobalUtils.Rand(config.WorldWidth - 50) + 20; // X=Rnd(590)+20 //city.Y = GlobalUtils.Rand(config.WorldHeight - 52) + 20; // Y=Rnd(460)+20 city.X = GlobalUtils.Rand(_legionConfig.WorldWidth); city.Y = GlobalUtils.Rand(_legionConfig.WorldHeight); } while (!IsCityPositionAvailable(city.X, city.Y)); city.Population = GlobalUtils.Rand(900) + 10; city.Owner = owner; city.BobId = 8 + (city.Owner != null ? city.Owner.Id : 0) * 2; if (city.Population > 700) { city.BobId++; city.WallType = GlobalUtils.Rand(2) + 1; } else { city.WallType = GlobalUtils.Rand(1); } city.Tax = GlobalUtils.Rand(25); city.Morale = GlobalUtils.Rand(100); //TEREN[X+4,Y+4] //city.TerrainType = terrainManager.GetTerrain(city.X + 4, city.Y + 4); //if (city.TerrainType == 7) city.TerrainType = 1; city.X += 8; city.Y += 8; city.Craziness = GlobalUtils.Rand(10) + 5; city.DaysToGetInfo = 30; _citiesHelper.UpdatePriceModificators(city); var buildings = GenerateBuildings(); city.Buildings = buildings; return(city); }
private List <PCComponent> CreateComponents(List <ComponentInterface> slotsToInsert, List <ComponentCharacteristic> characteristics) { var componentsToInsert = new List <PCComponent>(); for (var i = 0; i < 5; i++) { var newComponent = new PCComponent(NamesGenerator.ComponentName(i), ComponentType.PowerSupply); newComponent .WithAveragePrice(100 * (i + 1)) .WithPlugSlot(slotsToInsert.RandomElement()) .WithContainedSlot(slotsToInsert.RandomElement()) .WithContainedSlot(slotsToInsert.RandomElementExcept(newComponent.ContainedSlots.ToList())); componentsToInsert.Add(newComponent); AddCharacteristicsToComponent(characteristics, newComponent); } CreateRandomLinks(componentsToInsert); return(componentsToInsert); }
private List <PCConfiguration> CreateConfigurations(IList <PCComponent> componentsToInsert) { var configurations = new List <PCConfiguration>(); for (var i = 0; i < 5; i++) { var configuration = new PCConfiguration(); configuration.WithName(NamesGenerator.ConfigurationName(i)) .WithComponent(componentsToInsert.RandomElementExcept(configuration.Components.ToList())) .WithComponent(componentsToInsert.RandomElementExcept(configuration.Components.ToList())) .WithComponent(componentsToInsert.RandomElementExcept(configuration.Components.ToList())); configurations.Add(configuration); if (_random.NextDouble() > 0.5) { configuration.MoveToStatus(PCConfigurationStatus.Published); } } return(configurations); }
public void EndGame() { Cursor.lockState = CursorLockMode.None; Cursor.visible = true; statisticsUI.SetActive(true); string name = NamesGenerator.GetRandomName(); int timeOnGroundMins = (int)Mathf.Floor(timeOnGround / 60); float timeOnGroundSecs = timeOnGround - 60.0f * timeOnGroundMins; string timeOnGroundStr = "Ground time: " + timeOnGroundMins + "m " + timeOnGroundSecs.ToString("0.##") + "s"; int timeMins = (int)Mathf.Floor(totalTime / 60); float timeSecs = totalTime - timeMins * 60.0f; string totalTimeStr = "Time: " + timeMins + "m " + timeSecs.ToString("0.##") + "s"; string highScoreString = "Look for a high score with the name " + name + "!"; statisticsUI.GetComponentInChildren <Text>().text = timeOnGroundStr + "\n" + totalTimeStr + "\n" + highScoreString; SubmitHighScore(totalTime, timeOnGround, name); }
//занесение данных из объекта данных в контролы public void Build(Client data) { Data = data; updating++; //включаем режим обновления if (string.IsNullOrWhiteSpace(data.Surname)) { var namesGenerator = new NamesGenerator(); var name = namesGenerator.GetFullName(); tbSurname.Text = name.Item1; tbName.Text = name.Item2; tbLastName.Text = name.Item3; var phoneGenerator = new PhoneNumberGenerator(); tbPhoneNumber.Text = phoneGenerator.GetNumber(); var dateGenerator = new BirthdayGenerator(); dtpBirthday.Value = dateGenerator.GetDate(); tbCity.Text = "Москва"; var pasportGenerator = new PassportNumberGenerator(); tbPassport.Text = pasportGenerator.GetNumber(); nudNumberChild.Value = 0; } else { tbSurname.Text = data.Surname; tbName.Text = data.Name; tbLastName.Text = data.LastName; tbPhoneNumber.Text = data.PhoneNumber; dtpBirthday.Value = data.Birthday; tbCity.Text = data.City; tbPassport.Text = data.Passport; nudNumberChild.Value = data.NumberChild; } updating--; //выключаем режим обновления }
public void FindPublishedConfigurations_NotEmptyName_ShouldReturnPublishedConfigurationsWithSpecifiedName() { //Arrange var requestedName = NamesGenerator.ConfigurationName(); var configurationsList = new List <PCConfiguration> { new Mock <PCConfiguration>().Object.WithName(NamesGenerator.ConfigurationName(1)), new Mock <PCConfiguration>().Object.WithName(requestedName), new Mock <PCConfiguration>().Object.WithName(requestedName), new Mock <PCConfiguration>().Object.WithName(NamesGenerator.ConfigurationName(2)) }; configurationsList[1].MoveToStatus(PCConfigurationStatus.Published); configurationsList[3].MoveToStatus(PCConfigurationStatus.Published); MockWorkplace.Setup(x => x.Query <PCConfiguration>()).Returns(configurationsList.AsQueryable()); //Act var retrievedConfigurations = Repository.FindPublishedConfigurations(requestedName).ToList(); //Assert Assert.That(retrievedConfigurations.Count == 1); Assert.That(retrievedConfigurations.First().Status == PCConfigurationStatus.Published); Assert.That(retrievedConfigurations.First().Name == requestedName); }
private static ComponentInterfaceVO CreateInterfaceVO() { return(new ComponentInterfaceVO { Name = NamesGenerator.ComponentInterfaceName() }); }
private void generate(Stopwatch watcher) { Random.Seed(Options.MapSeed); biomesData = Map5BiomesSystem.applyDefaultBiomesSystem(); nameBases = NamesGenerator.getNameBases(); Names = new NamesGenerator(this); Routes = new Map6Routes(this); grid = new Grid(); _placePoints(); Debug.Log($"1 placePoints {Random.NextDouble()} number:{Options.PointsNumber} => points:{grid.points.Count}"); _calculateVoronoi(grid, grid.points, grid.boundary); Debug.Log($"2 calculateVoronoi {Random.NextDouble()}"); new HeightmapGenerator(this).generate(); Debug.Log($"3 HeightmapGenerator {Random.NextDouble()}"); var feature = new Map1Features(this); feature.markFeatures(); Debug.Log($"4 markFeatures {Random.NextDouble()}"); feature.openNearSeaLakes(); Debug.Log($"5 openNearSeaLakes {Random.NextDouble()}"); map1OceanLayers = new Map1OceanLayers(this); map1OceanLayers.generate(); Debug.Log($"6 Map1OceanLayers {Random.NextDouble()}"); double mapSize = 0, latitude = 0; defineMapSize(Options.MapTemplate, grid, ref mapSize, ref latitude); Debug.Log($"7 defineMapSize {Random.NextDouble()}"); mapCoordinates = calculateMapCoordinates(Options.Width, Options.Height, mapSize, latitude); Debug.Log($"8 calculateMapCoordinates {Random.NextDouble()}"); map1Temperatures = new Map1Temperatures(this); map1Temperatures.calculateTemperatures(); //Debug.SaveArray("temp.txt", grid.cells.temp); map1Temperatures.generate(); Debug.Log($"9 calculateTemperatures {Random.NextDouble()} {Options.TemperatureEquator.value} {Options.TemperaturePoleInput} {Options.HeightExponentInput}"); map2Precipitation = new Map2Precipitation(this); map2Precipitation.generatePrecipitation(); Debug.Log("map2Precipitation winds => " + Debug.toString(Options.WindsInput)); Debug.Log($"10 generatePrecipitation {Random.NextDouble()} modifier:{Options.PrecipitationInput / 100d}"); //Debug.SaveArray("prec.txt", grid.cells.prec); //Debug.SaveArray("grid.cells.h.txt", grid.cells.h); pack = new Grid(); reGraph(); Debug.Log($"11 reGraph {Random.NextDouble()}"); //Debug.SaveArray("pack.cells.area.txt", pack.cells.area); new Map3Features(this).reMarkFeatures(); map4Coastline = new Map4Coastline(this); map4Coastline.generate(); Debug.Log($"12 drawCoastline {Random.NextDouble()}"); new Map4Lakes(this).elevateLakes(); Debug.Log($"13 elevateLakes {Random.NextDouble()}"); //Debug.SaveArray("Map4Lakes.h.txt", pack.cells.r_height); Random.Seed(Options.MapSeed); var rivers = new Map4Rivers(this); rivers.generate(); Debug.Log($"14 Map4Rivers {Random.NextDouble()}"); map5Biomes = new Map5BiomesSystem(this); map5Biomes.defineBiomes(); Debug.Log($"15 defineBiomes {Random.NextDouble()}"); map5Biomes.rankCells(); map5Biomes.generate(); //Debug.SaveArray("pack.cells.biome.txt", pack.cells.biome); //Debug.SaveArray("pack.cells.s.txt", pack.cells.s); //Debug.SaveArray("pack.cells.pop.txt", pack.cells.pop); Debug.Log($"16 rankCells {Random.NextDouble()} rankCells: {elapsed(watcher)}ms"); map5Cultures = new Map5Cultures(this); map5Cultures.generate(); Debug.Log($"17 Cultures {Random.NextDouble()} cultures.generate: {elapsed(watcher)}ms"); map5Cultures.expand(); Debug.Log($"18 Cultures.expand {Random.NextDouble()} neutralInput:{Options.NeutralInput}"); //Debug.SaveArray("pack.cells.culture.txt", pack.cells.culture); var burgs = map6BurgsAndStates = new Map6BurgsAndStates(this); burgs.generate(); Debug.Log($"19 Map6BurgsAndStates.generate {Random.NextDouble()} {elapsed(watcher)}ms"); map6Religions = new Map6Religions(this); map6Religions.generate(); Debug.Log($"20 Map6Religions.generate {Random.NextDouble()} {elapsed(watcher)}ms"); burgs.defineStateForms(); burgs.generateProvinces(); burgs.defineBurgFeatures(); Debug.Log($"21 Map6BurgsAndStates.defineBurgFeatures {Random.NextDouble()} {elapsed(watcher)}ms"); burgs.generateProvincesPath(); burgs.generateStatesPath(); burgs.generateStateLabels(); burgs.generateBorders(); Debug.Log($"22 Map6BurgsAndStates.drawStateLabels {Random.NextDouble()} {elapsed(watcher)}ms"); }
public void NamesGenerator_GetRandomName() { var val = NamesGenerator.GetRandomName(); Assert.True(!string.IsNullOrEmpty(val)); }
public ChaosMonkeyException() { var generator = new NamesGenerator(); MonkeyName = generator.GetRandomName(); }
private static string GeneratePlanetName(int seed, int value) { return(NamesGenerator.GeneratePlanetName(seed, value)); }
public Adventure Create(int id, int level) { if (_userAdventures.Count >= MaxAdventures) { return(null); } var adventure = new Adventure(); adventure.Id = id; //PRZYGODY(NR,P_X)=ARMIA(A,0,TNOGI)-70 adventure.Y = GlobalUtils.Rand(9) + 1; adventure.Direction = null; adventure.Level = level; switch (id) { case 1: { // kopalnia adventure.Price = 20 * level; adventure.Terrain = 8; adventure.AddReward(RewardType.Money, level * 10000); } break; case 2: { // kurhan adventure.Price = GlobalUtils.Rand(20 * level); adventure.Terrain = 9; adventure.RelatedPerson = NamesGenerator.Generate(); adventure.AddReward(RewardType.Money, level * 100); /* * adventures.AddReward(RewardType.Weapon, weapon); * Repeat * BRON=Rnd(MX_WEAPON) * BTYP=BRON(BRON,B_TYP) * Until BRON(BRON,B_CENA)>=1000 and BRON(BRON,BCENA)<100+LEVEL*1000 and BTYP<>5 and BTYP<>8 and BTYP<>13 and BTYP<>14 and BTYP<16 * PRZYGODY(NR,P_BRON)=BRON */ } break; case 3: { // bandyci adventure.Price = 0; adventure.AddReward(RewardType.Money, 4000 + GlobalUtils.Rand(2000) + level * 100); } break; case 4: { // córa adventure.Price = 0; adventure.RelatedPerson = NamesGenerator.Generate(); /* * adventure.AddReward(RewardType.City, city.Id); * Repeat : MIASTO=Rnd(49) : Until MIASTA(MIASTO,0,M_CZYJE)<>1 */ } break; default: break; } _userAdventures.Add(adventure); return(adventure); }