public async Task ShouldCreateSensorLogItemValueRandom() { var userId = await RunAsDefaultUserAsync(); var device = new CreateDeviceItemCommand { Name = "New Devices", }; var deviceId = await SendAsync(device); var item = await FindAsync <Sensor>(deviceId); var command = new CreateDeviceLogsCommand { Sensor = item }; var sensorLog = await SendAsync(command); var sensorItem = await FindAsync <SensorLog>(sensorLog); sensorItem.Should().NotBeNull(); sensorItem.CreatedBy.Should().Be(userId); sensorItem.LastModifiedBy.Should().BeNull(); sensorItem.LastModified.Should().BeNull(); }
public async Task ShouldCreateDeviceItem() { var thingsDesc = new CreateThingsDescCommand { Name = "HUE Dim Light", Value = "test" }; await SendAsync(thingsDesc); var userId = await RunAsDefaultUserAsync(); var device = new CreateDeviceItemCommand { Name = "New Devices", ThingsDescId = 1 }; var deviceId = await SendAsync(device); var item = await FindAsync <Sensor>(deviceId); item.Should().NotBeNull(); item.Name.Should().Be(device.Name); item.CreatedBy.Should().Be(userId); item.LastModifiedBy.Should().BeNull(); item.LastModified.Should().BeNull(); }
public void ShouldRequiredMinimumFields() { var command = new CreateDeviceItemCommand(); FluentActions.Invoking(() => SendAsync(command)).Should().Throw <ValidationException>(); }
public void ShouldThrownExceptionForLessThanEndTo() { var command = new CreateDeviceItemCommand { Name = "New Devices", }; FluentActions.Invoking(() => SendAsync(command)).Should().Throw <ValidationException>(); }
public async Task ShouldRerturnACorrectVM() { var userId = await RunAsDefaultUserAsync(); var device = new CreateDeviceItemCommand { Name = "New Devices", }; var deviceId = await SendAsync(device); var item = await FindAsync <Sensor>(deviceId); var command = new GetDeviceLogQuery() { SensorId = item.Id }; var deviceVm = await SendAsync(command); deviceVm.Device.Id.Should().Be(item.Id); deviceVm.Data.Should().NotBeNull(); }
public async Task ShouldThrowValidationException() { var userId = await RunAsDefaultUserAsync(); var device = new CreateDeviceItemCommand { Name = "New Devices", }; var deviceId = await SendAsync(device); var item = await FindAsync <Sensor>(deviceId); var command = new CreateDeviceLogsCommand { Sensor = item }; FluentActions.Invoking(() => SendAsync(command)).Should().Throw <ValidationException>(); }
public async Task <ActionResult <string> > Create(CreateDeviceItemCommand command) { return(await Mediator.Send(command)); }