Exemple #1
0
        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();
        }
Exemple #2
0
        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();
        }
Exemple #3
0
        public void ShouldRequiredMinimumFields()
        {
            var command = new CreateDeviceItemCommand();

            FluentActions.Invoking(() =>
                                   SendAsync(command)).Should().Throw <ValidationException>();
        }
Exemple #4
0
        public void ShouldThrownExceptionForLessThanEndTo()
        {
            var command = new CreateDeviceItemCommand
            {
                Name = "New Devices",
            };

            FluentActions.Invoking(() =>
                                   SendAsync(command)).Should().Throw <ValidationException>();
        }
Exemple #5
0
        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();
        }
Exemple #6
0
        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>();
        }
Exemple #7
0
 public async Task <ActionResult <string> > Create(CreateDeviceItemCommand command)
 {
     return(await Mediator.Send(command));
 }