コード例 #1
0
        public void Can_Get_Restaurant_By_ExternalId()
        {
            var context = TestingSetup.GetContext();

            var restaurant = new Restaurant()
            {
                ExternalId = "31e045af-cc46-4e28-a783-71d456d86400",
                Name       = "New Restaurant"
            };

            context.Restaurants.Add(restaurant);
            context.SaveChanges();

            var controller =
                new RestaurantController(
                    new RestaurantService(
                        new RestaurantRepository(context)));

            var task = controller.GetRestaurantByExternalId("31e045af-cc46-4e28-a783-71d456d86400")
                       .ContinueWith(innerTask =>
            {
                var result = innerTask.Result;
                Assert.IsType <RestaurantDTO>(result);
                Assert.Equal("31e045af-cc46-4e28-a783-71d456d86400", result.ExternalId);
            });
        }
コード例 #2
0
        public void Can_Get_RestaurantDTO()
        {
            var context = TestingSetup.GetContext();
            IRestaurantRepository repo = new RestaurantRepository(context);

            var restaurant = new Restaurant()
            {
                ExternalId = "31e045af-cc46-4e28-a783-71d456d86400",
                Name       = "New Restaurant"
            };

            context.Restaurants.Add(restaurant);
            context.SaveChanges();

            var svc = new RestaurantService(repo);

            Task task = svc.GetRestaurantByIdAsync("31e045af-cc46-4e28-a783-71d456d86400")
                        .ContinueWith(innerTask =>
            {
                var result = innerTask.Result;
                Assert.IsType <RestaurantDTO>(result);
                Assert.Equal("America/New York", result.TimeZone);
                Assert.Equal("New Restaurant", result.Name);
            });
        }
コード例 #3
0
        public void Can_Get_Default_Restaurant_DTO()
        {
            var context = TestingSetup.GetContext();

            var controller =
                new RestaurantController(
                    new RestaurantService(
                        new RestaurantRepository(context)));
            dynamic result = (JsonResult)controller.Default();

            Assert.Equal(90, result.Value.MinutesInAdvanceAllowDelivery);
        }
コード例 #4
0
        public void Svc_Can_Save_CreateRestaurantDTO()
        {
            var restaurant = new CreateRestaurantDTO();
            var context    = TestingSetup.GetContext();
            var svc        = new RestaurantService(new RestaurantRepository(context));

            Task task = svc.SaveRestaurantAsync(restaurant)
                        .ContinueWith(innerTask =>
            {
                var result = innerTask.Result;
                Assert.Equal("America/New York", result.TimeZone);
            });

            Assert.Single(context.Restaurants);
        }
コード例 #5
0
        public void Can_Save_Restaurant()
        {
            var context    = TestingSetup.GetContext();
            var repo       = new RestaurantRepository(context);
            var restaurant = new Restaurant();

            Task task = repo.SaveAsync(restaurant)
                        .ContinueWith(innerTask =>
            {
                var result = innerTask.Result;
                Assert.IsType <Restaurant>(result);
            });

            Assert.Single(context.Restaurants);
        }
コード例 #6
0
        public void Post_New_Restuarant()
        {
            var context = TestingSetup.GetContext();

            var controller =
                new RestaurantController(
                    new RestaurantService(
                        new RestaurantRepository(context)));

            var restaurant = new CreateRestaurantDTO();

            restaurant.Name = "Mike's Diner";

            var task = controller.CreateRestaurant(restaurant)
                       .ContinueWith(innterTask =>
            {
                var result = innterTask.Result;
                Assert.IsType <RestaurantDTO>(result);
                Assert.Equal("Mike's Diner", result.Name);
            });
        }
コード例 #7
0
        public void Can_Get_Restuarant_By_ExternalId()
        {
            var context = TestingSetup.GetContext();
            var repo    = new RestaurantRepository(context);

            var restaurant = new Restaurant()
            {
                Name = "New Restaurant"
            };

            context.Restaurants.Add(restaurant);
            context.SaveChanges();

            var existingRestaurant = context.Restaurants.First();

            Task task = repo.GetRestaruantByExternalIdAsync(existingRestaurant.ExternalId)
                        .ContinueWith(innerTask =>
            {
                var result = innerTask.Result;
                Assert.Equal("New Restaurant", result.Name);
            });
        }