예제 #1
0
        public async void UpdateReviewOp()
        {
            DbContextOptions <LoveThemBackAPIDbContext> options =
                new DbContextOptionsBuilder <LoveThemBackAPIDbContext>().UseInMemoryDatabase("UpdateReview")
                .Options;


            using (LoveThemBackAPIDbContext context = new LoveThemBackAPIDbContext(options))
            {
                Review Review = new Review();
                Review.PetID      = 1;
                Review.UserID     = 2;
                Review.Impression = "Snooky";

                var ServicesCreate = new ReviewsService(context);
                await ServicesCreate.AddReview(Review);

                Review newReview = new Review();

                newReview.PetID      = 1;
                newReview.UserID     = 2;
                newReview.Impression = "Updates";

                ServicesCreate.UpdateReview(2, 1, newReview);
                var    getReview = ServicesCreate.GetById(1);
                string impression;
                foreach (var item in getReview.Value)
                {
                    impression = item.Impression;
                    Assert.Equal("Updates", impression);
                }
            }
        }
예제 #2
0
        public async void GetAllReview()
        {
            DbContextOptions <LoveThemBackAPIDbContext> options =
                new DbContextOptionsBuilder <LoveThemBackAPIDbContext>().UseInMemoryDatabase("AllReview")
                .Options;


            using (LoveThemBackAPIDbContext context = new LoveThemBackAPIDbContext(options))
            {
                var Review = new Review();
                Review.PetID      = 1;
                Review.UserID     = 2;
                Review.Impression = "Snooky";

                var Review2 = new Review();
                Review2.PetID      = 2;
                Review2.UserID     = 2;
                Review2.Impression = "Snooky";

                var ServicesCreate = new ReviewsService(context);
                await ServicesCreate.AddReview(Review);

                await ServicesCreate.AddReview(Review2);

                //READ//
                var getReview = ServicesCreate.GetAll();
                Assert.Equal(2, getReview.Value.Count());
            }
        }
예제 #3
0
        public void UpdatePet()
        {
            DbContextOptions <LoveThemBackAPIDbContext> options =
                new DbContextOptionsBuilder <LoveThemBackAPIDbContext>().UseInMemoryDatabase("UpdatePet")
                .Options;


            using (LoveThemBackAPIDbContext context = new LoveThemBackAPIDbContext(options))
            {
                Pet TestPet = new Pet();
                TestPet.PetID = 1;
                TestPet.Name  = "Snooky";

                var ServicesCreate = new PetsService(context);
                ServicesCreate.AddPet(TestPet);

                Pet UpdatePet = new Pet();
                UpdatePet.PetID = 1;
                UpdatePet.Name  = "Coolio";

                ServicesCreate.UpdatePet(1, UpdatePet);
                var getPet = ServicesCreate.GetById(1);

                Assert.Equal("Coolio", getPet.Value.Name);
            }
        }
예제 #4
0
        public void DeletePet()
        {
            DbContextOptions <LoveThemBackAPIDbContext> options =
                new DbContextOptionsBuilder <LoveThemBackAPIDbContext>().UseInMemoryDatabase("DeletePet")
                .Options;


            using (LoveThemBackAPIDbContext context = new LoveThemBackAPIDbContext(options))
            {
                Pet TestPet = new Pet();
                TestPet.PetID = 1;
                TestPet.Name  = "Snooky";

                var ServicesCreate = new PetsService(context);
                ServicesCreate.AddPet(TestPet);
                ServicesCreate.DeletePet(1, 8675309);
                var getPet = context.Pets.FirstOrDefault(x => x.PetID == 1);

                Assert.Null(getPet);
            }
        }
예제 #5
0
        public async void DeleteReview()
        {
            DbContextOptions <LoveThemBackAPIDbContext> options =
                new DbContextOptionsBuilder <LoveThemBackAPIDbContext>().UseInMemoryDatabase("DeletePet")
                .Options;


            using (LoveThemBackAPIDbContext context = new LoveThemBackAPIDbContext(options))
            {
                Review Review = new Review();
                Review.PetID      = 1;
                Review.UserID     = 2;
                Review.Impression = "Snooky";

                var ServicesCreate = new ReviewsService(context);
                await ServicesCreate.AddReview(Review);

                ServicesCreate.DeleteReview(2, 1);
                var getReview = context.Reviews.FirstOrDefault(x => x.PetID == 1 && x.UserID == 2);

                Assert.Null(getReview);
            }
        }
예제 #6
0
 public ReviewsService(LoveThemBackAPIDbContext context)
 {
     _context = context;
 }
예제 #7
0
 public PetsService(LoveThemBackAPIDbContext context)
 {
     _context = context;
 }