Ejemplo n.º 1
0
        public async void Task_Getinvents_MatchResult()
        {
            //Arrange
            var controller = new InventoriesController(repository);

            //Act
            var data = await controller.GetInventory();

            //Assert
            Assert.IsType <OkObjectResult>(data.Result);
        }
        public void GetInventory_ShouldReturnInventoryWithSameID()
        {
            var context = new TestInventory();

            context.InventoryList.Add(GetInventoryItem());

            var controller = new InventoriesController(context);
            var result     = controller.GetInventory(3) as OkNegotiatedContentResult <Inventory>;

            Assert.IsNotNull(result);
            Assert.AreEqual(3, result.Content.ID);
        }
Ejemplo n.º 3
0
        public async void Task_GetinventById_Return_BadRequestResult()
        {
            //Arrange
            var  controller = new InventoriesController(repository);
            long?inventid   = null;

            //Act
            var data = await controller.GetInventory(inventid);

            //Assert
            Assert.IsType <BadRequestResult>(data.Result);
        }
Ejemplo n.º 4
0
        public async void Task_GetinventById_Return_NotFoundResult()
        {
            //Arrange
            var controller = new InventoriesController(repository);
            var inventid   = 5;

            //Act
            var data = await controller.GetInventory(inventid);

            //Assert
            Assert.IsType <NotFoundResult>(data.Result);
        }
Ejemplo n.º 5
0
        public async void Task_GetinventById_Return_OkResult()
        {
            //Arrange
            var controller = new InventoriesController(repository);
            var inventid   = 2;

            //Act
            var data = await controller.GetInventory(inventid);

            //Assert
            Assert.IsType <ActionResult <Inventory> >(data);
        }
Ejemplo n.º 6
0
        public async void Task_GetinventById_MatchResult()
        {
            //Arrange
            var  controller = new InventoriesController(repository);
            long inventid   = 1;

            //Act
            var data = await controller.GetInventory(inventid);

            //Assert
            Assert.IsType <OkObjectResult>(data.Result);

            var okResult = data.Result.Should().BeOfType <OkObjectResult>().Subject;

            Assert.IsType <OkObjectResult>(okResult);
        }
Ejemplo n.º 7
0
        public async void Task_Update_ValidData_Return_OkResult()
        {
            //Arrange
            var controller = new InventoriesController(repository);
            var inventId   = 2;

            //Act
            var existingPost = await controller.GetInventory(inventId);

            var okResult = existingPost.Result.Should().BeOfType <OkObjectResult>().Subject;

            var post = new Inventory();

            post.Name        = "Test name 2 Updated";
            post.Description = "description updated";
            post.Price       = 33;
            post.Image       = null;

            var updatedData = await controller.PutInventory(post);

            //Assert
            Assert.IsType <OkResult>(updatedData);
        }