示例#1
0
 public void Ensure_that_beer_can_be_created_and_calories_are_proportional_to_volume()
 {
     Beer beer = new Beer(10);
     Assert.IsNotNull(beer);
     Assert.AreEqual(10, beer.Size);
     Assert.AreEqual(500, beer.Calories);
 }
示例#2
0
        public async Task<IHttpActionResult> PutBeer(int id, Beer beer)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            if (id != beer.Id)
            {
                return BadRequest();
            }

            db.Entry(beer).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!BeerExists(id))
                {
                    return NotFound();
                }
                else
                {
                    throw;
                }
            }

            return StatusCode(HttpStatusCode.NoContent);
        }
示例#3
0
        public static void test1()
        {
            var tmp = client.Get<Post>("a09590d8-2e98-46b0-a07f-00cfedd3aefd");
            Console.WriteLine(tmp==null?"fail":"ok");
            var newBeer = new Beer()
            {
                Name = "Old Yankee Ale",
                ABV = 5.00f,
                BreweryId = "cottrell_brewing",
                Style = "American-Style Amber",
                Category = "North American Ale"

            };
            var key = "cottrell_brewing-old_yankee_ale-demo2";
            try
            {
                var handler = new StoreHandler(client);
                //client.Remove(key);
                //var result = client.StoreJson(StoreMode.Set, key, newBeer);
                var result = handler.Set(key, newBeer);
                if (result.Success)
                {
                    Console.WriteLine("Cache store ok!");
                    Console.WriteLine(client.Get(key));
                    var cacheBeer = handler.Get(key); //client.GetJson<Beer>(key);
                    Console.WriteLine("Beer's Name:" + cacheBeer.Value);

                }

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        public void CheckForFavorite_BeerNotSavedAsFavorite_ReturnsNull()
        {
            var beer = new Beer { Id = 42, Name = "Duff Dark" };

            var fave = _favoriteBeerRepository.CheckForFavorite(beer.Id).Test();

            Assert.IsNull(fave);
        }
 Beer Build(Beer beer)
 {
     return new Beer()
     {
         BeerId = beer.BeerId,
         Name = beer.Name,
         Picture = beer.Picture,
     };
 }
        public void ShouldBeAssignableFrom_IsAssignableFrom_ShouldPass()
        {
            Beer beer = new Beer();

            beer.ShouldBeAssignableFrom<Drink>();
            beer.ShouldBeAssignableFrom<IDrink>();

            "foo".ShouldBeAssignableFrom<object>();
        }
		public void BasicTests()
		{
			var beer = new Beer() { id = 1, name = "Troeg's Mad Elf" };

			_connection.ExecuteSql("CREATE TABLE Beer (id int, name varchar(400))");
			_connection.ExecuteSql("INSERT INTO Beer (id, name) values (@id, @name)", beer);

			var pour = _connection.QuerySql<Beer>("SELECT * FROM Beer WHERE ID = @id", new { id = 1 }).FirstOrDefault();
			Assert.IsNotNull(pour);
			Assert.AreEqual(beer.id, pour.id);
			Assert.AreEqual(beer.name, pour.name);
		}
 public ActionResult Create(Beer beer)
 {
     try
     {
         _repository.Save(beer);
         return RedirectToAction("Index");
     }
     catch
     {
         return View();
     }
 }
示例#9
0
        public async Task<IHttpActionResult> PostBeer(Beer beer)
        {
            Thread.Sleep(2000);
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.Beers.Add(beer);
            await db.SaveChangesAsync();

            return CreatedAtRoute("DefaultApi", new { id = beer.Id }, beer);
        }
示例#10
0
 public async Task Post(string name, IFormFile file)
 {
     var beer = new Beer { Name = name };
     if (file != null)
     {
         var filename = ContentDispositionHeaderValue
             .Parse(file.ContentDisposition)
             .FileName
             .Trim('"');
         
         beer.Picture = "http://localhost:5000/Images/" + filename;
         await file.SaveAsAsync("C:\\Code\\personal\\app-to-app-uwp\\Inventory.API\\wwwroot\\Images\\" + filename);
     }
     beers.Add(beer);
 }
        static void CreatePatients(InventoryContext context)
        {
            var beers = new List<Beer>();

            var beer = new Beer
            {
                Name = "Amanda Silver",
                //Picture = GetPatientPicture(0),
                Created = DateTime.Now
            };
            beers.Add(beer);

            context.Beers.AddRange(beers);
            context.SaveChanges();
        }
        public void CheckForFavorite_BeerSavedAsFavorite_ReturnsFavorite()
        {
            var beer = new Beer { Id = 42, Name = "Duff Dark" };

            var fave = _favoriteBeerRepository.SaveFavorite(beer.Id, beer.Name).Test();

            Assert.AreNotEqual(0, fave.Id);
            Assert.AreEqual(beer.Id, fave.BeerId);
            Assert.AreEqual(beer.Name, fave.Name);

            var checkedFavorite = _favoriteBeerRepository.CheckForFavorite(beer.Id).Test();

            Assert.AreEqual(fave.Id, checkedFavorite.Id);
            Assert.AreEqual(fave.BeerId, checkedFavorite.BeerId);
            Assert.AreEqual(fave.Name, checkedFavorite.Name);
        }
		public void TestIssue18()
		{
			using (var connection = ConnectionWithTransaction())
			{
				connection.ExecuteSql("CREATE TABLE Beer18 (id int identity, name varchar(256), alcoholpts int)");
				connection.ExecuteSql(@"
					CREATE PROC InsertBeer18 @id int, @name varchar(256), @alcoholpts [int] AS 
						INSERT INTO Beer18 (Name, AlcoholPts)
						OUTPUT Inserted.Id
						VALUES (@Name, @AlcoholPts)
				");

				Beer b = new Beer() { AlcoholPts = 11 };
				connection.ExecuteScalar<int>("InsertBeer18", b);
				Assert.AreEqual(11, connection.ExecuteScalarSql<int>("SELECT AlcoholPts FROM Beer18"));
			}
		}
示例#14
0
 public BeerViewModel(Beer beer)
 {
     ID = beer.ID;
     BreweryID = beer.BreweryID;
     Brewery = beer.Brewery.Name;
     Location = String.Join(" / ", beer.Brewery.Contact.Address.Locality, beer.Brewery.Contact.Address.Region);
     Category = beer.Style.Category.Name;
     StyleID = beer.StyleID;
     Style = beer.Style.Name;
     Name = beer.Name;
     ABV = beer.ABV;
     IBU = beer.IBU;
     SRM = beer.SRM;
     Description = beer.Description;
     FullStyle = String.Join(" / ", Category, Style);
     if(beer.Ratings != null)
         AverageOverall = Math.Round(beer.Ratings.Average(x => x.Overall).GetValueOrDefault(), 1);
 }
        public void RemoveFavorite_FavoriteAlreadyRemoved_DoesNothing()
        {
            var beer = new Beer { Id = 42, Name = "Duff Dark" };

            var fave = _favoriteBeerRepository.SaveFavorite(beer.Id, beer.Name).Test();

            var allFaves = _favoriteBeerRepository.ListFavoriteBeers().Test();

            Assert.AreEqual(1, allFaves.Count);

            _favoriteBeerRepository.RemoveFavorite(fave).Wait();

            allFaves = _favoriteBeerRepository.ListFavoriteBeers().Test();

            Assert.AreEqual(0, allFaves.Count);

            _favoriteBeerRepository.RemoveFavorite(fave).Wait();

            allFaves = _favoriteBeerRepository.ListFavoriteBeers().Test();

            Assert.AreEqual(0, allFaves.Count);
        }
示例#16
0
    //--------------------------------------
    //  Properties
    //--------------------------------------
    // GETTER / SETTER
    ///<summary>
    ///	This is a sample getter/setter property.
    ///</summary>
    // PUBLIC
    ///<summary>
    ///	This is a sample public property.
    ///</summary>
    // PUBLIC STATIC
    ///<summary>
    ///	This is a sample public static property.
    ///</summary>
    // PRIVATE
    ///<summary>
    ///	This is a sample private property.
    ///</summary>
    // PRIVATE STATIC
    ///<summary>
    ///	This is a sample private static property.
    ///</summary>
    //--------------------------------------
    //  Methods
    //--------------------------------------
    ///<summary>
    ///	Use this for initialization
    ///</summary>
    void Start()
    {
        //*********************************************************************
        //
        //	UNITY WITH COCKTAILS THEME: BEER
        //
        //*********************************************************************

        //	DECLARE
        Beer		budweiser_beer   	= new Beer ("budweiser", Beer.CONTAINER_TYPE_BOTTLE);

        //	USE
        Debug.Log ("--------------");
        Debug.Log ("budweiser_beer" 		+ budweiser_beer);
        Beer.SamplePublicStaticMethod		("calling public static method");
        budweiser_beer.samplePublicMethod	("calling public method");

        //	REFLECTION
        Debug.Log ("	type 	: " + budweiser_beer.GetType());
        Debug.Log ("	typeof 	: " + typeof(Beer));
        Debug.Log ("	(budweiser_beer is Beer):  		: " + (budweiser_beer is Beer) );
        Debug.Log ("	(budweiser_beer is Beverage) 	: " + (budweiser_beer is Beverage) );
    }
示例#17
0
 public int AdminUpdate(Beer entity)
 {
     this.deleteableRepo.Update(entity);
     this.deleteableRepo.SaveChanges();
     return entity.Id;
 }
        public void ShouldBeAssignableFrom_IsNotAssignableFrom_ShouldThrowAssertionException()
        {
            Beer beer = new Beer();

            Assert.Throws<AssertionException>(beer.ShouldBeAssignableFrom<string>);
        }
示例#19
0
	//--------------------------------------
	//  Properties
	//--------------------------------------
	
	// GETTER / SETTER
	///<summary>
	///	This is a sample getter/setter property.
	///</summary>
		
	// PUBLIC
	///<summary>
	///	This is a sample public property.
	///</summary>
	
	// PUBLIC STATIC
	///<summary>
	///	This is a sample public static property.
	///</summary>
	
	// PRIVATE
	///<summary>
	///	This is a sample private property.
	///</summary>
	
	// PRIVATE STATIC
	///<summary>
	///	This is a sample private static property.
	///</summary>
	
	
	//--------------------------------------
	//  Methods
	//--------------------------------------		
	///<summary>
	///	Use this for initialization
	///</summary>
	void Start () 
	{
		
				
		//*********************************************************************
		//
		//	UNITY WITH COCKTAILS THEME: BEER
		//
		//*********************************************************************
			
		
		//	DECLARE 
		Beer		budweiser_beer   	= new Beer ("Budweiser", Beer.CONTAINER_TYPE_BOTTLE);
		
		
		//	USE
		Debug.Log ("--------------");
		Debug.Log ("budweiser_beer" 		+ budweiser_beer);
		Beer.SamplePublicStaticMethod		("calling public static method");
		budweiser_beer.samplePublicMethod	("calling public method");
		
		//	REFLECTION
		Debug.Log ("	type 	: " + budweiser_beer.GetType());
		Debug.Log ("	typeof 	: " + typeof(Beer));
		Debug.Log ("	(budweiser_beer is Beer):  		: " + (budweiser_beer is Beer) );
		Debug.Log ("	(budweiser_beer is Beverage) 	: " + (budweiser_beer is Beverage) );
		
		
		//  POLYMOPHISM, WE CAN TREAT BEER AND SODA INSTANCES IN A SIMILAR WAY (SOMETIMES)
		Soda cocaCola_soda = new Soda ("CocaCola");
		//
		Debug.Log ("--------------");
		Debug.Log ("	beer.name 	: " + budweiser_beer.name + " with calories " + budweiser_beer.calories);
		Debug.Log ("	soda.name 	: " + cocaCola_soda.name);
		
	}
示例#20
0
 public string Sing(int start, int stop)
 {
     return(Beer.Sing(start, stop));
 }
示例#21
0
        public EditarCervezaViewModel(Beer editarCerveza)
        {
            _editarCerveza = editarCerveza;

            for (int i = 0; i < Marcas.Count; i++)
            {
                if (editarCerveza.Brand.Id == Marcas[i].Id)
                {
                    MarcaSeleccionada = Marcas[i];
                    break;
                }
            }

            for (int i = 0; i < Clasificaciones.Count; i++)
            {
                if (editarCerveza.Clasification.Code == Clasificaciones[i].Code)
                {
                    ClasificacionSeleccionada = Clasificaciones[i];
                    break;
                }
            }

            for (int i = 0; i < Paises.Count; i++)
            {
                if (editarCerveza.Brand.Country.Id == Paises[i].Id)
                {
                    PaisSeleccionado = Paises[i];
                    break;
                }
            }

            for (int i = 0; i < Tipos.Count; i++)
            {
                if (Enum.GetName(typeof(PresentationType), editarCerveza.Presentation) == Tipos[i])
                {
                    TipoSeleccionado = Tipos[i];
                    break;
                }
            }

            for (int i = 0; i < UnidadesDeMedida.Count; i++)
            {
                if (Enum.GetName(typeof(MeasurementUnit), editarCerveza.MeasurementUnit) == UnidadesDeMedida[i])
                {
                    UnidadDeMedidaSeleccionada = UnidadesDeMedida[i];
                    break;
                }
            }

            for (int i = 0; i < TiposFermentacion.Count; i++)
            {
                if (Enum.GetName(typeof(Fermentation), editarCerveza.Fermlevel) == TiposFermentacion[i])
                {
                    TiposFermentacionSeleccionado = TiposFermentacion[i];
                    break;
                }
            }

            Contenido    = editarCerveza.Content;
            Precio       = editarCerveza.Price;
            GradoAlcohol = editarCerveza.GradoAlcohol;
            _id          = editarCerveza.Id;
            MemoryStream ms         = new MemoryStream(editarCerveza.Image);
            Bitmap       mapaDeBits = new Bitmap(ms);

            ImagenCerveza = BitmapToImageSource(mapaDeBits);
        }
示例#22
0
 public void Post([FromBody] Beer value)
 {
     _manager.Create(value);
 }
示例#23
0
        public void AlcoholKnownMustReturnFalseIfAlcoholByVolumeIsNotSet()
        {
            Beer beer = new Beer("New beer");

            Assert.False(beer.AlcoholKnown);
        }
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            // Seed breweries
            var brewery1 = new Brewery()
            {
                BreweryId   = 1,
                BreweryName = "Fall River Brewery",
                City        = "Redding",
                State       = "CA"
            };

            var brewery2 = new Brewery()
            {
                BreweryId   = 2,
                BreweryName = "Sierra Nevada Brewing Company",
                City        = "Chico",
                State       = "CA"
            };

            // Seed beers
            var beer1 = new Beer()
            {
                BeerId    = 1,
                Abv       = 7.2,
                Ibu       = 80,
                BeerName  = "Hexagenia",
                BeerStyle = BeerStyle.Ipa,
                BreweryId = 1
            };
            var beer2 = new Beer()
            {
                BeerId    = 2,
                Abv       = 9.2,
                Ibu       = 120,
                BeerName  = "Widowmaker",
                BeerStyle = BeerStyle.DoubleIpa,
                BreweryId = 1
            };
            var beer3 = new Beer()
            {
                BeerId    = 3,
                Abv       = 5.5,
                Ibu       = 75,
                BeerName  = "Sierra Nevada Pale Ale",
                BeerStyle = BeerStyle.PaleAle,
                BreweryId = 2
            };

            // Convert BeerStyle enum to string
            modelBuilder
            .Entity <Beer>()
            .Property(b => b.BeerStyle)
            .HasConversion(new EnumToStringConverter <BeerStyle>());

            // Configure many-to-one relationship for Beers table
            modelBuilder
            .Entity <Beer>()
            .HasOne(b => b.Brewery)
            .WithMany(b => b.Beers)
            .HasForeignKey(fk => fk.BreweryId);

            // Configure one-to-many relationship for Breweries table
            modelBuilder
            .Entity <Brewery>()
            .HasMany(b => b.Beers)
            .WithOne(b => b.Brewery);

            // Create index for State
            modelBuilder
            .Entity <Brewery>()
            .HasIndex(b => b.State);

            // Seed data
            modelBuilder
            .Entity <Beer>()
            .HasData(beer1, beer2, beer3);

            modelBuilder
            .Entity <Brewery>()
            .HasData(brewery1, brewery2);
        }
示例#25
0
 public Beer AddBeer(Beer beer)
 {
     throw new NotImplementedException();
 }
 private async void OnBeerSelectedCommandExecuted(Beer beer)
 {
     // TODO: make a call to the Navigation Service
     await _navigationService.NavigateAsync("BeerPage", "beer", beer, false, true);
 }
        public void AlcoholKnown_AlcoholByVolumeNotSet_ReturnsFalse()
        {
            Beer beer = new Beer("New beer");

            Assert.False(beer.AlcoholKnown);
        }
示例#28
0
 public async Task Add(Guid clientId, Beer item)
 {
     //TODO: implement
     throw new NotImplementedException();
 }
示例#29
0
        [HttpPost]      // Post: Blogs
        public async Task <ActionResult> Post([FromBody] Beer beer)
        {
            Beer result = await _beerManager.Add(beer);

            return(Created("Object Created", result));
        }
示例#30
0
 public IActionResult UpdateBeer(Beer beer, String id)
 {
     _logger.LogInformation("UpdateBeer called, with object: {} for id: {}", beer, id);
     _beerService.UpdateBeer(beer, id);
     return(NoContent());
 }
示例#31
0
 public IActionResult CreateBeer(Beer beer)
 {
     _logger.LogInformation("CreateBeer called, with object: {}", beer);
     _beerService.CreateBeer(beer);
     return(Created(API_PATH + beer.Id, ""));
 }
示例#32
0
 public void UpdateBeer(Beer beer)
 {
     throw new NotImplementedException();
 }
 public bool AcceptBeer(Beer beer)
 {
     throw new NotImplementedException();
 }
 public BeerReview()
 {
     Beer = new Beer();
     Review = new Review();
 }
示例#35
0
 public Beer Put(int id, [FromBody] Beer value)
 {
     return(_manager.Update(id, value));
 }
示例#36
0
 public Task <Beer> Add(Beer beer)
 {
     _beers.Add(beer);
     return(Task.FromResult(beer));
 }
        public BeerProfile(Beer scannedBeer)
        {
            InitializeComponent();
            listener = new SwipeListener(stlout_Swipe, this);

            Beer beer = scannedBeer;

            beerID               = Convert.ToInt32(beer.beerId);
            this.Title           = beer.beerName;
            img_BeerImage.Source = beer.pic;

            crits = Database.ShowCriteria();

            attr1.Text = crits[0].Kriterium;
            attr2.Text = crits[1].Kriterium;
            attr3.Text = crits[2].Kriterium;
            attr4.Text = crits[3].Kriterium;
            attr5.Text = crits[4].Kriterium;

            newGrades = Database.CheckRating(Convert.ToInt32(scannedBeer.beerId));

            if (newGrades != null)
            {
                if (crits[0].KriterienID == newGrades[0].KriterienID)
                {
                    pickAttr1.Value = Convert.ToInt32(newGrades[0].Bewertung);
                }
                else
                {
                    pickAttr1.Value = 0;
                }
                if (newGrades.Count > 1 && crits[1].KriterienID == newGrades[1].KriterienID)
                {
                    pickAttr2.Value = Convert.ToInt32(newGrades[1].Bewertung);
                }
                else
                {
                    pickAttr2.Value = 0;
                }
                if (newGrades.Count > 2 && crits[2].KriterienID == newGrades[2].KriterienID)
                {
                    pickAttr3.Value = Convert.ToInt32(newGrades[2].Bewertung);
                }
                else
                {
                    pickAttr3.Value = 0;
                }
                if (newGrades.Count > 3 && crits[3].KriterienID == newGrades[3].KriterienID)
                {
                    pickAttr4.Value = Convert.ToInt32(newGrades[3].Bewertung);
                }
                else
                {
                    pickAttr4.Value = 0;
                }
                if (newGrades.Count > 4 && crits[4].KriterienID == newGrades[4].KriterienID)
                {
                    pickAttr5.Value = Convert.ToInt32(newGrades[4].Bewertung);
                }
                else
                {
                    pickAttr5.Value = 0;
                }
            }
            else
            {
                pickAttr1.Value = 0;
                pickAttr2.Value = 0;
                pickAttr3.Value = 0;
                pickAttr4.Value = 0;
                pickAttr5.Value = 0;
            }
        }
示例#38
0
 public BeerResponse AddBeer(Beer beer)
 {
     return(_vendorABeerServices.AddBeer(beer));
 }
示例#39
0
 public string Verse(int number)
 {
     return(Beer.Verse(number));
 }
示例#40
0
 public BeerResponse UpdateBeer(Beer beer)
 {
     return(_vendorABeerServices.UpdateBeer(beer));
 }
示例#41
0
        public void AddBeer(Beer beer)
        {
            context.Beers.Add(beer);

            context.SaveChanges();
        }
        public void SaveFavorite_SavesToDatabase_ReturnsSavedFavorite()
        {
            var beer = new Beer {Id = 42, Name = "Duff Dark"};

            var fave = _favoriteBeerRepository.SaveFavorite(beer.Id, beer.Name).Test();

            Assert.AreNotEqual(0, fave.Id);
            Assert.AreEqual(beer.Id, fave.BeerId);
            Assert.AreEqual(beer.Name, fave.Name);

            var allFaves = _favoriteBeerRepository.ListFavoriteBeers().Test();

            Assert.AreEqual(1, allFaves.Count());

            var savedFave = allFaves.First();

            Assert.AreEqual(fave.Id, savedFave.Id);
            Assert.AreEqual(fave.BeerId, savedFave.BeerId);
            Assert.AreEqual(fave.Name, savedFave.Name);
        }
示例#43
0
 public void InsertBeer(Beer beer)
 {
     _context.Beers.Add(beer); //dodaj e do bazy browar
 }
示例#44
0
 private void LoadBeerList()
 {
     allBeers = Beer.GetBeersFromCsv();
 }
示例#45
0
 public int Add(Beer beer)
 {
     this.beers.Add(beer);
     this.beers.Save();
     return beer.Id;
 }
        public void RateShould_RecalculateRating_WhenValid()
        {
            //Arrange
            var options = InMemory.GetOptions("RateShould_RecalculateRating_WhenValid");

            using (var context = new BOContext(options))
            {
                var user = new User()
                {
                    Id       = 1,
                    IDOld    = 1,
                    Name     = "SuperMan",
                    Password = "******",
                };

                var user2 = new User()
                {
                    Id       = 2,
                    IDOld    = 2,
                    Name     = "Batman",
                    Password = "******",
                };


                var beer = new Beer()
                {
                    ID      = 1,
                    ABV     = 4.5f,
                    Name    = "Carlsberg",
                    Country = new Country()
                    {
                        Name = "Germany"
                    },
                    Style = new BeerStyle()
                    {
                        Name = "Ale"
                    }
                };
                var firstNewRating = new BeerUserRating()
                {
                    BeerID = beer.ID,
                    Beer   = beer,
                    UserID = user.IDOld,
                    User   = user,
                    Rating = 2,
                };
                context.Users.Add(user);
                context.Users.Add(user2);
                context.Beers.Add(beer);
                context.BeerUserRatings.Add(firstNewRating);
                context.SaveChanges();
            }

            using (var context = new BOContext(options))
            {
                //Act
                var sut               = new UsersService(context);
                var result            = sut.Rate(2, 1, 5).Result;
                var beerWithNewRating = context.Beers.Find(1);
                //Assert
                Assert.AreEqual(3.5, beerWithNewRating.Rating);
            }
        }
 public Beer ServeBeerTo(Beer beer, Person person)
 {
     person.Accept(beer);
     return(beer);
 }
示例#48
0
 private void TestModels()
 {
     //use the get beers from csv method:
     List <Beer> beersFromCsv = Beer.GetBeersFromCsv();
 }
 public new bool AcceptBeer(Beer beer)
 {
     return(Drink(beer));
 }
 bool Drink(Beer beer)
 {
     return(beer != null);
 }
示例#51
0
        public async Task <IActionResult> Post([FromBody] Beer beer)
        {
            await beerService.AddBeer(beer);

            return(Ok(beer));
        }
示例#52
0
 public void Visit(Beer item)
 {
     AccumulateTax(item, taxOnBeer);
 }