コード例 #1
0
        public void GetAll_Positive_ReturnsList()
        {
            var dataRepo = new Mock <IDatabaseRepository>();
            List <Technology> technologies = GetMockDatabase();

            dataRepo.Setup(d => d.GetAllData()).Returns(technologies);
            SMEController sMEController = new SMEController(dataRepo.Object);

            var actionResult = sMEController.GetAll();

            var okObjectResult = actionResult as OkObjectResult;

            Assert.NotNull(okObjectResult);

            var model = okObjectResult.Value as List <Technology>;

            Assert.NotNull(model);

            Assert.Equal(technologies.Count, model.Count);
        }
コード例 #2
0
        public void GetAll_Negative_ReturnsEmptyList()
        {
            var dataRepo           = new Mock <IDatabaseRepository>();
            List <Technology> list = null;

            dataRepo.Setup(d => d.GetAllData()).Returns(list);
            SMEController sMEController = new SMEController(dataRepo.Object);

            var actionResult = sMEController.GetAll();

            var okObjectResult = actionResult as OkObjectResult;

            Assert.NotNull(okObjectResult);

            var model = okObjectResult.Value as List <Technology>;

            Assert.NotNull(model);
            int expected = 0;

            Assert.Equal(expected, model.Count);
        }