public void Update_WithValidParameters_DeviceIsUpdated()
        {
            //Arrange
            var dbContext           = DbContextMocker.GetDbContext(nameof(Update_WithValidParameters_DeviceIsUpdated));
            var devicesController   = new DevicesController(dbContext);
            var updateDeviceRequest = new UpdateDeviceRequest
            {
                Name     = "updatedName",
                Location = "updatedLocation"
            };
            var expectedDevice = new Device
            {
                Device_id = 1,
                Name      = "updatedName",
                Location  = "updatedLocation"
            };

            //Act
            var response       = devicesController.Update(1, updateDeviceRequest);
            var result         = (ObjectResult)response.Result;
            var deviceReceived = result.Value.As <Device>();

            dbContext.Dispose();

            //Assert
            result.StatusCode.Should().Be((int)HttpStatusCode.OK);
            Assert.True(DevicesComparer.CompareDevices(deviceReceived, expectedDevice), "The device received is different " +
                        "than the expected.");
        }
        public async Task Create_WithValidParameters_DeviceIsAdded()
        {
            //Arrange
            var dbContext           = DbContextMocker.GetDbContext(nameof(Create_WithValidParameters_DeviceIsAdded));
            var devicesController   = new DevicesController(dbContext);
            var createDeviceRequest = new CreateDeviceRequest
            {
                Name     = "testName1",
                Location = "testLocation1"
            };
            var expectedDevice = new Device
            {
                Device_id = 4,
                Name      = "testName1",
                Location  = "testLocation1"
            };

            //Act
            var response = await devicesController.Create(createDeviceRequest);

            var result         = (ObjectResult)response.Result;
            var deviceReceived = result.Value.As <Device>();

            dbContext.Dispose();

            //Assert
            result.StatusCode.Should().Be((int)HttpStatusCode.Created);
            Assert.True(DevicesComparer.CompareDevices(deviceReceived, expectedDevice), "The device received is different " +
                        "than the expected.");
        }
        public async Task GetById_WithDeviceAvailable_ReturnsDevice()
        {
            //Arrange
            var dbContext         = DbContextMocker.GetDbContext(nameof(GetById_WithDeviceAvailable_ReturnsDevice));
            var devicesController = new DevicesController(dbContext);
            var expectedDevice    = new Device
            {
                Device_id = 1, Name = "testName1", Location = "testLocation1"
            };

            //Act
            var response = await devicesController.GetById(1);

            var result         = (ObjectResult)response.Result;
            var deviceReceived = result.Value.As <Device>();

            dbContext.Dispose();

            //Assert
            result.StatusCode.Should().Be((int)HttpStatusCode.OK);
            Assert.True(DevicesComparer.CompareDevices(deviceReceived, expectedDevice), "The device received is different " +
                        "than the expected.");
        }