public async void DeleteDeviceTest()
        {
            var deviceID = _fixture.Create <string>();

            _deviceLogicMock.Setup(mock => mock.RemoveDeviceAsync(deviceID)).Returns(Task.FromResult(true));
            await _deviceController.DeleteDevice(deviceID);

            _deviceLogicMock.Verify(mock => mock.RemoveDeviceAsync(deviceID), Times.Once());
        }
        public async void TestDeleteDevice()
        {
            var mockRepository = new Mock <IDeviceRepository>();
            var mockMapper     = new Mock <IMapper>();

            var deviceController = new DeviceController(mockRepository.Object, mockMapper.Object);

            var result = await deviceController.DeleteDevice(1);

            var x = result as NotFoundResult;

            Assert.Equal(404, x.StatusCode);
        }
Exemplo n.º 3
0
        public async void PostPutDelete()
        {
            Device device = new Device {
                Name = "ESP32", Location = "Kitchen", MACAddress = "F0:AE:EA:EA:EA:EA"
            };

            var createdResult = (await DeviceController.PostDevice(device));


            Assert.IsType <CreatedAtActionResult>(createdResult.Result);

            device.Name     = "UpdateESP32";
            device.Location = "Entrance";

            var putNoContentResult = await DeviceController.PutDevice(device.DeviceId, device);

            Assert.IsType <NoContentResult>(putNoContentResult);

            var deleteNoContentResult = await DeviceController.DeleteDevice(device.DeviceId);

            Assert.IsType <NoContentResult>(deleteNoContentResult);
        }