Exemplo n.º 1
0
        public void CreateNotVaidArea()
        {
            var mock = new Mock <IAreaLogic>(MockBehavior.Strict);

            mock.Setup(m => m.CreateArea(null)).Throws(new BusinessLogicInterfaceException());

            var controller = new AreasController(mock.Object);
            var result     = controller.Post(null);

            mock.VerifyAll();
            Assert.IsInstanceOfType(result, typeof(BadRequestObjectResult));
        }
Exemplo n.º 2
0
        public void AreaControllerPostTest()
        {
            var Area = new Area
            {
                Id   = Guid.NewGuid(),
                Name = "First Area",
            };

            var Logic         = new AreaLogic();
            var Controller    = new AreasController(Logic);
            var result        = Controller.Post(AreaDTO.ToModel(Area));
            var createdResult = result as CreatedAtRouteResult;
            var model         = createdResult.Value as AreaDTO;

            Assert.AreEqual(Area.Name, model.Name);
        }
Exemplo n.º 3
0
        public void CreateAreaOk()
        {
            IEnumerable <Indicator> indicators = new List <Indicator>();
            AreaModel area = new AreaModel()
            {
                Name             = "Area1",
                ConnectionString = "ConnectionString",
                Id         = Guid.NewGuid(),
                Indicators = IndicatorModel.ToModel(indicators).ToList(),
            };

            var mock = new Mock <IAreaLogic>(MockBehavior.Strict);

            mock.Setup(m => m.CreateArea(It.IsAny <Area>())).Returns(area.ToEntity);

            var controller    = new AreasController(mock.Object);
            var result        = controller.Post(area);
            var createdResult = result as CreatedAtRouteResult;

            mock.VerifyAll();
        }