Esempio n. 1
0
        public void GetPositions()
        {
            // Arrange
            PositionController controller = new PositionController();

            // Act
            JsonResult result = controller.GetPositions(1);
            JsonGetPositionResultModel resData = null;
            string errMsg = "";

            try
            {
                resData = (JsonGetPositionResultModel)result.Data;
            }
            catch (Exception ex)
            {
                errMsg  = ex.Message;
                resData = null;
            }
            // Assert
            Assert.IsNotNull(result.Data);
            Assert.AreEqual("", errMsg);
            Assert.IsNotNull(resData);
            Assert.AreEqual(true, resData.result);
            Assert.AreNotEqual(0, resData.data.Count);
        }
        public void GetPositions()
        {
            // Arrange

            // Act
            var positions = _positionController.GetPositions().Value.ToList();

            // Assert
            Assert.Equal(3, positions.Count());
        }
        public void GetPositions_ReturnsListOfPositions()
        {
            PositionController controller = new PositionController(_dbContext);
            OkObjectResult     result     = controller.GetPositions() as OkObjectResult;

            Assert.Multiple((() => {
                Assert.That(result, Is.Not.Null);

                Position[] value = (result.Value as ContentModel <Position>)?.Content.ToArray();
                Assert.That(value, Is.Not.Null);
                Assert.That(value.Count(), Is.GreaterThan(0));
                Assert.That(value.FirstOrDefault(position => position.Id == 1), Is.Not.Null);
            }));
        }