Beispiel #1
0
        public void AreasControllerGetAllTest()
        {
            var FirstArea = new Area
            {
                Id   = Guid.NewGuid(),
                Name = "First Area",
            };

            var SecondArea = new Area
            {
                Id   = Guid.NewGuid(),
                Name = "Second Area",
            };

            var Logic      = new AreaLogic();
            var Controller = new AreasController(Logic);

            Logic.Create(FirstArea);
            Logic.Create(SecondArea);

            List <Area> Areas = new List <Area>()
            {
                FirstArea, SecondArea
            };

            var Result        = Controller.Get();
            var CreatedResult = Result as OkObjectResult;
            var AreaResults   = CreatedResult.Value as IEnumerable <AreaDTO>;

            Assert.AreEqual(Areas.Count, AreaResults.ToList().Count);
        }
Beispiel #2
0
        public void GetNotExistingArea()
        {
            var mock = new Mock <IAreaLogic>(MockBehavior.Strict);

            mock.Setup(m => m.Get(It.IsAny <Guid>())).Throws(new BusinessLogicInterfaceException());

            var controller = new AreasController(mock.Object);
            var result     = controller.Get(Guid.NewGuid());

            mock.VerifyAll();
            Assert.IsInstanceOfType(result, typeof(NotFoundObjectResult));
        }
Beispiel #3
0
        public void AreasControllerGetTest()
        {
            var Area = new Area
            {
                Id   = Guid.NewGuid(),
                Name = "First Area",
            };

            var Logic      = new AreaLogic();
            var Controller = new AreasController(Logic);

            Logic.Create(Area);

            var Result        = Controller.Get(Area.Id);
            var CreatedResult = Result as OkObjectResult;
            var Model         = CreatedResult.Value as AreaDTO;

            Assert.AreEqual(Area.Name, Model.Name);
        }
Beispiel #4
0
        public void GetAllAreas()
        {
            List <User> managers = new List <User>();
            User        user     = new User
            {
                Id       = Guid.NewGuid(),
                Name     = "Santiago",
                LastName = "Larralde",
                UserName = "******",
                Password = "******",
                Admin    = false
            };

            managers.Add(user);
            IEnumerable <Indicator> indicators = new List <Indicator>();
            AreaModel area = new AreaModel()
            {
                Name             = "Area1",
                ConnectionString = "ConnectionString",
                Id         = Guid.NewGuid(),
                Indicators = IndicatorModel.ToModel(indicators).ToList(),
            };


            List <Area> areas = new List <Area>();

            areas.Add(AreaModel.ToEntity(area));

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

            mock.Setup(m => m.GetAll()).Returns(areas);

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

            var createdResult = result as OkObjectResult;
            var models        = createdResult.Value as IEnumerable <AreaModel>;

            mock.VerifyAll();

            Assert.AreEqual(areas[0].Name, models.ToList <AreaModel>()[0].Name);
        }
        public void When()
        {
            var controller = new AreasController(Store);

            _areas = controller.Get().ToArray();
        }