Пример #1
0
        public void ReturnEditSensorView_WhenSensorByIdIsValid()
        {
            // Arrange
            var sensorServiceMock = new Mock <ISensorService>();
            var httpClientMock    = new Mock <HttpClientProvider>();

            var controller = new SensorController(sensorServiceMock.Object,
                                                  httpClientMock.Object);

            controller.UserMocking("test");

            var sensor = new SensorDataModel()
            {
                OwnerId = It.IsAny <string>()
            };

            sensorServiceMock.Setup(s => s.GetUserSensorById(It.IsAny <int>()))
            .Returns(sensor);

            // Act
            controller.EditSensor(It.IsAny <int>());

            // Assert
            controller.WithCallTo(c => c.EditSensor(It.IsAny <int>()))
            .ShouldRenderView("EditSensor");
        }
Пример #2
0
        public void ReturnEditSensorView_WhenSensorByIdIsValid()
        {
            // Arrange
            var sensorServiceMock = new Mock <ISensorService>();
            var httpClientMock    = new Mock <HttpClientProvider>();

            sensorServiceMock.Setup(s => s.GetUserSensorById(It.IsAny <int>()))
            .Returns <SensorDataModel>(null);

            var controller = new SensorController(sensorServiceMock.Object,
                                                  httpClientMock.Object);



            // Act
            controller.EditSensor(It.IsAny <int>());

            // Assert
        }
Пример #3
0
        public void ReturnNotAuthenticatedView_WhenSensorByIdIsNull()
        {
            // Arrange
            var sensorServiceMock = new Mock <ISensorService>();
            var httpClientMock    = new Mock <HttpClientProvider>();

            var controller = new SensorController(sensorServiceMock.Object,
                                                  httpClientMock.Object);

            int someInvalidid = -1;

            sensorServiceMock.Setup(s => s.GetUserSensorById(someInvalidid))
            .Returns <SensorDataModel>(null);

            // Act
            controller.EditSensor(someInvalidid);

            // Assert
            controller.WithCallTo(c => c.EditSensor(someInvalidid))
            .ShouldRenderView("NotAuthenticated");
        }