public void startSubscriber() { gen = new CustomerGenerator(); gen.CustomerReady += gen_CustomerReady; gen.PumpProgress += gen_PumpProgress; gen.PumpingFinished += gen_PumpingFinished; }
public void MultipleRollBacksShouldBeFine() { // Arrange using (var uow = GetFactory().Create(ScopeType.Transactional)) { uow.GetRepository <ICustomerRepository>().Add(CustomerGenerator.Generate()); // Act uow.Dispose(); // Assert Action action = () => { uow.Dispose(); uow.Dispose(); }; action.ShouldNotThrow(); } }
public override void Init(SignalBus signalBus, Container.Cloud cloud, StateController <RunTimeState> runTimeStateController, InputController inputController, AudioController audioController, VideoController videoController, MonoBehaviour monoBehaviour, SceneManager.SceneManager sceneManager, SpawnController spawnController, CompanyData companyData) { this.signalBus = signalBus; this.cloud = cloud; this.runTimeStateController = runTimeStateController; this.inputController = inputController; this.audioController = audioController; this.videoController = videoController; this.sceneManager = sceneManager; this.spawnController = spawnController; this.monoBehaviour = monoBehaviour; this.companyData = companyData; this.customerGenerator = new CustomerGenerator(); }
static void Main() { ILogger logger = new LoggerConfiguration() .WriteTo.DurableHttp( requestUri: "http://*****:*****@customer} placed {@order}", customer, order); Thread.Sleep(1000); } }
static void Main() { ILogger logger = new LoggerConfiguration() .WriteTo.DurableHttpUsingFileSizeRolledBuffers( requestUri: "http://*****:*****@customer} placed {@order}", customer, order); Thread.Sleep(1000); } }
static void Main() { ILogger logger = new LoggerConfiguration() .WriteTo.Udp( "localhost", 7071, AddressFamily.InterNetwork, new Log4jTextFormatter()) .WriteTo.Console() .CreateLogger(); var customerGenerator = new CustomerGenerator(); var orderGenerator = new OrderGenerator(); while (true) { var customer = customerGenerator.Generate(); var order = orderGenerator.Generate(); logger.Information("{@customer} placed {@order}", customer, order); Thread.Sleep(1000); } }
public void Dispose_ShouldRollbackEverything() { // Arrange var customer = CustomerGenerator.Generate(); using (GetFactory().Create(ScopeType.Transactional)) { using (var uowMiddle = GetFactory().Create(ScopeType.Transactional)) { using (var uowInner = GetFactory().Create()) { uowInner.GetRepository <ICustomerRepository>().Add(customer); uowInner.Commit(); } uowMiddle.Commit(); } // Act - no commit called means dispose will do its thing at the end } // Assert CheckCustomerExistence(false, customer.Name); }
public void UsingTransactionsWithMultipleUoWsWhenTransactionalUoWIsUsedForQueryingShouldWork() { ScopedUnitOfWorkConfiguration.ConfigureDiagnosticsMode(Console.WriteLine, true); using (var unitOfWork = GetFactory().Create(ScopeType.Transactional)) { var customer = unitOfWork.GetRepository <ICustomerRepository>().FindByName("name"); // it does not really matter if customer is null, this is just for a simple query if (customer == null) { for (int i = 0; i < 10; i++) { using (var uow = GetFactory().Create()) { uow.GetRepository <ICustomerRepository>().Add(CustomerGenerator.Generate()); uow.Commit(); } } } unitOfWork.Commit(); } }
private static void SeedCustomers(SalesContext db, int count) { CustomerGenerator.InitialCustomersSeed(db, count); }
public void ExampleBoolean() { var customers = new CustomerGenerator().Generate(5); var anyCustomers = customers.Any(); var anyCustomersWithOverOneHundredLogins = customers.Any(c => c.LoginCount > 100); var anyCustomersWithNoLogins = customers.Any(c => c.LoginCount == 0); var allCustomersHaveAtLeastOneLogin = customers.All(c => c.LoginCount > 0); var allCustomersHaveIdOfOne = customers.All(c => c.Id == 1); var numbers = new int[] { 1, 2, 3, 4, 5 }; var containsThree = numbers.Contains(3); var containsSixty = numbers.Contains(60); var otherNumbers = new int[] { 1, 2, 3, 4, 5 }; var identicalToOtherNumbers = numbers.SequenceEqual(otherNumbers); var outOfOrderNumbers = new int[] { 2, 4, 5, 3, 1 }; var identicalToOutOfOrderNumbers = numbers.SequenceEqual(outOfOrderNumbers); var customer1 = new Customer() { Id = 1 }; var customer2 = new Customer() { Id = 2 }; var customersWithIds = new Customer[] { customer1, customer2 }; var containsNewCustomer = customersWithIds.Contains(new Customer()); var containsNewCustomer1 = customersWithIds.Contains(new Customer() { Id = 1 }); var containsCustomer1 = customersWithIds.Contains(customer1); var containsCustomer2 = customersWithIds.Contains(customer2); var widgets = new Tuple <int, string>[] { new Tuple <int, string>(1, "One"), new Tuple <int, string>(2, "Two") }; var containsWidget1 = widgets.Contains(new Tuple <int, string>(1, "One")); var containsWidget9 = widgets.Contains(new Tuple <int, string>(9, "Nine")); var products = new Product[] { new Product() { Id = 1, Name = "One" }, new Product() { Id = 2, Name = "Two" } }; var containsProduct1 = products.Contains(new Product() { Id = 1, Name = "One" }); var containsProduct9 = products.Contains(new Product() { Id = 9, Name = "Nine" }); }
public void ExampleConversionItems() { var numbersAsObjects = new object[] { 1, 2, 3, 4, 5 }; var numbersAsInts = numbersAsObjects.Cast <int>(); var customers = new CustomerGenerator().Generate(5); var users = customers.Select(c => new User() { Id = c.Id, Name = c.FirstName + " " + c.LastName, FavoriteNumbers = new int[0] }); var inactivePeople = customers .Where(c => !c.IsActive) .Select(c => new { c.Id, Name = c.LastName + ", " + c.FirstName }) .OrderBy(p => p.Name); var usersWithFavoriteNumbers = new User[] { new User() { Id = 1, Name = "User1", FavoriteNumbers = new int[] { 7 } }, new User() { Id = 2, Name = "User2", FavoriteNumbers = new int[] { 1, 3, 7 } }, new User() { Id = 3, Name = "User3", FavoriteNumbers = new int[] { 2, 3, 5, 7, 11 } }, new User() { Id = 4, Name = "User4", FavoriteNumbers = new int[] { 1, 2 } } }; var allFavoriteNumbers = usersWithFavoriteNumbers.SelectMany(u => u.FavoriteNumbers); var distinctOrderedFavoriteNumbers = usersWithFavoriteNumbers .SelectMany(u => u.FavoriteNumbers) .Distinct() .OrderBy(n => n); var infos = new PlayerInfo[] { new PlayerInfo() { PlayerId = 1, Name = "Name1", CreatedDate = DateTime.Parse("01/01/2001") }, new PlayerInfo() { PlayerId = 2, Name = "Name2", CreatedDate = DateTime.Parse("02/02/2002") } }; var metadatas = new PlayerMetadata[] { new PlayerMetadata() { PlayerId = 1, Tags = new string[] { "strong slow" } }, new PlayerMetadata() { PlayerId = 2, Tags = new string[] { "weak fast" } } }; var players = infos.Zip(metadatas, (i, m) => new Player() { Id = i.PlayerId == m.PlayerId ? i.PlayerId : Int32.MinValue, Name = i.Name, CreatedDate = i.CreatedDate, Tags = m.Tags }); }
private void parseAction(int i_Action) { Console.Clear(); switch (i_Action) { case 1: string PlateNumber = UserCommunicator.getStringFromUser("Your vehicle's plate number"); if (!m_Garage.isCustomerEnrolled(PlateNumber)) { DataBaseInitializer InitDB = new DataBaseInitializer(); DataBase newCarDataBase = InitDB.InitializeVehicle(); newCarDataBase.m_PlateNumber = PlateNumber; m_Garage.Add(CustomerGenerator.Start(newCarDataBase)); Console.Clear(); Console.WriteLine($"{newCarDataBase.m_Name}, your car have been added, and it's status is \"In Repair\""); } else { string name = m_Garage.FindCustomerByPlateNumber(PlateNumber).Name; Console.WriteLine($"Welcome back {name}, your car status changed to \"In Repair\""); m_Garage.ChangeStatus(PlateNumber, MotorVehicle.eVehicleStatus.inRepair); } break; case 2: DisplayAllPlateNumbersFiltered(); break; case 3: changeCarStatus(); break; case 4: InflateToMax(); break; case 5: FuelUp(); break; case 6: chargeUpElectric(); break; case 7: printVehicleDetails(); break; case 8: Console.WriteLine("Bye Bye\nPress any key to exit..."); Console.ReadLine(); return; } Console.WriteLine("Press any key to continue"); Console.ReadLine(); Console.Clear(); Start(); }
private void Start() { customerGenerator = GetComponent <CustomerGenerator>(); buildingGenerator = GetComponent <BuildingGenerator>(); objectGenerator = GetComponent <ObjectGenerator>(); }
public CustomerGeneratorTests() { object locker = new object(); Generator = new CustomerGenerator(locker); }
// Update is called once per frame void Update() { if (Input.GetMouseButtonDown(0)) { Vector2 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition); RaycastHit2D hit = Physics2D.Raycast(mousePos, Vector2.up); if (hit.collider) { Vector3 loc = hit.collider.transform.position; if (hit.collider.tag == "ingredients") { hit.collider.GetComponent <IngredientBoxScript>().OnClick(); m_locations.Enqueue(new Vector3(loc.x, loc.y + 2, loc.z)); } else if (hit.collider.tag == "customer") { hit.collider.GetComponent <Customer>().OnClick(); } } } //setting the player to move if there is only one location to go to if (!m_needsToMove && m_locations.Count >= 1) { m_nextLocation = m_locations.Dequeue(); m_needsToMove = true; } //if enough time has passed, put the next item in the queue into the player's hand if (!m_needsToMove && m_playerQueue.Count > 0) { if (m_locations.Count > 0) { m_nextLocation = m_locations.Dequeue(); m_needsToMove = true; } //putting the ingredient into the player's hand if (m_playerQueue.Peek().GetType() == typeof(Ingredients)) { m_itemsInHand.Add((Ingredients)m_playerQueue.Dequeue()); } //"using" the kitchen utensil. must check if the recipe exists else if (m_playerQueue.Peek().GetType() == typeof(CookingUtensilScript)) { CookingUtensilScript tool = (CookingUtensilScript)m_playerQueue.Dequeue(); //if there is a plate for us to pick up. if (tool.HasPlate()) { //can only pick up the plate if there is no other plate in our hand if (m_plateInHand == null) { //we picked up a plate ChangePlateInHand(tool.PickUpPlate()); } } //if no plate, we will place the recipe as long as we have items to cook and there is nothing on the stove else if (m_itemsInHand.Count > 0) { Recipe r = GetRecipe(m_itemsInHand.ToArray(), tool.utensil.utensil); //either putting a recipe in or finding what we should get from clicking on the utensil tool.Loading(PlayerData.GetFoodSprite(r.recipeName), r); m_itemsInHand.Clear(); } } //clicked on a customer else { Customer c = CustomerGenerator.GetCustomer((int)m_playerQueue.Dequeue()); GivePlateToCustomer(c.GetOrder(), c.GetCustomerNumber()); } } if (m_needsToMove) { Vector3 catPos = transform.position; if (catPos == m_nextLocation) { m_needsToMove = false; } else { transform.position = Vector3.MoveTowards(catPos, m_nextLocation, 0.2f); } } }
public MyClass(CustomerGenerator c) { cGen = c; }