Commit 5997656
Changed files (8)
product
desktop.ui
presenters
views
service
handlers
specs
unit
ui
presenters
product/desktop.ui/presenters/StockViewModel.cs
@@ -7,11 +7,11 @@ namespace solidware.financials.windows.ui.presenters
public StockViewModel(string symbol)
{
Symbol = symbol;
- Price = 0m.ToObservable();
+ Price = Money.Null;
}
public string Symbol { get; set; }
- public Observable<decimal> Price { get; set; }
+ public Observable<Money> Price { get; set; }
public bool IsFor(string symbol)
{
product/desktop.ui/presenters/StockWatchPresenter.cs
@@ -29,7 +29,7 @@ namespace solidware.financials.windows.ui.presenters
public void present()
{
- timer.start_notifying(this, new TimeSpan(0, 1, 0));
+ timer.start_notifying(this, new TimeSpan(0, 0, 10));
AddSymbol = builder.build<AddSymbolCommand>(this);
refresh_command = builder.build<RefreshStockPricesCommand>(this);
}
product/desktop.ui/views/Shell.xaml.cs
@@ -41,7 +41,11 @@ namespace solidware.financials.windows.ui.views
public void region<Region>(Action<Region> configure) where Region : UIElement
{
ensure_that_the_region_exists<Region>();
- configure(regions[typeof (Region)].downcast_to<Region>());
+ Action action = () =>
+ {
+ configure(regions[typeof (Region)].downcast_to<Region>());
+ };
+ Dispatcher.BeginInvoke(action);
}
public void region<Region>(Configuration<Region> configuration) where Region : UIElement
product/desktop.ui/views/StockWatch.xaml
@@ -6,7 +6,7 @@
<DataTemplate>
<DockPanel>
<Label Content="{Binding Path=Symbol}" DockPanel.Dock="Left" Width="90"></Label>
- <Label Content="{Binding Path=Price}" DockPanel.Dock="Right" HorizontalAlignment="Right" HorizontalContentAlignment="Right"></Label>
+ <Label Content="{Binding Path=Price.Value}" DockPanel.Dock="Right" HorizontalAlignment="Right" HorizontalContentAlignment="Right"></Label>
</DockPanel>
</DataTemplate>
</ListView.ItemTemplate>
product/messages/CurrentStockPrice.cs
@@ -7,5 +7,10 @@ namespace solidware.financials.messages
{
public string Symbol { get; set; }
public decimal Price { get; set; }
+
+ public override string ToString()
+ {
+ return "{0}: {1:C}".format(Symbol, Price);
+ }
}
}
\ No newline at end of file
product/messages/StartWatchingSymbol.cs
@@ -6,5 +6,10 @@ namespace solidware.financials.messages
public class StartWatchingSymbol : ValueType<StartWatchingSymbol>, Event
{
public string Symbol { get; set; }
+
+ public override string ToString()
+ {
+ return "I will start watching {0}".format(Symbol);
+ }
}
}
\ No newline at end of file
product/service/handlers/StockPriceLookupService.cs
@@ -1,4 +1,6 @@
-namespace solidware.financials.service.handlers
+using System;
+
+namespace solidware.financials.service.handlers
{
public interface StockPriceLookupService
{
@@ -9,7 +11,7 @@
{
public decimal FindPriceFor(string symbol)
{
- return 24.00m;
+ return Convert.ToDecimal(new Random().NextDouble());
}
}
}
\ No newline at end of file
product/specs/unit/ui/presenters/StockWatchPresenterSpecs.cs
@@ -82,7 +82,7 @@ namespace specs.unit.ui.presenters
{
sut.Stocks.Add(new StockViewModel(symbol:"ARX.TO")
{
- Price = 20.00m.ToObservable()
+ Price = new Money(20.00m).ToObservable(),
});
};
@@ -93,7 +93,7 @@ namespace specs.unit.ui.presenters
It should_display_the_new_price = () =>
{
- sut.Stocks.Last().Price.Value.should_be_equal_to(25.50m);
+ sut.Stocks.Last().Price.Value.should_be_equal_to(new Money(25.50m));
};
}