Пример #1
0
        public void ReturnAddValueTypeModel(ValueTypeViewModel model)
        {
            var sensorRepo = new Mock <ISensorsRepository>();

            sensorRepo.Setup(s => s.GetById(model.SensorId)).Returns(GetSensors().FirstOrDefault(s => s.Id == model.SensorId));

            var sensorValueTypeRepo = new Mock <IValueTypesRepository>();

            sensorValueTypeRepo.Setup(s => s.Create(It.IsAny <ValueType>())).Returns(true);

            var _sensorsManager = new SensorsManager(sensorRepo.Object, sensorValueTypeRepo.Object, null);

            var sensorController = new SensorController(_sensorsManager, null);

            var result = sensorController.AddValueType(model).Result;

            var redirectToActionResult = Assert.IsType <RedirectToActionResult>(result);

            Assert.Equal("Info", redirectToActionResult.ActionName);
        }
Пример #2
0
        public void ReturnAddValueType(string id)
        {
            var sensorId = Guid.Parse(id);

            var sensorRepo = new Mock <ISensorsRepository>();

            sensorRepo.Setup(s => s.GetById(sensorId)).Returns(GetSensors().FirstOrDefault(s => s.Id == sensorId));

            var _sensorsManager = new SensorsManager(sensorRepo.Object, null, null);

            var sensorController = new SensorController(_sensorsManager, null);

            var result = sensorController.AddValueType(sensorId).Result;

            var viewResult = Assert.IsType <ViewResult>(result);
            var model      = Assert.IsType <ValueTypeViewModel>(viewResult.ViewData.Model);

            Assert.Null(model.Name);
            Assert.Equal(Guid.Empty, model.Id);
            Assert.Equal(sensorId, model.SensorId);
            Assert.Equal(PayloadType.String, model.Type);
        }