示例#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);
        }
示例#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);
     }
 }
示例#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);
        }
示例#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);
        }
示例#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);
        }
示例#6
0
 public void Dispose()
 {
     Brewery.DeleteAll();
     Beer.DeleteAll();
 }