Example #1
0
        public void Save_ObjectSavedToDatabase()
        {
            //Arrange
            var testList       = new List <Brewery> {
            };
            Brewery newBrewery = new Brewery("Widmer", "Portland, OR");

            //Act
            newBrewery.Save();
            testList.Add(newBrewery);
            var savedBreweries = Brewery.GetAll();

            //Assert
            Assert.Equal(testList, savedBreweries);
        }
Example #2
0
 //Overrides
 public override bool Equals(System.Object otherObject)
 {
     if (!(otherObject is Brewery))
     {
         return(false);
     }
     else
     {
         Brewery testBrewery      = (Brewery)otherObject;
         bool    idEquality       = this.GetId() == testBrewery.GetId();
         bool    nameEquality     = this.GetName() == testBrewery.GetName();
         bool    locationEquality = this.GetLocation() == testBrewery.GetLocation();
         return(idEquality && nameEquality && locationEquality);
     }
 }
Example #3
0
        public void GetAll_GetsAllObjectsFromTable()
        {
            //Arrange
            Brewery testBrewery1 = new Brewery("Widmer", "Portland, OR");
            Brewery testBrewery2 = new Brewery("Breakside", "Portland, OR");

            testBrewery1.Save();
            testBrewery2.Save();
            List <Brewery> expectedList = new List <Brewery> {
                testBrewery1, testBrewery2
            };
            //Act
            List <Brewery> results = Brewery.GetAll();

            //Assert
            Assert.Equal(expectedList, results);
        }
Example #4
0
        public void AddBeer_SaveAssociationBetweenBeerAndBrewery()
        {
            //Arrange
            Brewery testBrewery = new Brewery("Widmer", "Portland, OR");

            testBrewery.Save();

            Beer testBeer1 = new Beer("Alpha IPA", 6.8, 70.0);

            testBeer1.Save();
            List <Beer> testList = new List <Beer> {
                testBeer1
            };

            //Act
            testBrewery.AddBeer(testBeer1.GetId());

            var result = testBrewery.GetBeers();

            //Assert
            Assert.Equal(testList, result);
        }
Example #5
0
        public void GetBeers_GetAllBeersAssociatedWithBrewery()
        {
            //Arrange
            Brewery testBrewery = new Brewery("Widmer", "Portland, OR");

            testBrewery.Save();
            Beer testBeer1 = new Beer("Alpha IPA", 6.8, 70.0);
            Beer testBeer2 = new Beer("Beta IPA", 6.8, 70.0);

            testBeer1.Save();
            testBeer2.Save();
            List <Beer> testList = new List <Beer> {
                testBeer1
            };

            testBrewery.AddBeer(testBeer1.GetId());
            //Act
            var result = testBrewery.GetBeers();

            //Assert
            Assert.Equal(testList, result);
        }
Example #6
0
 public void Dispose()
 {
     Brewery.DeleteAll();
     Beer.DeleteAll();
 }