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)); }
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); }
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(); }