Esempio n. 1
0
        public void Setup()
        {
            // Prepare TestBall
            using (var db = new BirdieDBContext())
            {
                var newBall = new Ball()
                {
                    Name     = "Test Ball",
                    ColourId = 1
                };

                db.Ball.Add(newBall);
                db.SaveChanges();

                TestBall = db.Ball
                           .Where(b => b.Name == "Test Ball")
                           .Single();
            }

            // Prepare NewTestBall
            using (var db = new BirdieDBContext())
            {
                var dbColour = db.Colour.Where(c => c.Name == "Red").Single();

                NewTestBall = new Ball()
                {
                    Name   = "New Test Ball",
                    Colour = dbColour
                };
            }
        }
Esempio n. 2
0
        public void DeleteBall(Ball inputBall)
        {
            using (var db = new BirdieDBContext())
            {
                var originalBall = db.Ball
                                   .Where(b => b.Id == inputBall.Id)
                                   .Single();

                db.Ball.Remove(originalBall);

                db.SaveChanges();
            }
        }
Esempio n. 3
0
        public void UpdateBall(Ball inputBall)
        {
            using (var db = new BirdieDBContext())
            {
                var originalBall = db.Ball
                                   .Where(b => b.Id == inputBall.Id)
                                   .Single();

                originalBall.Name     = inputBall.Name;
                originalBall.ColourId = inputBall.Colour.Id;

                db.SaveChanges();
            }
        }
Esempio n. 4
0
        public void AddBall(Ball inputBall)
        {
            var newBall = new Ball()
            {
                Name     = inputBall.Name,
                ColourId = inputBall.Colour.Id
            };

            using (var db = new BirdieDBContext())
            {
                db.Ball.Add(newBall);
                db.SaveChanges();
            }
        }
Esempio n. 5
0
        public void TearDown()
        {
            using (var db = new BirdieDBContext())
            {
                var TestBalls = db.Ball
                                .Where(b => b.Name.Contains("Test"))
                                .ToList();

                foreach (var item in TestBalls)
                {
                    db.Ball.Remove(item);
                }

                db.SaveChanges();
            }
        }