public void ShouldCreateDeviceRoom()
        {
            var communicatorMock = new Mock <ICommunicator>();
            var viewModel        = new DeviceOverviewPageModel(communicatorMock.Object, new Mock <IEventAggregator>().Object);

            viewModel.NewObjectCommand.Execute(null);

            communicatorMock.Verify(x => x.SendAsync(It.Is <CreateDeviceDataRequest>(y => y.ClientObjectIdentifier == 0x01 && y.Description == "New device")));
        }
        public void ShouldNavigateToDevice()
        {
            const int deviceId            = 3;
            var       eventAggregatorMock = new Mock <IEventAggregator>();
            var       viewModel           = new DeviceOverviewPageModel(new Mock <ICommunicator>().Object, eventAggregatorMock.Object);

            viewModel.NavigateToObjectCommand.Execute(deviceId);

            eventAggregatorMock.Verify(x => x.PublishAsync(It.Is <NavigationEvent>(y => y.ViewType == typeof(DeviceDetailPage) && (int)y.Parameter == deviceId)));
        }
Esempio n. 3
0
        public async void ShouldSendGetDeviceDescriptionRequestForAllDevicesOnReceiveGetAllDevicesResponse()
        {
            var communicatorMock = new Mock <ICommunicator>();

            var viewModel = new DeviceOverviewPageModel(communicatorMock.Object, new Mock <IEventAggregator>().Object);
            await viewModel.LoadedAsync(null);

            communicatorMock.Raise(x => x.ReceiveData += null, new GetAllDevicesDataResponse {
                Identifiers = new[] { 1, 2, 3 }
            });

            communicatorMock.Verify(x => x.SendAsync(It.Is <IRequest>(y => y is GetDeviceDescriptionDataRequest && ((GetDeviceDescriptionDataRequest)y).Identifier == 1)));
            communicatorMock.Verify(x => x.SendAsync(It.Is <IRequest>(y => y is GetDeviceDescriptionDataRequest && ((GetDeviceDescriptionDataRequest)y).Identifier == 2)));
            communicatorMock.Verify(x => x.SendAsync(It.Is <IRequest>(y => y is GetDeviceDescriptionDataRequest && ((GetDeviceDescriptionDataRequest)y).Identifier == 3)));
        }
Esempio n. 4
0
        public async void ShouldResetDevicesViewModelOnReceiveGetAllDevicesResponse()
        {
            var communicatorMock = new Mock <ICommunicator>();

            var viewModel = new DeviceOverviewPageModel(communicatorMock.Object, new Mock <IEventAggregator>().Object);
            await viewModel.LoadedAsync(null);

            communicatorMock.Raise(x => x.ReceiveData += null, new GetAllDevicesDataResponse {
                Identifiers = new[] { 1, 2, 3 }
            });

            viewModel.Objects.Should().HaveCount(3);
            viewModel.Objects[0].Id.Should().Be(1);
            viewModel.Objects[1].Id.Should().Be(2);
            viewModel.Objects[2].Id.Should().Be(3);
        }
Esempio n. 5
0
        public async void ShouldAddNewDeviceOnReceiveCreateDeviceDataResponse()
        {
            var communicatorMock = new Mock <ICommunicator>();

            var viewModel = new DeviceOverviewPageModel(communicatorMock.Object, new Mock <IEventAggregator>().Object);
            await viewModel.LoadedAsync(null);

            await viewModel.NewObjectCommand.Execute(null);

            communicatorMock.Raise(x => x.ReceiveData += null, new CreateDeviceDataResponse {
                Identifier = 3, ClientObjectIdentifier = 0x01
            });

            viewModel.Objects.Should().HaveCount(1);
            viewModel.Objects[0].Id.Should().Be(3);
            viewModel.Objects[0].Description.Should().Be("New device");
        }
Esempio n. 6
0
        public async void ShouldSetDeviceDescriptionOnReceiveGetDeviceDescriptionResponse()
        {
            var communicatorMock = new Mock <ICommunicator>();

            var viewModel = new DeviceOverviewPageModel(communicatorMock.Object, new Mock <IEventAggregator>().Object);
            await viewModel.LoadedAsync(null);

            viewModel.Objects.Add(new DeviceViewModel {
                Id = 1
            });

            communicatorMock.Raise(x => x.ReceiveData += null, new GetDeviceDescriptionDataResponse {
                Identifier = 1, Description = "Airing"
            });

            viewModel.Objects[0].Description.Should().Be("Airing");
        }