public void Setup() { SimpleIoc.Default.Reset(); Messenger.Reset(); _currencyService = MockRepository.GenerateMock <IExternalCurrencyService>(); _currencyService.Stub(x => x.GetCurrentRates("EUR")).Repeat.Any().Return(Task.FromResult(new CurrentRatesDataObject( new Dictionary <string, float>() { { "PLN", 4.31484865f }, { "USD", 1.05874658f }, { "CZK", 25.7744486f }, }) )); _settingsProvider = MockRepository.GenerateMock <ISettingsProvider>(); _settingsProvider.Stub(x => x.GetValue <string>("baseCurrency")).Repeat.Any().Return("EUR"); _errorHandler = MockRepository.GenerateMock <IErrorHandler>(); _localCurrencyService = MockRepository.GenerateMock <ILocalCurrencyService>(); _navigator = MockRepository.GenerateMock <INavigator>(); SimpleIoc.Default.Register(() => _navigator); _mainViewModel = new MainViewModel(_currencyService, _settingsProvider, _errorHandler, _localCurrencyService); }
public void Setup() { SimpleIoc.Default.Reset(); _currencyService = MockRepository.GenerateMock <IExternalCurrencyService>(); _currencyService.Stub(x => x.GetHistoryRates("EUR", "PLN", DateTime.Today.AddDays(-30), DateTime.Today)).Repeat.Any().Return(Task.FromResult(new HistoryRatesDataObject { HistoryRates = new Dictionary <string, float>() { { "2019-04-20", 0.21054f }, { "2019-04-27", 0.21164f }, { "2019-05-04", 0.21004f }, { "2019-05-11", 0.21210f }, { "2019-05-18", 0.21698f }, } } )); _settingsProvider = MockRepository.GenerateMock <ISettingsProvider>(); _localCurrencyService = MockRepository.GenerateMock <ILocalCurrencyService>(); _rateViewModel = new RemoteRateViewModel("EUR", "PLN", 4.30f, _currencyService, _settingsProvider, _localCurrencyService, MockRepository.GenerateMock <IErrorHandler>()); }
public async Task RefreshedWithNewData_DisplayedDataChanged() { await _mainViewModel.Init(); _currencyService.ClearBehavior(); _currencyService.Stub(x => x.GetCurrentRates("EUR")).Repeat.Any().Return(Task.FromResult(new CurrentRatesDataObject(new Dictionary <string, float> { { "CZK", 27.05f }, { "PLN", 4.20f }, { "USD", 1.15f }, }))); await _mainViewModel.RefreshCommand.ExecuteAsync(); Assert.AreEqual("1.1500", _mainViewModel.Items[2].DisplayValue); }