mirror of
https://github.com/mgroves/MonodroidStockPortfolio.git
synced 2024-12-26 19:34:49 +00:00
reorganized tests, fixed ticker validation (thanks to monkey), other minor cleanup
This commit is contained in:
parent
50fb96b5b5
commit
3d31d52493
37 changed files with 51 additions and 67 deletions
|
@ -31,6 +31,8 @@
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
|
<AndroidUseSharedRuntime>True</AndroidUseSharedRuntime>
|
||||||
|
<AndroidLinkMode>SdkOnly</AndroidLinkMode>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="mscorlib" />
|
<Reference Include="mscorlib" />
|
||||||
|
|
|
@ -51,6 +51,10 @@ namespace MonoStockPortfolio.Core.StockData
|
||||||
// if it can't find the ticker
|
// if it can't find the ticker
|
||||||
public bool IsValidTicker(string ticker)
|
public bool IsValidTicker(string ticker)
|
||||||
{
|
{
|
||||||
|
if(string.IsNullOrEmpty(ticker))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
var quote = GetStockQuotes(new[] {ticker}).Single();
|
var quote = GetStockQuotes(new[] {ticker}).Single();
|
||||||
return quote.LastTradePrice > 0.0M;
|
return quote.LastTradePrice > 0.0M;
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,36 +61,35 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Framework\When_validating_forms_with_validation_errors.cs" />
|
<Compile Include="Framework\When_validating_forms_with_validation_errors.cs" />
|
||||||
<Compile Include="MetaTests.cs" />
|
<Compile Include="MetaTests.cs" />
|
||||||
<Compile Include="Presenters\Given_an_initialized_Config_Presenter.cs" />
|
<Compile Include="Presenters\Config\Given_an_initialized_Config_Presenter.cs" />
|
||||||
<Compile Include="Presenters\EditPortfolioTests.cs" />
|
<Compile Include="Presenters\EditPortfolio\EditPortfolioTests.cs" />
|
||||||
<Compile Include="Presenters\EditPositionTests.cs" />
|
<Compile Include="Presenters\EditPosition\EditPositionTests.cs" />
|
||||||
<Compile Include="Presenters\MainPresenterTests.cs" />
|
<Compile Include="Presenters\Main\MainPresenterTests.cs" />
|
||||||
<Compile Include="Presenters\PortfolioPresenterTests.cs" />
|
<Compile Include="Presenters\Portfolio\PortfolioPresenterTests.cs" />
|
||||||
<Compile Include="Presenters\When_done_initializing_a_Portfolio_Presenter.cs" />
|
<Compile Include="Presenters\Portfolio\When_done_initializing_a_Portfolio_Presenter.cs" />
|
||||||
<Compile Include="Presenters\When_initialize_the_config_presenter.cs" />
|
<Compile Include="Presenters\Config\When_initialize_the_config_presenter.cs" />
|
||||||
<Compile Include="Presenters\When_initializing_the_edit_portfolio_presenter_with_an_id.cs" />
|
<Compile Include="Presenters\EditPortfolio\When_initializing_the_edit_portfolio_presenter_with_an_id.cs" />
|
||||||
<Compile Include="Presenters\When_initializing_the_edit_portfolio_presenter_with_no_id.cs" />
|
<Compile Include="Presenters\EditPortfolio\When_initializing_the_edit_portfolio_presenter_with_no_id.cs" />
|
||||||
<Compile Include="Presenters\When_initializing_the_edit_position_presenter_with_an_id.cs" />
|
<Compile Include="Presenters\EditPosition\When_initializing_the_edit_position_presenter_with_an_id.cs" />
|
||||||
<Compile Include="Presenters\When_initializing_the_edit_position_presenter_with_no_id.cs" />
|
<Compile Include="Presenters\EditPosition\When_initializing_the_edit_position_presenter_with_no_id.cs" />
|
||||||
<Compile Include="Presenters\When_initializing_the_Main_Presenter.cs" />
|
<Compile Include="Presenters\Main\When_initializing_the_Main_Presenter.cs" />
|
||||||
<Compile Include="Presenters\When_the_user_selects_delete_context_option.cs" />
|
<Compile Include="Presenters\Portfolio\When_the_user_selects_delete_context_option.cs" />
|
||||||
<Compile Include="Presenters\When_the_user_selects_edit_context_option.cs" />
|
<Compile Include="Presenters\Portfolio\When_the_user_selects_edit_context_option.cs" />
|
||||||
<Compile Include="Presenters\When_the_user_tries_to_save_a_new_portfolio_with_a_blank_name.cs" />
|
<Compile Include="Presenters\EditPortfolio\When_the_user_tries_to_save_a_new_portfolio_with_a_blank_name.cs" />
|
||||||
<Compile Include="Presenters\When_the_user_tries_to_save_a_portfolio_with_a_duplicated_name.cs" />
|
<Compile Include="Presenters\EditPortfolio\When_the_user_tries_to_save_a_portfolio_with_a_duplicated_name.cs" />
|
||||||
<Compile Include="Presenters\When_the_user_wants_to_add_a_new_portfolio.cs" />
|
<Compile Include="Presenters\Main\When_the_user_wants_to_add_a_new_portfolio.cs" />
|
||||||
<Compile Include="Presenters\When_the_user_wants_to_add_a_new_position.cs" />
|
<Compile Include="Presenters\Portfolio\When_the_user_wants_to_add_a_new_position.cs" />
|
||||||
<Compile Include="Presenters\When_the_user_wants_to_configure_the_display_fields.cs" />
|
<Compile Include="Presenters\Main\When_the_user_wants_to_configure_the_display_fields.cs" />
|
||||||
<Compile Include="Presenters\When_the_user_wants_to_delete_a_portfolio.cs" />
|
<Compile Include="Presenters\Main\When_the_user_wants_to_delete_a_portfolio.cs" />
|
||||||
<Compile Include="Presenters\When_the_user_wants_to_edit_a_portfolio.cs" />
|
<Compile Include="Presenters\Main\When_the_user_wants_to_edit_a_portfolio.cs" />
|
||||||
<Compile Include="Presenters\When_the_user_wants_to_exit_the_app.cs" />
|
<Compile Include="Presenters\Main\When_the_user_wants_to_exit_the_app.cs" />
|
||||||
<Compile Include="Presenters\When_the_user_wants_to_refresh_the_positions.cs" />
|
<Compile Include="Presenters\Portfolio\When_the_user_wants_to_refresh_the_positions.cs" />
|
||||||
<Compile Include="Presenters\When_the_user_wants_to_save_an_invalid_position.cs" />
|
<Compile Include="Presenters\EditPosition\When_the_user_wants_to_save_an_invalid_position.cs" />
|
||||||
<Compile Include="Presenters\When_the_user_wants_to_save_an_invalid_position_with_blank_fields.cs" />
|
<Compile Include="Presenters\EditPosition\When_the_user_wants_to_save_an_invalid_position_with_blank_fields.cs" />
|
||||||
<Compile Include="Presenters\When_the_user_wants_to_save_a_valid_portfolio.cs" />
|
<Compile Include="Presenters\EditPortfolio\When_the_user_wants_to_save_a_valid_portfolio.cs" />
|
||||||
<Compile Include="Presenters\When_the_user_wants_to_save_a_valid_position.cs" />
|
<Compile Include="Presenters\EditPosition\When_the_user_wants_to_save_a_valid_position.cs" />
|
||||||
<Compile Include="Presenters\When_the_user_wants_to_save_configuration.cs" />
|
<Compile Include="Presenters\Config\When_the_user_wants_to_save_configuration.cs" />
|
||||||
<Compile Include="Presenters\When_the_user_wants_to_see_the_context_menu.cs" />
|
<Compile Include="Presenters\Main\When_the_user_wants_to_view_a_portfolio.cs" />
|
||||||
<Compile Include="Presenters\When_the_user_wants_to_view_a_portfolio.cs" />
|
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="Services\When_using_the_Yahoo_stock_data_service_to_validate_tickers.cs" />
|
<Compile Include="Services\When_using_the_Yahoo_stock_data_service_to_validate_tickers.cs" />
|
||||||
<Compile Include="Services\YahooStockDataServiceTests.cs" />
|
<Compile Include="Services\YahooStockDataServiceTests.cs" />
|
||||||
|
|
|
@ -4,7 +4,7 @@ using MonoStockPortfolio.Core.PortfolioRepositories;
|
||||||
using MonoStockPortfolio.Core.StockData;
|
using MonoStockPortfolio.Core.StockData;
|
||||||
using Telerik.JustMock;
|
using Telerik.JustMock;
|
||||||
|
|
||||||
namespace MonoStockPortfolio.Tests.Presenters
|
namespace MonoStockPortfolio.Tests.Presenters.EditPosition
|
||||||
{
|
{
|
||||||
public class EditPositionTests
|
public class EditPositionTests
|
||||||
{
|
{
|
|
@ -2,7 +2,7 @@
|
||||||
using MonoStockPortfolio.Entities;
|
using MonoStockPortfolio.Entities;
|
||||||
using Telerik.JustMock;
|
using Telerik.JustMock;
|
||||||
|
|
||||||
namespace MonoStockPortfolio.Tests.Presenters
|
namespace MonoStockPortfolio.Tests.Presenters.EditPosition
|
||||||
{
|
{
|
||||||
[Tags("UnitTest")]
|
[Tags("UnitTest")]
|
||||||
public class When_initializing_the_edit_position_presenter_with_an_id : EditPositionTests
|
public class When_initializing_the_edit_position_presenter_with_an_id : EditPositionTests
|
|
@ -2,7 +2,7 @@
|
||||||
using MonoStockPortfolio.Entities;
|
using MonoStockPortfolio.Entities;
|
||||||
using Telerik.JustMock;
|
using Telerik.JustMock;
|
||||||
|
|
||||||
namespace MonoStockPortfolio.Tests.Presenters
|
namespace MonoStockPortfolio.Tests.Presenters.EditPosition
|
||||||
{
|
{
|
||||||
[Tags("UnitTest")]
|
[Tags("UnitTest")]
|
||||||
public class When_initializing_the_edit_position_presenter_with_no_id : EditPositionTests
|
public class When_initializing_the_edit_position_presenter_with_no_id : EditPositionTests
|
|
@ -3,7 +3,7 @@ using MonoStockPortfolio.Activites.EditPositionScreen;
|
||||||
using MonoStockPortfolio.Entities;
|
using MonoStockPortfolio.Entities;
|
||||||
using Telerik.JustMock;
|
using Telerik.JustMock;
|
||||||
|
|
||||||
namespace MonoStockPortfolio.Tests.Presenters
|
namespace MonoStockPortfolio.Tests.Presenters.EditPosition
|
||||||
{
|
{
|
||||||
[Tags("UnitTest")]
|
[Tags("UnitTest")]
|
||||||
public class When_the_user_wants_to_save_a_valid_position : EditPositionTests
|
public class When_the_user_wants_to_save_a_valid_position : EditPositionTests
|
||||||
|
@ -32,6 +32,6 @@ namespace MonoStockPortfolio.Tests.Presenters
|
||||||
It should_save_a_position_with_the_correct_Containing_Portfolio_ID = () =>
|
It should_save_a_position_with_the_correct_Containing_Portfolio_ID = () =>
|
||||||
Mock.Assert(() => _mockPortfolioRepository.SavePosition(Arg.Matches<Position>(p => p.ContainingPortfolioID == 1)), Occurs.Exactly(1));
|
Mock.Assert(() => _mockPortfolioRepository.SavePosition(Arg.Matches<Position>(p => p.ContainingPortfolioID == 1)), Occurs.Exactly(1));
|
||||||
It should_tell_the_view_to_go_back_to_the_main_activity = () =>
|
It should_tell_the_view_to_go_back_to_the_main_activity = () =>
|
||||||
Mock.Assert(() => _mockView.GoBackToMainActivity(), Occurs.Exactly(1));
|
Mock.Assert(() => _mockView.GoBackToPortfolioActivity(), Occurs.Exactly(1));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,7 +7,7 @@ using MonoStockPortfolio.Activites.EditPositionScreen;
|
||||||
using MonoStockPortfolio.Entities;
|
using MonoStockPortfolio.Entities;
|
||||||
using Telerik.JustMock;
|
using Telerik.JustMock;
|
||||||
|
|
||||||
namespace MonoStockPortfolio.Tests.Presenters
|
namespace MonoStockPortfolio.Tests.Presenters.EditPosition
|
||||||
{
|
{
|
||||||
[Tags("UnitTest")]
|
[Tags("UnitTest")]
|
||||||
public class When_the_user_wants_to_save_an_invalid_position : EditPositionTests
|
public class When_the_user_wants_to_save_an_invalid_position : EditPositionTests
|
||||||
|
@ -36,7 +36,7 @@ namespace MonoStockPortfolio.Tests.Presenters
|
||||||
It should_send_an_invalid_price_per_share_error_to_the_view = () =>
|
It should_send_an_invalid_price_per_share_error_to_the_view = () =>
|
||||||
MockAssertPositionMatches(x => x.Any(p => p == "Please enter a valid, positive price per share"));
|
MockAssertPositionMatches(x => x.Any(p => p == "Please enter a valid, positive price per share"));
|
||||||
It should_not_tell_the_view_to_go_back_to_the_main_activity = () =>
|
It should_not_tell_the_view_to_go_back_to_the_main_activity = () =>
|
||||||
Mock.Assert(() => _mockView.GoBackToMainActivity(), Occurs.Never());
|
Mock.Assert(() => _mockView.GoBackToPortfolioActivity(), Occurs.Never());
|
||||||
|
|
||||||
private static void MockAssertPositionMatches(Expression<Predicate<IList<string>>> match)
|
private static void MockAssertPositionMatches(Expression<Predicate<IList<string>>> match)
|
||||||
{
|
{
|
|
@ -7,7 +7,7 @@ using MonoStockPortfolio.Activites.EditPositionScreen;
|
||||||
using MonoStockPortfolio.Entities;
|
using MonoStockPortfolio.Entities;
|
||||||
using Telerik.JustMock;
|
using Telerik.JustMock;
|
||||||
|
|
||||||
namespace MonoStockPortfolio.Tests.Presenters
|
namespace MonoStockPortfolio.Tests.Presenters.EditPosition
|
||||||
{
|
{
|
||||||
[Tags("UnitTest")]
|
[Tags("UnitTest")]
|
||||||
public class When_the_user_wants_to_save_an_invalid_position_with_blank_fields : EditPositionTests
|
public class When_the_user_wants_to_save_an_invalid_position_with_blank_fields : EditPositionTests
|
||||||
|
@ -36,7 +36,7 @@ namespace MonoStockPortfolio.Tests.Presenters
|
||||||
It should_send_an_invalid_price_per_share_error_to_the_view = () =>
|
It should_send_an_invalid_price_per_share_error_to_the_view = () =>
|
||||||
MockPositionMatches(x => x.Any(p => p == "Please enter a valid, positive price per share"));
|
MockPositionMatches(x => x.Any(p => p == "Please enter a valid, positive price per share"));
|
||||||
It should_not_tell_the_view_to_go_back_to_the_main_activity = () =>
|
It should_not_tell_the_view_to_go_back_to_the_main_activity = () =>
|
||||||
Mock.Assert(() => _mockView.GoBackToMainActivity(), Occurs.Never());
|
Mock.Assert(() => _mockView.GoBackToPortfolioActivity(), Occurs.Never());
|
||||||
|
|
||||||
private static void MockPositionMatches(Expression<Predicate<IList<string>>> match)
|
private static void MockPositionMatches(Expression<Predicate<IList<string>>> match)
|
||||||
{
|
{
|
|
@ -1,6 +1,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Machine.Specifications;
|
using Machine.Specifications;
|
||||||
|
using MonoStockPortfolio.Entities;
|
||||||
using Telerik.JustMock;
|
using Telerik.JustMock;
|
||||||
|
|
||||||
namespace MonoStockPortfolio.Tests.Presenters
|
namespace MonoStockPortfolio.Tests.Presenters
|
||||||
|
@ -11,8 +12,8 @@ namespace MonoStockPortfolio.Tests.Presenters
|
||||||
It should_get_the_portfolio_list = () =>
|
It should_get_the_portfolio_list = () =>
|
||||||
Mock.Assert(() => _mockPortfolioRepository.GetAllPortfolios(), Occurs.Exactly(1));
|
Mock.Assert(() => _mockPortfolioRepository.GetAllPortfolios(), Occurs.Exactly(1));
|
||||||
It should_refresh_the_view = () =>
|
It should_refresh_the_view = () =>
|
||||||
Mock.Assert(() => _mockView.RefreshList(Arg.IsAny<IList<string>>()), Occurs.Exactly(1));
|
Mock.Assert(() => _mockView.RefreshList(Arg.IsAny<IList<Portfolio>>()), Occurs.Exactly(1));
|
||||||
It should_refresh_the_view_with_the_portfolio_list = () =>
|
It should_refresh_the_view_with_the_portfolio_list = () =>
|
||||||
Mock.Assert(() => _mockView.RefreshList(Arg.Matches<IList<string>>(stringList => stringList.SequenceEqual(_portfolioList.Select(p => p.Name)))));
|
Mock.Assert(() => _mockView.RefreshList(Arg.Matches<IList<Portfolio>>(p => p.SequenceEqual(_portfolioList))));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,21 +0,0 @@
|
||||||
using Machine.Specifications;
|
|
||||||
using MonoStockPortfolio.Tests.Presenters;
|
|
||||||
using Telerik.JustMock;
|
|
||||||
|
|
||||||
namespace MonoStockPortfolio.Tests.Activities
|
|
||||||
{
|
|
||||||
[Tags("UnitTest")]
|
|
||||||
public class When_the_user_wants_to_see_the_context_menu : Given_an_initialized_Main_Presenter
|
|
||||||
{
|
|
||||||
static int _id;
|
|
||||||
|
|
||||||
Because of = () =>
|
|
||||||
_id = _presenter.GetPortfolioIdForContextMenu(_portfolio1.Name);
|
|
||||||
|
|
||||||
It should_use_the_given_name_to_lookup_the_ID = () =>
|
|
||||||
{
|
|
||||||
Mock.Assert(() => _mockPortfolioRepository.GetPortfolioByName(_portfolio1.Name), Occurs.Exactly(1));
|
|
||||||
_portfolio1.ID.ShouldEqual(_id);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -28,7 +28,5 @@ namespace MonoStockPortfolio.Tests.Services
|
||||||
_quotes.ForEach(q => string.IsNullOrEmpty(q.Volume).ShouldBeFalse());
|
_quotes.ForEach(q => string.IsNullOrEmpty(q.Volume).ShouldBeFalse());
|
||||||
It should_get_last_trade_prices_from_the_web = () =>
|
It should_get_last_trade_prices_from_the_web = () =>
|
||||||
_quotes.ForEach(q => q.LastTradePrice.ShouldNotEqual(0.0M));
|
_quotes.ForEach(q => q.LastTradePrice.ShouldNotEqual(0.0M));
|
||||||
It should_get_price_change_from_the_web = () =>
|
|
||||||
_quotes.ForEach(q => q.Change.ShouldNotEqual(0.0M));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -52,7 +52,7 @@ namespace MonoStockPortfolio.Activites.EditPositionScreen
|
||||||
this.SharesTextBox.Text = position.Shares.ToString();
|
this.SharesTextBox.Text = position.Shares.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GoBackToMainActivity()
|
public void GoBackToPortfolioActivity()
|
||||||
{
|
{
|
||||||
this.EndActivity();
|
this.EndActivity();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using Android.Util;
|
||||||
using MonoStockPortfolio.Core.PortfolioRepositories;
|
using MonoStockPortfolio.Core.PortfolioRepositories;
|
||||||
using MonoStockPortfolio.Core.StockData;
|
using MonoStockPortfolio.Core.StockData;
|
||||||
using MonoStockPortfolio.Entities;
|
using MonoStockPortfolio.Entities;
|
||||||
|
@ -50,7 +51,7 @@ namespace MonoStockPortfolio.Activites.EditPositionScreen
|
||||||
if (!errorMessages.Any())
|
if (!errorMessages.Any())
|
||||||
{
|
{
|
||||||
_portfolioRepository.SavePosition(GetPosition(positionInputModel));
|
_portfolioRepository.SavePosition(GetPosition(positionInputModel));
|
||||||
_currentView.GoBackToMainActivity();
|
_currentView.GoBackToPortfolioActivity();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,7 +7,7 @@ namespace MonoStockPortfolio.Activites.EditPositionScreen
|
||||||
{
|
{
|
||||||
void SetTitle(string title);
|
void SetTitle(string title);
|
||||||
void PopulateForm(Position position);
|
void PopulateForm(Position position);
|
||||||
void GoBackToMainActivity();
|
void GoBackToPortfolioActivity();
|
||||||
void ShowErrorMessages(IList<string> errorMessages);
|
void ShowErrorMessages(IList<string> errorMessages);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue