Exemplo n.º 1
0
        public async Task TestPutInvalidItem()
        {
            using (var context = new SpendingTrackContext(options))
            {
                // Given
                SpendingItem grabItem = context.SpendingItem.Where(x => x.Heading == headingList[1]).Single();
                grabItem.Heading = "Flight to Chiang Rai";
                grabItem.Cost    = 0; //cost should never be 0

                // When
                SpendingController controller = new SpendingController(context, configuration);
                IActionResult      result     = await controller.PutSpendingItem(grabItem.ID, grabItem) as IActionResult;

                Assert.IsNotNull(result);
                Assert.IsInstanceOfType(result, typeof(UnprocessableEntityResult));
            }
        }
Exemplo n.º 2
0
        public async Task TestPutItem()
        {
            using (var context = new SpendingTrackContext(options))
            {
                // Given
                SpendingItem grabItem = context.SpendingItem.Where(x => x.Heading == headingList[0]).Single();
                grabItem.Heading = "Dinner at the Opera House";
                grabItem.Cost    = 145;

                // When
                SpendingController controller = new SpendingController(context, configuration);
                IActionResult      result     = await controller.PutSpendingItem(grabItem.ID, grabItem) as IActionResult;

                // Then check that item was updated successfully / NOCONTENT response
                Assert.IsNotNull(result);
                Assert.IsInstanceOfType(result, typeof(NoContentResult));

                //Then check if there's only one entry in db with heading "Dinner at the Opera House"
                grabItem = context.SpendingItem.Where(x => x.Heading == "Dinner at the Opera House").Single();
            }
        }