public void Edit_CanExecute_WhenNoPatientIsSelected_ReturnsFalse()
        {
            var mockDialogService      = new MockDialogService();
            var mockPatientDataService = new MockPatientDataService();
            var sut = new MainWindowViewModel(mockDialogService, mockPatientDataService);

            var result = sut.Edit.CanExecute(null);

            Assert.IsFalse(result);
        }
        public void Constructor_LoadsAllPatients()
        {
            var mockDialogService      = new MockDialogService();
            var mockPatientDataService = new MockPatientDataService();
            var expected = mockPatientDataService.GetAllPatients();

            var sut    = new MainWindowViewModel(mockDialogService, mockPatientDataService);
            var result = sut.AllPatients.Select(x => x.Model);

            CollectionAssert.AreEqual(expected, result);
        }
Beispiel #3
0
        public async Task LogIn_ClosesDialog_WhenLoginRequestSucceeds()
        {
            MockCloudFoundryService.Setup(mock => mock.LoginWithCredentials(FakeTarget, FakeUsername, FakeSecurePw, _sut.ProceedWithInvalidCertificate))
            .ReturnsAsync(new DetailedResult(true, null));

            await _sut.LogIn(null);

            Assert.IsFalse(_sut.HasErrors);
            MockDialogService.Verify(mock => mock.CloseDialog(It.IsAny <object>(), It.IsAny <bool>()), Times.Once);
            MockDialogService.Verify(ds => ds.CloseDialog(It.IsAny <object>(), true), Times.Once);
        }
Beispiel #4
0
 protected override void TestInitializeExtensions()
 {
     _mockGetRootResult = new MockGetRootResult {
         GetResultFunc = () => new List <MusicFolder>()
     };
     MockSubsonicService.GetMusicFolders = () => _mockGetRootResult;
     _mockResourceService    = new MockResourceService();
     Subject.ResourceService = _mockResourceService;
     _mockDialogService      = new MockDialogService();
     Subject.DialogService   = _mockDialogService;
 }
        public void Edit_CanExecute_WhenPatientIsSelected_ReturnsTrue()
        {
            var mockDialogService      = new MockDialogService();
            var mockPatientDataService = new MockPatientDataService();
            var sut = new MainWindowViewModel(mockDialogService, mockPatientDataService);

            sut.SelectedPatient = sut.AllPatients.First();

            var result = sut.Edit.CanExecute(null);

            Assert.IsTrue(result);
        }
Beispiel #6
0
        public void TestProperties()
        {
            Button            expectedClearCoinReturnButton = new Button();
            MockCoinReturn    expectedCoinReturn            = new MockCoinReturn();
            MockDialogService expectedDialogService         = new MockDialogService();

            ClearCoinReturnButtonController clearCoinReturnButtonController = new ClearCoinReturnButtonController(expectedClearCoinReturnButton, expectedCoinReturn, expectedDialogService);

            Assert.AreSame(expectedCoinReturn, clearCoinReturnButtonController.CoinReturn);
            Assert.AreSame(expectedClearCoinReturnButton, clearCoinReturnButtonController.Button);
            Assert.AreSame(expectedDialogService, clearCoinReturnButtonController.DialogService);
        }
        public async Task DeleteApp_ClearsCfAppValue_AndClosesDialog_WhenDeleteAppAsyncSucceeds(bool deleteRoutes)
        {
            MockCloudFoundryService.Setup(m => m.DeleteAppAsync(_fakeCfApp, true, deleteRoutes, 1)).ReturnsAsync(FakeSuccessDetailedResult);

            Assert.AreEqual(_fakeCfApp, _sut.CfApp);
            _sut.DeleteRoutes = deleteRoutes;

            await _sut.DeleteApp(_fakeConfirmationWindow);

            Assert.IsNull(_sut.CfApp);
            MockDialogService.Verify(ds => ds.CloseDialog(_fakeConfirmationWindow, true), Times.Once);
        }
        public void Edit_Execute_OpensPatientDetailsDialog()
        {
            var mockDialogService      = new MockDialogService();
            var mockPatientDataService = new MockPatientDataService();
            var sut = new MainWindowViewModel(mockDialogService, mockPatientDataService);

            sut.SelectedPatient = sut.AllPatients.First();
            sut.Edit.Execute(null);

            var firstMethocCall = mockDialogService.InvocationList.First();

            Assert.AreEqual(nameof(mockDialogService.ShowDetailsDialog), firstMethocCall);
        }
Beispiel #9
0
        public async Task LogIn_SetsErrorMessage_WhenLoginRequestFails()
        {
            const string expectedErrorMessage = "my fake error message";

            MockCloudFoundryService.Setup(mock => mock.LoginWithCredentials(FakeTarget, FakeUsername, FakeSecurePw, _sut.ProceedWithInvalidCertificate))
            .ReturnsAsync(new DetailedResult(false, expectedErrorMessage));

            await _sut.LogIn(null);

            Assert.IsTrue(_sut.HasErrors);
            Assert.AreEqual(expectedErrorMessage, _sut.ErrorMessage);
            MockDialogService.Verify(ds => ds.CloseDialog(It.IsAny <object>(), true), Times.Never);
        }
        public void HandlePatientDeletedMessage_ClosesPatientDetailsDialog()
        {
            var mockDialogService      = new MockDialogService();
            var mockPatientDataService = new MockPatientDataService();
            var sut = new MainWindowViewModel(mockDialogService, mockPatientDataService);
            var dummyPatientViewModel = new PatientViewModel();

            Messenger.Default.Send(new PatientDeleteMessage(dummyPatientViewModel));

            var firstMethocCall = mockDialogService.InvocationList.First();

            Assert.AreEqual(nameof(mockDialogService.CloseDetailsDialog), firstMethocCall);
        }
Beispiel #11
0
        public void EditCommand_DisplaysNewDialog()
        {
            //arrange
            var mockDialgoService = new MockDialogService();
            var mockDataService   = new MockDataService();
            var sut = new MainWindowViewModel(mockDialgoService, mockDataService);

            //act
            sut.EditCommand.Execute(null);

            //assert
            Assert.IsTrue(mockDialgoService.Was_ShowPatientDetailDialog_Called);
        }
 public void Setup()
 {
     _mockWinRTWrapperService = new MockWinRTWrappersService();
     _mockNavigationService = new MockNavigationService();
     _mockDialogNotificationService = new MockDialogNotificationService();
     _mockResourceService = new MockResourceService();
     _mockDialogService = new MockDialogService();
     _subject = new ErrorDialogViewModel(
         _mockWinRTWrapperService,
         _mockNavigationService,
         _mockDialogNotificationService,
         _mockResourceService,
         _mockDialogService);
 }
        public async Task DeleteApp_LogsError_DisplaysError_ClearsCfAppValue_AndClosesDialog_WhenDeleteAppAsyncFails(bool deleteRoutes)
        {
            MockCloudFoundryService.Setup(m => m.DeleteAppAsync(_fakeCfApp, true, deleteRoutes, 1)).ReturnsAsync(FakeFailureDetailedResult);

            Assert.AreEqual(_fakeCfApp, _sut.CfApp);
            _sut.DeleteRoutes = deleteRoutes;

            await _sut.DeleteApp(_fakeConfirmationWindow);

            Assert.IsNull(_sut.CfApp);
            MockDialogService.Verify(ds => ds.CloseDialog(_fakeConfirmationWindow, true), Times.Once);
            MockLogger.Verify(m => m.Error(It.Is <string>(s => s.Contains(AppDeletionConfirmationViewModel._deleteAppErrorMsg)), It.Is <string>(s => s == _fakeCfApp.AppName), It.Is <string>(s => s == FakeFailureDetailedResult.ToString())), Times.Once);
            MockErrorDialogService.Verify(m => m.DisplayErrorDialog(It.Is <string>(s => s.Contains(AppDeletionConfirmationViewModel._deleteAppErrorMsg) && s.Contains(_fakeCfApp.AppName)), It.Is <string>(s => s.Contains(FakeFailureDetailedResult.Explanation))), Times.Once);
        }
 public void Setup()
 {
     _mockWinRTWrapperService       = new MockWinRTWrappersService();
     _mockNavigationService         = new MockNavigationService();
     _mockDialogNotificationService = new MockDialogNotificationService();
     _mockResourceService           = new MockResourceService();
     _mockDialogService             = new MockDialogService();
     _subject = new ErrorDialogViewModel(
         _mockWinRTWrapperService,
         _mockNavigationService,
         _mockDialogNotificationService,
         _mockResourceService,
         _mockDialogService);
 }
Beispiel #15
0
        public async Task LogIn_SetsConnectionOnTasExplorer_WhenLoginRequestSucceeds()
        {
            MockCloudFoundryService.Setup(mock => mock.
                                          LoginWithCredentials(FakeTarget, FakeUsername, FakeSecurePw, _sut.ProceedWithInvalidCertificate))
            .ReturnsAsync(new DetailedResult(true, null));

            MockTasExplorerViewModel.Setup(m => m.SetConnection(It.IsAny <CloudFoundryInstance>())).Verifiable();

            await _sut.LogIn(null);

            Assert.IsFalse(_sut.HasErrors);
            MockDialogService.Verify(mock => mock.CloseDialog(It.IsAny <object>(), It.IsAny <bool>()), Times.Once);
            MockDialogService.Verify(ds => ds.CloseDialog(It.IsAny <object>(), true), Times.Once);

            MockTasExplorerViewModel.Verify(m => m.SetConnection(It.Is <CloudFoundryInstance>(cf => cf.ApiAddress == FakeTarget)), Times.Once);
        }
        public async Task DeleteApp_LogsError_DisplaysError_ClearsCfAppValue_AndClosesDialog_WhenDeleteAppAsyncThrowsException(bool deleteRoutes)
        {
            var fakeExceptionMsg = "something went wrong in DeleteAppAsync ;)";

            MockCloudFoundryService.Setup(m => m.DeleteAppAsync(_fakeCfApp, true, deleteRoutes, 1)).Throws(new Exception(fakeExceptionMsg));

            Assert.AreEqual(_fakeCfApp, _sut.CfApp);
            _sut.DeleteRoutes = deleteRoutes;

            await _sut.DeleteApp(_fakeConfirmationWindow);

            Assert.IsNull(_sut.CfApp);
            MockDialogService.Verify(ds => ds.CloseDialog(_fakeConfirmationWindow, true), Times.Once);
            MockLogger.Verify(m => m.Error(It.Is <string>(s => s.Contains(AppDeletionConfirmationViewModel._deleteAppErrorMsg)), It.Is <string>(s => s == _fakeCfApp.AppName), It.Is <string>(s => s == fakeExceptionMsg)), Times.Once);
            MockErrorDialogService.Verify(m => m.DisplayErrorDialog(It.Is <string>(title => title.Contains(AppDeletionConfirmationViewModel._deleteAppErrorMsg) && title.Contains(_fakeCfApp.AppName)), It.Is <string>(msg => msg.Contains("Something unexpected happened") && msg.Contains(_fakeCfApp.AppName))), Times.Once);
        }
Beispiel #17
0
        public void TestClickingButtonDoesNotDisplayDialogIfAmountReturnedIsZero()
        {
            Button            clearCoinReturnButton = new Button();
            MockCoinReturn    mockCoinReturn        = new MockCoinReturn();
            MockDialogService mockDialogService     = new MockDialogService();

            mockCoinReturn.ValueToReturnFromClear = 0;

            new ClearCoinReturnButtonController(clearCoinReturnButton, mockCoinReturn, mockDialogService);

            Assert.AreEqual(0, mockDialogService.NumberOfTimesShowMessageWasCalled);

            clearCoinReturnButton.PerformClick();

            Assert.AreEqual(0, mockDialogService.NumberOfTimesShowMessageWasCalled);
        }
Beispiel #18
0
        public void TestClickingButtonDisplaysDialogInformingUserOfAmountReturedFromClear(decimal amountReturnedByCoinReturn, string expectedFormatedAmount)
        {
            Button            clearCoinReturnButton = new Button();
            MockCoinReturn    mockCoinReturn        = new MockCoinReturn();
            MockDialogService mockDialogService     = new MockDialogService();

            mockCoinReturn.ValueToReturnFromClear = amountReturnedByCoinReturn;
            string expectedDialogText = "You receive: " + expectedFormatedAmount;

            new ClearCoinReturnButtonController(clearCoinReturnButton, mockCoinReturn, mockDialogService);

            Assert.AreEqual(0, mockDialogService.NumberOfTimesShowMessageWasCalled);

            clearCoinReturnButton.PerformClick();

            Assert.AreEqual(1, mockDialogService.NumberOfTimesShowMessageWasCalled);
            Assert.AreEqual(expectedDialogText, mockDialogService.LastMessageShown);
        }
Beispiel #19
0
        public async Task LoginWithPasscodeAsync_SetsConnection_AndClosesSsoDialog_AndClosesLoginDialog_WhenLoginAttemptSucceeds()
        {
            const string fakePasscode        = "fake sso passcode!";
            object       fakeSsoDialogWindow = new object();
            var          fakeParentViewModel = MockLoginViewModel.Object;

            MockCloudFoundryService.Setup(m => m.LoginWithSsoPasscode(_sut.ApiAddress, fakePasscode))
            .ReturnsAsync(FakeSuccessDetailedResult);

            _sut.Passcode        = fakePasscode;
            _sut._loginViewModel = fakeParentViewModel;

            Assert.IsFalse(_sut.HasErrors);
            Assert.IsNull(_sut.ErrorMessage);

            await _sut.LoginWithPasscodeAsync(fakeSsoDialogWindow);

            Assert.IsFalse(_sut.HasErrors);
            Assert.IsNull(_sut.ErrorMessage);

            MockDialogService.Verify(m => m.CloseDialog(fakeSsoDialogWindow, true), Times.Once);
            MockLoginViewModel.Verify(m => m.SetConnection(), Times.Once);
            MockLoginViewModel.Verify(m => m.CloseDialog(), Times.Once);
        }
Beispiel #20
0
 public void TestCleanup()
 {
     MockCloudFoundryService.VerifyAll();
     MockDialogService.VerifyAll();
     MockLoginViewModel.VerifyAll();
 }
Beispiel #21
0
        public void CloseDialog_WrapsDialogServiceCloseDialogByName()
        {
            _sut.CloseDialog();

            MockDialogService.Verify(m => m.CloseDialogByName(nameof(LoginViewModel), null), Times.Once);
        }
        public void ShowConfirmation_RecordsAppValue_AndDisplaysDeletionConfirmationDialog()
        {
            _sut.ShowConfirmation(_fakeCfApp);

            MockDialogService.Verify(ds => ds.ShowDialog(nameof(AppDeletionConfirmationViewModel), null), Times.Once);
        }