public void SearchShouldReturnCorrectResultsWithFilterAndOrder() { // Arrange var firstGlass = new Glass { Id = 1, Name = "First" }; var secondGlass = new Glass { Id = 2, Name = "Second" }; var thirdGlass = new Glass { Id = 3, Name = "Third" }; this.db.AddRange(firstGlass, secondGlass, thirdGlass); this.db.SaveChanges(); var glassService = new ShoppingGlassService(this.db); // Act var result = glassService.Search("d"); var secondResult = glassService.Search(string.Empty); // Assert result.Should() .Match(r => r.ElementAt(0).Id == 3 && r.ElementAt(1).Id == 2) .And .HaveCount(2); secondResult .Should() .HaveCount(3); }
public void SpawnGlass(int recipeIndex = -1) { //timeCounter = 0; if (recipeIndex == -1) { recipeIndex = Random.Range(0, levels[level]); } DrinkRecipe recipe = recipes[recipeIndex]; Glass glass = Instantiate <Glass>(glasses[recipe.cupSize]); glass.recipe = recipe; glass.transform.position = this.transform.position; glass.GetComponent <move>().speed = speeds[level]; ObjectFollowerUI ofui = Instantiate <ObjectFollowerUI>(labelPrefab); ofui.GetComponent <RectTransform>().SetParent(labelCanvas.GetComponent <RectTransform>()); ofui.transform.position = labelPrefab.transform.position; ofui.text.text = recipe.drinkName.ToUpper(); ofui.objectToFollow = glass.transform; glass.label = ofui.gameObject; audiosource.Play(); audiosource.pitch = 1.2f - (0.2f * recipe.cupSize) + Random.Range(-0.2f, 0.2f); audiosource.time = audioDelay; }
public Datum() { style = new Style(); Labels = new Labels(); available = new Available(); glass = new Glass(); }
public Tap GetBeer(int tapId, Glass glass) { //Get Keg by TapId KegEntity kegEntity = _unitOfWork.KegRepository.GetFirst(k => k.TapId == tapId); if (kegEntity.Remaining < glass.AmountToPour) { throw new Exception("Not enough beer in this Tap!!!!!"); } if (kegEntity != null) { using (var scope = new TransactionScope()) { kegEntity.Remaining -= glass.AmountToPour; _unitOfWork.KegRepository.Update(kegEntity); Mapper.CreateMap <Glass, GlassEntity>(); var glassModel = Mapper.Map <Glass, GlassEntity>(glass); _unitOfWork.GlassRepository.Insert(glassModel); _unitOfWork.Save(); scope.Complete(); } } var tap = _unitOfWork.TapRepository.GetByID(tapId); return(GetTapById(tapId)); }
void InstallationStep1() { SetupButton.IsEnabled = false; Glass.HideSystemMenu(this); var info = FileVersionInfo.GetVersionInfo(_targetPath); string name = !string.IsNullOrEmpty(info.ProductName) ? info.ProductName : Path.GetFileNameWithoutExtension(_targetPath); _targetPEInfo = new PEInfo(_targetPath); ShowMessage("Working on " + name + " ...", "Analyzing " + name + " ..."); string nameModule = _targetPEInfo.Modules.FirstOrDefault(s => s.StartsWith("opengl32", StringComparison.OrdinalIgnoreCase) || s.StartsWith("vulkan-1", StringComparison.OrdinalIgnoreCase)); if (nameModule == null) { nameModule = string.Empty; } bool isApiOpenGL = nameModule.StartsWith("opengl32", StringComparison.OrdinalIgnoreCase); bool isApiVulkan = nameModule.StartsWith("vulkan-1", StringComparison.OrdinalIgnoreCase); Message.Text = "Select the rendering API the game uses:"; ApiGroup.IsEnabled = true; ApiOpenGL.IsChecked = isApiOpenGL; ApiVulkan.IsChecked = isApiVulkan; }
public override bool WillHandle(Glass.Sitecore.Mapper.Configuration.SitecoreProperty property, IEnumerable<AbstractSitecoreDataHandler> datas, Dictionary<Type, SitecoreClassConfig> classes) { if (!property.Property.PropertyType.IsGenericType) return false; Type type = Utility.GetGenericOuter(property.Property.PropertyType); return property.Attribute is SitecoreLinkedAttribute && typeof(IEnumerable<>) == type; }
// Depth Quality public void DepthQualityChanged_Front(Glass glass) { foreach (Glass instance in instances) { instance.depthQuality_front = glass.depthQuality_front; } }
public void DepthQualityChanged_Other(Glass glass) { foreach (Glass instance in instances) { instance.depthQuality_other = glass.depthQuality_other; } }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name")] Glass glass) { if (id != glass.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(glass); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GlassExists(glass.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(glass)); }
protected override void OnLoad(EventArgs e) { if (this.Owner != null) { Point pt = this.Owner.Location; pt.Offset(6, 6); this.Location = pt; } if (Glass.IsDesktopCompositionEnabled()) { if (this.MainMenuStrip != null) { //this.TransparencyKey = Color.FromArgb(121, 122, 123); //this.BackColor = this.TransparencyKey; //this.MainMenuStrip.BackColor = this.TransparencyKey; //foreach (ToolStripMenuItem menuItem in this.MainMenuStrip.Items) //{ // menuItem.BackColor = Color.FromArgb(153, 180, 209); //} //var margins = new Glass.MARGINS() //{ // Left = 0, // Right = 0, // Top = this.MainMenuStrip.Height, // Bottom = 0 //}; //ExtendGlassFrameIntoClientArea(margins); } } base.OnLoad(e); }
public void Update(GameTime gameTime) { foreach (GlassPane Glass in Edges) { Glass.Update(gameTime); } }
/// <summary> ///Add new Glass to pour beer from the tap /// </summary> public Glass AddGlass(Glass glass) { _dbContext = new BeerTapDBContext(); _dbContext.Glasses.Add(glass); _dbContext.SaveChanges(); return(glass); }
public void Draw(SpriteBatch spriteBatch) { foreach (GlassPane Glass in Edges) { Glass.Draw(spriteBatch); } }
public void TotalShouldReturnCorrectCount() { // Arrange var first = new Glass { Id = 1, Name = "First" }; var second = new Glass { Id = 2, Name = "Second" }; var third = new Glass { Id = 3, Name = "Third" }; this.db.AddRange(first, second, third); this.db.SaveChanges(); var giftSetService = new AdminGlassService(this.db); // Act var result = giftSetService.Total(""); var secondResult = giftSetService.Total("d"); // Assert result .Should() .Equals(3); secondResult .Should() .Equals(2); }
public void TotalShouldReturnCorrectResult() { //Arrange var firstGlass = new Glass { Id = 1, Name = "First" }; var secondGlass = new Glass { Id = 2, Name = "Second" }; var thirdGlass = new Glass { Id = 3, Name = "Third" }; this.db.AddRange(firstGlass, secondGlass, thirdGlass); this.db.SaveChanges(); var glassService = new ShoppingGlassService(this.db); //Act var result = glassService.Total(); //Assert result .Should() .Equals(3); }
void OnTriggerStay2D(Collider2D other) { if (other.tag.Contains("Pickable") && !m_currentlyCollidingWith) { //Debug.Log("collided with " + other.tag + " " + other.gameObject.name); Debug.Log("TES"); m_currentlyCollidingWith = other; GameObject go = other.gameObject; Glass g = go.GetComponent <Glass>(); if (g) { g.setSelected(true); } Alcohol a = go.GetComponent <Alcohol>(); if (a) { a.setSelected(true); } Fruit f = go.GetComponent <Fruit>(); if (f) { f.setSelected(true); } } else if (other.tag.Contains("Client") && !m_client) { m_client = other.gameObject; } }
private void StartMove(MouseButtonEventArgs e) { _isMoving = true; _localMovePoint = e.GetPosition(Glass); _surfaceMousePoint = e.GetPosition(DesignParent.Surface); Glass.CaptureMouse(); }
public int classify(Glass unknown) { // calculate distances to all points in the trainingData var distances = new List <Tuple <Glass, double> >(); foreach (Glass item in trainingData) { var distance = calculateDistance(unknown.GetMainValues(), item.GetMainValues()); distances.Add(Tuple.Create(item, distance)); } // sort distances.OrderBy(x => x.Item2); // get k nearest glasses from trainingData var kNearest = distances.GetRange(0, k); // determine what class unknown is nearest to var classesNearest = kNearest.Select(x => x.Item1.group_type); var map = new Dictionary <int, int>(); foreach (int c in classesNearest) { if (map.Keys.Contains(c)) { map[c] = map[c] + 1; } else { map.Add(c, 1); } } int max = map.Max(x => x.Value); return(max); }
public DrinkInfo(JsonNode json) { this.menuDrinkId = json["menu_drink_id"].Get <int>(); this.language = (SessionManager.Language)json["language"].Get <int>(); json = json["drink"]; this.minDegree = json["min_degree"].Get <int>(); this.maxDegree = json["max_degree"].Get <int>(); this.imageUrl = json["image_url"].Get <string>(); this.shopUrl = json["shop_url"].Get <string>(); this.primaryName = json["primary_name"].Get <string>(); this.names = new string[json["names"].Count]; for (int i = 0; i < this.names.Length; i++) { this.names[i] = json["names"][i].Get <string>(); } this.taste = json["taste"].Get <string>(); this.description = json["description"].Get <string>(); this.recipe = json["recipe"].Get <string>(); this.color = json["color"].Get <string>(); this.location = json["location"].Get <string>(); this.company = json["company"].Get <string>(); this.technique = new Technique(json["technique"]); this.glass = new Glass(json["grass"]); this.drinkBase = new DrinkBase(json["base"]); this.category = new Category(json["category"]); this.source = new Source(json["source"]); this.compornents = new Compornent[json["compornents"].Count]; for (int i = 0; i < this.compornents.Length; i++) { this.compornents[i] = new Compornent(json["compornents"][i]); } }
public virtual async Task AddAsync(Glass glass) { using (var context = new MicrobrewitContext()) { context.Entry(glass).State = EntityState.Added; try { await context.SaveChangesAsync(); } catch (DbEntityValidationException dbEx) { //foreach (var validationErrors in dbEx.EntityValidationErrors) //{ // foreach (var validationError in validationErrors.ValidationErrors) // { // Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage); // Log.DebugFormat("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage); // throw dbEx; // } //} throw; } catch (Exception ex) { throw; } } }
public Task <ResourceCreationResult <PourBeer, int> > CreateAsync(PourBeer resource, IRequestContext context, CancellationToken cancellation) { _repository = new BeeerTapRepository(); var tapId = context.UriParameters.GetByName <int>("TapId").EnsureValue(() => context.CreateHttpResponseException <Tap>("The TapId must be supplied in the URI", HttpStatusCode.BadRequest)); Keg k = _repository.GetKegByTapId(tapId); if (k.Remaining < resource.Glass.AmountToPour) { throw new Exception("Not enough beer in this Tap!!!!!"); } //Add new Glass resource.Id = tapId; resource.Glass.TapId = tapId; Glass g = _repository.AddGlass(resource.Glass); //Update the Keg _repository.UpdateKegByGlass(g); //Get the Tap for reference Tap t = _repository.GetTapById(tapId); resource.Tap = t; return(Task.FromResult(new ResourceCreationResult <PourBeer, int>(resource))); }
public void DepthQualityChanged_Back(Glass glass) { foreach (Glass instance in instances) { instance.depthQuality_back = glass.depthQuality_back; } }
public ActionResult Create([Bind(Include = "Id,TimeStamp,LinePos,SourcePos,SourceSide,GlassId,GlassHeight,GlassWidth,GlassThickness,GlassWeight,DestRackPos,DestRackSide,PreviousHeight,PreviousWidth,GlassResult,OrderId,CustomerId")] Glass glass) { #region EF6 Code //if (ModelState.IsValid) //{ // db.GlassSet.Add(glass); // db.SaveChanges(); // return RedirectToAction("Index"); //} //ViewBag.CustomerId = new SelectList(db.CustomerSet, "Id", "Name", glass.CustomerId); //ViewBag.OrderId = new SelectList(db.OrderSet, "Id", "Number", glass.OrderId); //return View(glass); #endregion if (glass.TimeStamp == DateTime.MinValue) { glass.TimeStamp = DateTime.Now; } if (ModelState.IsValid) { _repo.SaveNewGlass(glass); return(RedirectToAction("Index")); } #region EF& Code //ViewBag.CustomerId = new SelectList(db.CustomerSet, "Id", "Name", glass.CustomerId); //ViewBag.OrderId = new SelectList(db.OrderSet, "Id", "Number", glass.OrderId); #endregion //ViewBag.CustomerId = new SelectList(_repo.GetCustomerList(), "Id", "Name", glass.CustomerId); ViewBag.OrderId = new SelectList(_repo.GetOrderList(), "Id", "Number", glass.OrderId); return(View(glass)); }
public IActionResult Edit(int id, [Bind("Glass_ID,GName,Price,Brand_ID")] Glass glass) { if (id != glass.Glass_ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(glass); _context.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!GlassExists(glass.Glass_ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["Brand_ID"] = new SelectList(_context.Brands, "Brand_ID", "Brand_ID", glass.Brand_ID); return(View(glass)); }
// GET: Glasses/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Glass glass = _repo.GetGlassWithOrder(id.Value); if (glass == null) { return(HttpNotFound()); } #region EF6 Code //ViewBag.CustomerId = new SelectList(db.CustomerSet, "Id", "Name", glass.CustomerId); //ViewBag.OrderId = new SelectList(db.OrderSet, "Id", "Number", glass.OrderId); #endregion //ViewBag.CustomerId = new SelectList(_repo.GetCustomerList(), "Id", "Name", glass.CustomerId); ViewBag.OrderId = new SelectList(_repo.GetOrderList(), "Id", "Number", glass.OrderId); ViewBag.returnUrl = Request.Headers["Referer"].ToString(); return(View(glass)); }
static void ObjectHierarchy() { Beer beer = new Beer() { Name = "Sly Fox IPA", Flavor = "yummy", OriginalGravity = 4.2m }; Glass glass = new Glass() { Name = "Pilsner", Ounces = 16 }; Database.Connection().Insert("InsertBeer", beer); Database.Connection().Insert("InsertGlass", glass); Serving serving = new Serving() { When = DateTime.Parse("1/1/2012") }; serving.Beer = beer; serving.Glass = glass; Database.Connection().Insert("InsertServing", serving); var servings = Database.Connection().QuerySql <Serving, Beer, Glass>("SELECT s.*, b.*, g.* FROM Servings s JOIN Beer b ON (s.BeerID = b.ID) JOIN Glasses g ON (s.GlassesID = g.ID)", Parameters.Empty); foreach (var s in servings) { Console.WriteLine("{0} {1} {2}", s.When, s.Beer.Name, s.Glass.Ounces); } }
public ActionResult Edit([Bind(Include = "Id,TimeStamp,LinePos,SourcePos,SourceSide,GlassId,GlassHeight,GlassWidth,GlassThickness,GlassWeight,DestRackPos,DestRackSide,PreviousHeight,PreviousWidth,GlassResult,OrderId,CustomerId")] Glass glass, string returnUrl) { #region EF6 Code //if (ModelState.IsValid) //{ // db.Entry(glass).State = EntityState.Modified; // db.SaveChanges(); // return RedirectToAction("Index"); //} //ViewBag.CustomerId = new SelectList(db.CustomerSet, "Id", "Name", glass.CustomerId); //ViewBag.OrderId = new SelectList(db.OrderSet, "Id", "Number", glass.OrderId); //return View(glass); #endregion if (ModelState.IsValid) { _repo.SaveUpdatedGlass(glass); TempData["Success"] = "Added Successfully!"; //return Redirect(returnUrl); //return RedirectToAction("Index"); } #region EF6 Code //ViewBag.CustomerId = new SelectList(db.CustomerSet, "Id", "Name", glass.CustomerId); //ViewBag.OrderId = new SelectList(db.OrderSet, "Id", "Number", glass.OrderId); #endregion //ViewBag.CustomerId = new SelectList(_repo.GetCustomerList(), "Id", "Name", glass.CustomerId); ViewBag.OrderId = new SelectList(_repo.GetOrderList(), "Id", "Number", glass.OrderId); return(View(glass)); }
private void Draw(Graphics draw) { if (Glass.InvokeRequired) { Glass.Invoke(new Action(() => { Draw(draw); })); return; } // this causes flickering //Glass.TopMost = true; Clear(draw); foreach (var id in Graphics.Keys.ToArray()) { var gfx = Graphics[id]; Graphic g = gfx.RealGraphic; if (gfx.Expired) { Graphics.Remove(id); continue; } if (!String.IsNullOrEmpty(g.Shape)) { DrawShape(draw, g); } else { if (!String.IsNullOrEmpty(g.Text)) { DrawText(draw, g); } } } }
void TestTemporaryLoad() { Glass g = null; Config.Apply("playerGlass", ref g); Assert(g.Capacity == 12, "Loaded playerGlass capacity", 12); }
/// <summary> Saves Glass (new or existing). </summary> public int SaveGlass(Glass glass) { if (glass == null) { throw new CoreException("No Glass Specified!"); } // Save ventilation if (glass.GlassVentilation != null) { glass.IdGlassVentilation = SaveVentilation(glass.GlassVentilation); } // Insert or update if (glass.Id == 0) { glass.Id = repository.Insert(glass).InsertId.Value; } else { repository.Update(glass); } return(glass.Id); }
public void AddInstance(Glass instance) { if (!instances.Contains(instance)) { instances.Add(instance); } }
public override void Execute(Glass.Mapper.Pipelines.ObjectConstruction.ObjectConstructionArgs args) { //check that no other task has created an object //also check that this is a dynamic object if (args.Result == null) { var configuration = args.Configuration; if(!configuration.Type.IsAssignableFrom(typeof(IDynamicMetaObjectProvider))) { //check to see if the type is registered with the SimpleInjector container //if it isn't added it if (IsRegistered(configuration.Type)) { lock (_lock) { if (IsRegistered(configuration.Type)) { Register(configuration.Type); } } } Action<object> mappingAction = (target) => configuration.MapPropertiesToObject(target, args.Service, args .AbstractTypeCreationContext); if (args.AbstractTypeCreationContext.IsLazy) { var resolved = GetConstructorParameters(configuration); var proxy = _generator.CreateClassProxy(configuration.Type, resolved, new LazyObjectInterceptor(mappingAction, args)); args.Result = proxy; args.Counters.ProxyModelsCreated++; } else { //create instance using SimpleInjector var obj = CreateConcreteInstance(configuration); //map properties from item to model mappingAction(obj); //set the new object as the returned result args.Result = obj; args.Counters.ConcreteModelCreated++; args.Counters.ModelsMapped++; } } } base.Execute(args); }
public void Ensure_that_the_beer_tap_does_not_dispense_beer_if_there_is_none_left() { Avatar avatar = new Avatar(); Glass glass = new Glass(); avatar.PickUp(glass); Fridge fridge = new Fridge(); fridge.BeerRemaining = 0; avatar.DispenseBeerFrom(fridge).Into(glass); }
public void Ensure_that_if_there_is_only_a_little_bit_of_beer_left_the_container_will_not_be_totally_full() { Avatar avatar = new Avatar(); Glass glass = new Glass(); avatar.PickUp(glass); Fridge fridge = new Fridge(); fridge.BeerRemaining = 2; avatar.DispenseBeerFrom(fridge).Into(glass); Assert.IsFalse(glass.IsEmpty); Assert.IsFalse(glass.IsFull); Assert.AreEqual(48, glass.RemainingCapacity); Assert.AreEqual(0, fridge.BeerRemaining); }
public HeapScroller(Profile p) { this.p = p; Events |= Gdk.EventMask.ButtonPressMask; Timeline [] tl = p.Timeline; maxt = tl [tl.Length - 1].Time; time_span = maxt / 5; SetSizeRequest (100, 100); WidgetFlags |= WidgetFlags.NoWindow; glass = new Glass (this); }
public static void LoadConfigurationMaps(IDependencyResolver resolver, Glass.Mapper.Context context) { var dependencyResolver = resolver as DependencyResolver; if (dependencyResolver == null) { return; } if (dependencyResolver.ConfigurationMapFactory is ConfigurationMapConfigFactory) { GlassMapperScCustom.AddMaps(dependencyResolver.ConfigurationMapFactory); } IConfigurationMap configurationMap = new ConfigurationMap(dependencyResolver); SitecoreFluentConfigurationLoader configurationLoader = configurationMap.GetConfigurationLoader<SitecoreFluentConfigurationLoader>(); context.Load(configurationLoader); }
public GlassModelCounter(Glass.Mapper.Context context, string identifier, int threshold) { _log = context.DependencyResolver.GetLog(); _identifier = identifier; _threshold = threshold; _enabled = context.Config.Debug.Enabled; _counter = context.DependencyResolver.GetModelCounter(); RequestCount = -1; CacheCount = -1; if (_enabled) { _requestedCountBefore = _counter.ModelsRequested; _cacheCount = _counter.CachedModels; } }
public void Contents_of_an_emptied_dishwasher_are_always_clean() { var fork = new Fork(); var spoon = new Spoon(); var glass = new Glass(); Avatar avatar = new Avatar(); avatar.PickUp(fork); avatar.PickUp(spoon); avatar.PickUp(glass); Dishwasher washer = new Dishwasher(); washer.Load(fork); washer.Load(spoon); washer.Load(glass); washer.TakeEverythingOut(); Assert.IsTrue(washer.ContentsAreClean()); }
public void Ensure_that_the_beer_tap_dispenses_beer_fills_containers_and_makes_containers_dirtier() { Avatar avatar = new Avatar(); Glass glass = new Glass(); avatar.PickUp(glass); FineChinaTeacup teacup = new FineChinaTeacup(); avatar.PickUp(teacup); Fridge fridge = new Fridge(); avatar.DispenseBeerFrom(fridge).Into(glass); avatar.DispenseBeerFrom(fridge).Into(teacup); Assert.IsTrue(glass.IsFull); Assert.AreEqual(80m, glass.PercentClean); Assert.AreEqual(DirtRating.Smudged, glass.DirtRating); Assert.IsTrue(teacup.IsFull); Assert.AreEqual(80m, teacup.PercentClean); Assert.AreEqual(DirtRating.Smudged, teacup.DirtRating); Assert.AreEqual(425, fridge.BeerRemaining); }
public void CanQueryOnMetadataUsingDynamicQueries() { using(var store = NewDocumentStore()) { using(var s = store.OpenSession()) { var g = new Glass(); s.Store(g); s.Advanced.GetMetadataFor(g)["Is-Nice"] = true; s.SaveChanges(); } using (var s = store.OpenSession()) { var glasses = s.Advanced.LuceneQuery<Glass>() .WhereEquals("@metadata.Is-Nice", true) .ToArray(); Assert.NotEmpty(glasses); } } }
public GroupSelector() : base() { SetFlag (WidgetFlags.NoWindow); background = Rectangle.Zero; glass = new Glass (this); min_limit = new Limit (this, Limit.LimitType.Min); max_limit = new Limit (this, Limit.LimitType.Max); left = new Gtk.Button (); //left.Add (new Gtk.Image (Gtk.Stock.GoBack, Gtk.IconSize.Button)); left.Add (new Gtk.Arrow (Gtk.ArrowType.Left, Gtk.ShadowType.None)); left.Relief = Gtk.ReliefStyle.None; //left.Clicked += HandleScrollLeft; left.Pressed += HandleLeftPressed; left.ButtonReleaseEvent += HandleScrollReleaseEvent; left_delay = new Delay (50, new GLib.IdleHandler (HandleScrollLeft)); right = new Gtk.Button (); //right.Add (new Gtk.Image (Gtk.Stock.GoForward, Gtk.IconSize.Button)); right.Add (new Gtk.Arrow (Gtk.ArrowType.Right, Gtk.ShadowType.None)); right.Relief = Gtk.ReliefStyle.None; right.Pressed += HandleRightPressed; right.ButtonReleaseEvent += HandleScrollReleaseEvent; right_delay = new Delay (50, new GLib.IdleHandler (HandleScrollRight)); //right.Clicked += HandleScrollRight; this.Put (left, 0, 0); this.Put (right, 100, 0); left.Show (); right.Show (); CanFocus = true; Mode = RangeType.Min; UpdateButtons (); }
public override string SetFieldValue(object value, Glass.Mapper.Sc.Configuration.SitecoreFieldConfiguration config, Glass.Mapper.Sc.SitecoreDataMappingContext context) { throw new NotImplementedException(); }
public void Ensure_that_you_cannot_dispense_a_beverage_into_a_container_that_is_full() { Avatar avatar = new Avatar(); Glass glass = new Glass(); avatar.PickUp(glass); Fridge fridge = new Fridge(); avatar.DispenseBeerFrom(fridge).Into(glass); avatar.DispenseBeerFrom(fridge).Into(glass); }
public void TestEatRows() { var arr = new[]{ new[]{0,0,0,0,0,1,0,0,0,0,0,0,1,1,0,1,1,0,0,1}, new[]{0,0,0,0,0,1,0,0,0,0,0,0,1,0,1,1,1,1,1,1}, new[]{0,0,0,0,0,1,0,0,0,0,0,0,1,1,0,1,1,1,0,1}, new[]{0,0,0,0,0,1,0,0,0,0,0,0,1,0,1,1,1,0,0,1}, new[]{0,0,0,0,0,1,0,0,0,0,0,0,1,1,1,1,1,0,1,1}, new[]{0,0,0,0,0,1,0,0,0,0,0,0,1,0,1,1,1,1,1,1}, new[]{0,0,0,0,0,1,0,0,0,0,0,0,1,1,0,1,1,0,0,1}, new[]{0,0,0,0,0,1,0,0,0,0,0,0,1,0,1,1,1,1,1,1}, new[]{0,0,0,0,0,1,0,0,0,0,0,0,1,1,0,1,1,0,1,1}, new[]{0,0,0,0,0,1,0,0,0,0,0,0,1,0,1,1,1,0,0,1} }; var glass = Glass.createTestGlass ( arr ); Assert.AreEqual ( 5, glass.EatRows() ); arr = new[]{ new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,1}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0} }; Assert.IsTrue ( glass.compareFields ( arr ) ); glass = new Glass(); int score = 0; Assert.IsTrue( glass.AddFigure(new FigureI()) ); glass.Rotate(); for (int i = 0; i < 10; ++i) glass.StepRight(); glass.FallDown(); score += glass.EatRows(); Assert.IsTrue ( glass.AddFigure(new FigureI()) ); glass.Rotate(); for(int i = 0; i < 10; ++i) glass.StepLeft(); glass.FallDown(); score += glass.EatRows(); Assert.IsTrue ( glass.AddFigure(new FigureL()) ); glass.FallDown(); score += glass.EatRows(); Assert.AreEqual ( 1, score ); arr = new[]{ new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} }; Assert.IsTrue ( glass.compareFields ( arr ) ); }
public void TestFallDown() { var glass = new Glass(); Assert.IsTrue(glass.AddFigure(new FigureZ())); glass.FallDown(); var arr = new[]{ new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} }; Assert.IsTrue(glass.compareFields(arr)); Assert.IsFalse(glass.IsRunning()); Assert.IsTrue(glass.AddFigure(new FigureT())); glass.FallDown(); arr = new[]{ new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} }; Assert.IsTrue(glass.compareFields(arr)); Assert.IsFalse(glass.IsRunning()); Assert.IsTrue(glass.AddFigure(new FigureS())); glass.FallDown(); arr = new[]{ new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} }; Assert.IsTrue(glass.compareFields(arr)); Assert.IsFalse(glass.IsRunning()); Assert.IsTrue(glass.AddFigure(new FigureO())); glass.FallDown(); arr = new[]{ new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1}, new[]{0,0,0,0,0,0,0,0,0,0,0,1,1,0,1,1,1,1,1,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} }; Assert.IsTrue(glass.compareFields(arr)); Assert.IsFalse(glass.IsRunning()); Assert.IsTrue(glass.AddFigure(new FigureL())); glass.FallDown(); arr = new[]{ new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1}, new[]{0,0,0,0,0,0,0,0,0,0,1,1,1,0,1,1,1,1,1,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} }; Assert.IsTrue(glass.compareFields(arr)); Assert.IsFalse(glass.IsRunning()); Assert.IsTrue(glass.AddFigure(new FigureJ())); glass.FallDown(); arr = new[]{ new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1}, new[]{0,0,0,0,0,1,1,1,0,0,1,1,1,0,1,1,1,1,1,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} }; Assert.IsTrue(glass.compareFields(arr)); Assert.IsFalse(glass.IsRunning()); Assert.IsTrue(glass.AddFigure(new FigureI())); glass.FallDown(); arr = new[]{ new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, new[]{0,0,0,0,0,1,1,1,0,0,1,1,1,0,1,1,1,1,1,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} }; Assert.IsTrue(glass.compareFields(arr)); Assert.IsFalse(glass.IsRunning()); Assert.IsFalse(glass.AddFigure(new FigureI())); glass.FallDown(); arr = new[]{ new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, new[]{0,0,0,0,0,1,1,1,0,0,1,1,1,0,1,1,1,1,1,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} }; Assert.IsTrue(glass.compareFields(arr)); Assert.IsFalse(glass.IsRunning()); Assert.IsTrue(glass.IsFull()); }
static void Expando_Expand() { Beer beer = new Beer() { Name = "Sly Fox IPA" }; Glass glass = new Glass() { Ounces = 32 }; // create an expando and combine the objects FastExpando x = beer.Expand(); x.Expand(glass); // look! a dynamic object dynamic d = x; Console.WriteLine("{0}", d.Name); Console.WriteLine("{0}", d.Ounces); }
static void ObjectHierarchy() { Beer beer = new Beer() { Name = "Sly Fox IPA", Flavor = "yummy", OriginalGravity = 4.2m }; Glass glass = new Glass() { Name = "Pilsner", Ounces = 16 }; Database.Connection().Insert("InsertBeer", beer); Database.Connection().Insert("InsertGlass", glass); Serving serving = new Serving() { When = DateTime.Parse("1/1/2012") }; serving.Beer = beer; serving.Glass = glass; Database.Connection().Insert("InsertServing", serving); var servings = Database.Connection().QuerySql<Serving, Beer, Glass>("SELECT s.*, b.*, g.* FROM Servings s JOIN Beer b ON (s.BeerID = b.ID) JOIN Glasses g ON (s.GlassesID = g.ID)", Parameters.Empty); foreach (var s in servings) Console.WriteLine("{0} {1} {2}", s.When, s.Beer.Name, s.Glass.Ounces); }
public void TestRotate() { var glass = new Glass(); Assert.IsTrue(glass.AddFigure(new FigureL())); glass.Rotate(); var arr = new[]{ new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} }; Assert.IsTrue(glass.compareFields(arr)); glass.Rotate(); arr = new[]{ new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} }; Assert.IsTrue(glass.compareFields(arr)); glass = new Glass(); Assert.IsTrue(glass.AddFigure(new FigureS())); glass.Rotate(); arr = new[]{ new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} }; Assert.IsTrue(glass.compareFields(arr)); glass.Rotate(); arr = new[]{ new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} }; Assert.IsTrue(glass.compareFields(arr)); arr = new[]{ new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} }; glass = Glass.createTestGlass(arr); Assert.IsTrue(glass.AddFigure(new FigureT())); glass.Rotate(); arr = new[]{ new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} }; Assert.IsTrue(glass.compareFields(arr)); }
public void TestAddFigure() { var glass = new Glass(); var arr = new[]{ new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} }; Assert.IsTrue ( glass.AddFigure ( new FigureI() ) ); Assert.IsTrue ( glass.compareFields ( arr )); Assert.IsTrue ( glass.IsRunning() ); Assert.IsFalse( glass.IsFull()); glass = new Glass(); arr = new[]{ new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} }; Assert.IsTrue(glass.AddFigure(new FigureT())); Assert.IsTrue(glass.compareFields(arr)); Assert.IsTrue(glass.IsRunning()); Assert.IsFalse(glass.IsFull()); glass = new Glass(); arr = new[]{ new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} }; Assert.IsTrue(glass.AddFigure(new FigureL())); Assert.IsTrue(glass.compareFields(arr)); Assert.IsTrue(glass.IsRunning()); Assert.IsFalse(glass.IsFull()); glass = new Glass(); arr = new[]{ new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} }; Assert.IsTrue(glass.AddFigure(new FigureO())); Assert.IsTrue(glass.compareFields(arr)); Assert.IsTrue(glass.IsRunning()); Assert.IsFalse(glass.IsFull()); glass = new Glass(); arr = new[]{ new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} }; Assert.IsTrue(glass.AddFigure(new FigureS())); Assert.IsTrue(glass.compareFields(arr)); Assert.IsTrue(glass.IsRunning()); Assert.IsFalse(glass.IsFull()); // добавить вторую фигуру подряд Assert.IsFalse(glass.AddFigure(new FigureS())); Assert.IsTrue(glass.compareFields(arr)); Assert.IsTrue(glass.IsRunning()); Assert.IsFalse(glass.IsFull()); arr = new[]{ new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} }; glass = Glass.createTestGlass(arr); Assert.IsFalse(glass.AddFigure(new FigureS())); Assert.IsTrue(glass.compareFields(arr)); Assert.IsFalse(glass.IsRunning()); Assert.IsTrue(glass.IsFull()); }
public void TestStepDown() { var glass = new Glass(); Assert.IsTrue(glass.AddFigure(new FigureI())); glass.StepDown(); var arr = new[]{ new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} }; Assert.IsTrue(glass.compareFields(arr)); for(int i = 0; i < 20; ++i) glass.StepDown(); arr = new[]{ new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} }; Assert.IsTrue(glass.compareFields(arr)); Assert.IsFalse ( glass.IsRunning() ); Assert.IsTrue(glass.AddFigure(new FigureS())); Assert.IsTrue(glass.IsRunning()); for(int i = 0; i < 20; ++i) glass.StepDown(); arr = new[]{ new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} }; Assert.IsTrue(glass.compareFields(arr)); Assert.IsFalse(glass.IsRunning()); }
public override bool WillHandle(Glass.Sitecore.Mapper.Configuration.SitecoreProperty property, IEnumerable<AbstractSitecoreDataHandler> datas, Dictionary<Type, SitecoreClassConfig> classes) { return property.Property.PropertyType.IsEnum && property.Property.PropertyType != typeof(FieldTypes.TriState); }
public override bool WillHandle(Glass.Sitecore.Mapper.Configuration.SitecoreProperty property, IEnumerable<AbstractSitecoreDataHandler> datas, Dictionary<Type, SitecoreClassConfig> classes) { if (!(property.Attribute is SitecoreFieldAttribute)) return false; return classes.ContainsKey(property.Property.PropertyType); }
public void TestStepRight() { var glass = new Glass(); Assert.IsTrue(glass.AddFigure(new FigureO())); glass.StepRight(); var arr = new[]{ new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} }; Assert.IsTrue(glass.compareFields(arr)); glass.StepRight(); glass.StepRight(); glass.StepRight(); glass.StepRight(); glass.StepRight(); glass.StepRight(); arr = new[]{ new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} }; Assert.IsTrue(glass.compareFields(arr)); arr = new[]{ new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} }; glass = Glass.createTestGlass ( arr ); Assert.IsTrue(glass.AddFigure(new FigureJ())); glass.StepRight(); glass.StepRight(); glass.StepRight(); glass.StepRight(); glass.StepRight(); glass.StepRight(); arr = new[]{ new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, new[]{0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} }; Assert.IsTrue(glass.compareFields(arr)); }
// Use this for initialization void Start() { // Init texts updateGUI(); // Init glass glass = GameObject.Find("Glass").GetComponent<Glass>(); // Generate first element && throw it glass.CreateNextElement(level); glass.ThrowNextElement(level); nextDownTime = Time.time + startSpeed; nextLevelTime = Time.time + nextLevelSeconds; }
public override bool WillHandle(Glass.Sitecore.Mapper.Configuration.SitecoreProperty property, IEnumerable<AbstractSitecoreDataHandler> datas, Dictionary<Type, SitecoreClassConfig> classes) { if(!(property.Attribute is SitecoreFieldAttribute)) return false; Type type = property.Property.PropertyType; if (!type.IsGenericType) return false; if (type.GetGenericTypeDefinition() != typeof(IEnumerable<>) && type.GetGenericTypeDefinition() != typeof(IList<>)) return false; return true; }
public override bool WillHandle(Glass.Sitecore.Mapper.Configuration.SitecoreProperty property, IEnumerable<AbstractSitecoreDataHandler> datas, Dictionary<Type, SitecoreClassConfig> classes) { return property.Attribute is SitecoreInfoAttribute; }
public void Ensure_that_you_can_always_fill_a_partially_full_container() { Avatar avatar = new Avatar(); Glass glass = new Glass(); avatar.PickUp(glass); Fridge fridge1 = new Fridge(); fridge1.BeerRemaining = 2; avatar.DispenseBeerFrom(fridge1).Into(glass); Assert.AreEqual(0, fridge1.BeerRemaining); Fridge fridge2 = new Fridge(); avatar.DispenseBeerFrom(fridge2).Into(glass); Assert.AreEqual(452, fridge2.BeerRemaining); Assert.IsFalse(glass.IsEmpty); Assert.IsTrue(glass.IsFull); }