예제 #1
0
        public void AreasControllerUpdateTest()
        {
            var AreaId     = Guid.NewGuid();
            var Logic      = new AreaLogic();
            var Controller = new AreasController(Logic);

            var Area = new Area
            {
                Id   = AreaId,
                Name = "First Area",
            };

            Logic.Create(Area);

            AreaDTO UpdatedArea = new AreaDTO()
            {
                Id   = AreaId,
                Name = "Updated Area"
            };

            var result        = Controller.Put(AreaId, UpdatedArea);
            var createdResult = result as CreatedAtRouteResult;
            var model         = createdResult.Value as AreaDTO;

            Assert.AreEqual("Updated Area", model.Name);
        }
예제 #2
0
        public void UpdateArea()
        {
            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.UpdateArea(It.IsAny <Area>())).Returns(area.ToEntity());

            var controller    = new AreasController(mock.Object);
            var result        = controller.Put(area.Id, area);
            var createdResult = result as OkObjectResult;

            mock.VerifyAll();
        }