예제 #1
0
        public void ShouldCreateNewDevice()
        {
            var requestHandler = new CreateDeviceRequestHandler();

            var response = (CreateDeviceDataResponse)requestHandler.Handle(new CreateDeviceDataRequest {
                ClientObjectIdentifier = 0x54, Description = "New device description"
            });

            response.ClientObjectIdentifier.Should().Be(0x54);
            response.Identifier.Should().Be(0x01);
            using (var context = new ServerDatabaseContext())
            {
                var devices = context.Devices.ToList();
                devices.Should().HaveCount(1);
                devices[0].Description.Should().Be("New device description");
                devices[0].Id.Should().Be(0x01);
            }
        }
        public void Execute(object parameter)
        {
            CreateDeviceRequestHandler deviceHandler = new CreateDeviceRequestHandler(new DeviceRepository());
            Random random = new Random();
            int    port   = random.Next(16000, 16100);

            CreateDeviceRequest request = new CreateDeviceRequest()
            {
                Device = new Device(port)
                {
                    Id          = Guid.NewGuid(),
                    Name        = "Aspirator",
                    DeviceState = DeviceState.Active
                }
            };

            deviceHandler.Handle(request).Wait();
        }