public MainViewModel()
        {
            _informationEngine = new InformationEngine();
            _sessionViewModels =
                _informationEngine.Sessions.CreateDerivedCollection(x => new SessionViewModel(x) as ISessionViewModel);
            ((IEditableCollectionView)(CollectionViewSource.GetDefaultView(_sessionViewModels)))
            .NewItemPlaceholderPosition = NewItemPlaceholderPosition.AtEnd;

            _showInitializationErrorMessage = () => MessageBox.Show(
                "Bei der Initialisierung des Receivers ist ein Fehler aufgetreten.\n" +
                "Bitte schließen Sie die Session und starten den Receiver neu.",
                "Fehler");

            _showCloseSessionErrorMessage = () => MessageBox.Show(
                "Beim Schließen der Session trat ein Fehler auf.",
                "Fehler");

            StartNewSessionCommand = new ReactiveCommand();
            StartNewSessionCommand.Subscribe(_ => StartNewSession());

            InitializeReceiverCommand = new ReactiveAsyncCommand();
            InitializeReceiverCommand.RegisterAsyncAction(x => InitializeReceiver((Tuple <Guid, IReceiver>)x));
            InitializeReceiverCommand.ThrownExceptions.Subscribe(
                ex => _showInitializationErrorMessage());

            CloseSessionCommand = new ReactiveCommand();
            CloseSessionCommand.Subscribe(x => CloseSession((ISessionViewModel)x));
            CloseSessionCommand.ThrownExceptions.Subscribe(ex => _showCloseSessionErrorMessage());
        }
Example #2
0
        private void ProcessTheCsvFile(string filePath)
        {
            var diagnoseOutputEntries = ReadAllEntriesFromFile(filePath);

            foreach (var diagnoseOutputEntry in diagnoseOutputEntries)
            {
                InformationEngine.ProcessNewDiagnoseOutputEntry(diagnoseOutputEntry, SessionId);
            }
        }
        public void AddSession_Normal_AddsTheSessionAndReturnsTheSessionId()
        {
            var receiverMock = new Mock <IReceiver>();
            var analysisMock = new Mock <IAnalysis>();

            var informationEngine = new InformationEngine();

            var newSessionId = informationEngine.AddSession(receiverMock.Object, analysisMock.Object);

            informationEngine.Sessions.Any().Should().BeTrue();
            newSessionId.Should().NotBeEmpty();
        }
        public void DeleteSession_ExistingGuid_DeletesTheSession()
        {
            var receiverMock = new Mock <IReceiver>();
            var analysisMock = new Mock <IAnalysis>();

            var informationEngine = new InformationEngine();

            var newSessionId = informationEngine.AddSession(receiverMock.Object, analysisMock.Object);

            informationEngine.DeleteSession(newSessionId);

            informationEngine.Sessions.Any().Should().BeFalse();
        }
Example #5
0
        public void GetEndpoints_HappyPath()
        {
            var request = new InformationRequest
            {
                CompanyName = _CompanyName,
                Username    = _Username,
                Endpoint    = _Endpoint,
                Size        = _Size
            };

            var entity = new string[] {
                ""
            };

            var mockRepository = Substitute.For <IInformationRepository>();

            mockRepository.GetEndpoints(_Endpoint, _CompanyName, _Username, _Size).Returns(entity);

            var engine   = new InformationEngine(mockRepository);
            var response = engine.GetEndpoints(request);

            Assert.AreEqual(entity[0], response[0]);
        }
        public void DeleteSession_NonExistingGuid_Throws()
        {
            var informationEngine = new InformationEngine();

            informationEngine.DeleteSession(Guid.NewGuid());
        }