diff --git a/scripts/StockTicker.build b/scripts/StockTicker.build index 55cf52c..bfcf7a4 100644 --- a/scripts/StockTicker.build +++ b/scripts/StockTicker.build @@ -14,8 +14,8 @@ - - + + diff --git a/source/.nuget/NuGet.Config b/source/.nuget/NuGet.Config new file mode 100644 index 0000000..67f8ea0 --- /dev/null +++ b/source/.nuget/NuGet.Config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/source/.nuget/NuGet.exe b/source/.nuget/NuGet.exe new file mode 100644 index 0000000..4645f4b Binary files /dev/null and b/source/.nuget/NuGet.exe differ diff --git a/source/.nuget/NuGet.targets b/source/.nuget/NuGet.targets new file mode 100644 index 0000000..d566b12 --- /dev/null +++ b/source/.nuget/NuGet.targets @@ -0,0 +1,151 @@ + + + + $(MSBuildProjectDirectory)\..\ + + + false + + + false + + + true + + + false + + + + + + + + + + + $([System.IO.Path]::Combine($(SolutionDir), ".nuget")) + $([System.IO.Path]::Combine($(ProjectDir), "packages.config")) + + + + + $(SolutionDir).nuget + packages.config + + + + + $(NuGetToolsPath)\nuget.exe + @(PackageSource) + + "$(NuGetExePath)" + mono --runtime=v4.0.30319 $(NuGetExePath) + + $(TargetDir.Trim('\\')) + + -RequireConsent + + $(NuGetCommand) install "$(PackagesConfig)" -source "$(PackageSources)" $(RequireConsentSwitch) -solutionDir "$(SolutionDir) " + $(NuGetCommand) pack "$(ProjectPath)" -p Configuration=$(Configuration) -o "$(PackageOutputDir)" -symbols + + + + RestorePackages; + $(BuildDependsOn); + + + + + $(BuildDependsOn); + BuildPackage; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/source/.nuget/packages.config b/source/.nuget/packages.config new file mode 100644 index 0000000..e661988 --- /dev/null +++ b/source/.nuget/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/source/StockTicker.Specification/SpecificationBootstrapper.cs b/source/StockTicker.Specification/SpecificationBootstrapper.cs index d5443cb..ccc04eb 100644 --- a/source/StockTicker.Specification/SpecificationBootstrapper.cs +++ b/source/StockTicker.Specification/SpecificationBootstrapper.cs @@ -35,11 +35,6 @@ public IKernel StandardKernel } } - public void Start() - { - this.OnStartup(this, null); - } - public void Stop() { this.OnExit(this, null); diff --git a/source/StockTicker.Specification/StockTicker.Specification.csproj b/source/StockTicker.Specification/StockTicker.Specification.csproj index f97b8a6..cd795dd 100644 --- a/source/StockTicker.Specification/StockTicker.Specification.csproj +++ b/source/StockTicker.Specification/StockTicker.Specification.csproj @@ -3,38 +3,41 @@ StockTicker Specification + ..\ + true {FA85776B-D3B5-439D-A349-5CD1108CE8CB} Library - - ..\packages\Caliburn.Micro\lib\net40\Caliburn.Micro.dll - - + False - ..\packages\Machine.Specifications\lib\net40\Machine.Specifications.dll + ..\packages\Caliburn.Micro.1.5.1\lib\net40\Caliburn.Micro.dll + + + ..\packages\Machine.Specifications.0.5.12\lib\net40\Machine.Specifications.dll - ..\packages\Machine.Specifications\lib\net40\Machine.Specifications.Clr4.dll + ..\packages\Machine.Specifications.0.5.12\lib\net40\Machine.Specifications.Clr4.dll - - ..\packages\Ninject\lib\net40\Ninject.dll + + ..\packages\Ninject.3.0.1.10\lib\net40\Ninject.dll + + False + ..\packages\Caliburn.Micro.1.5.1\lib\net40\System.Windows.Interactivity.dll + - - ..\packages\thinktectureUIAnnotationsWPF\lib\Thinktecture.UIAnnotations.dll - @@ -57,4 +60,5 @@ + \ No newline at end of file diff --git a/source/StockTicker.Specification/packages.config b/source/StockTicker.Specification/packages.config index 0311509..684e512 100644 --- a/source/StockTicker.Specification/packages.config +++ b/source/StockTicker.Specification/packages.config @@ -1,7 +1,7 @@  - - - + + + \ No newline at end of file diff --git a/source/StockTicker.Test/Actions/BusyIndicationViewModelTest.cs b/source/StockTicker.Test/Actions/BusyIndicationViewModelTest.cs index 63a3fc2..29d25af 100644 --- a/source/StockTicker.Test/Actions/BusyIndicationViewModelTest.cs +++ b/source/StockTicker.Test/Actions/BusyIndicationViewModelTest.cs @@ -21,7 +21,6 @@ namespace StockTicker.Actions using System; using FluentAssertions; - using FluentAssertions.EventMonitoring; using Xunit; public class BusyIndicationViewModelTest diff --git a/source/StockTicker.Test/Actions/RescueResultDecoratorTest.cs b/source/StockTicker.Test/Actions/RescueResultDecoratorTest.cs index 9ee6317..0564ec1 100644 --- a/source/StockTicker.Test/Actions/RescueResultDecoratorTest.cs +++ b/source/StockTicker.Test/Actions/RescueResultDecoratorTest.cs @@ -24,7 +24,6 @@ namespace StockTicker.Actions using System.Linq; using Caliburn.Micro; using FluentAssertions; - using FluentAssertions.EventMonitoring; using Moq; using StockTicker.TestHelpers; using Xunit; diff --git a/source/StockTicker.Test/Actions/ResultDecoraterBaseTest.cs b/source/StockTicker.Test/Actions/ResultDecoraterBaseTest.cs index 3ebb748..fda8309 100644 --- a/source/StockTicker.Test/Actions/ResultDecoraterBaseTest.cs +++ b/source/StockTicker.Test/Actions/ResultDecoraterBaseTest.cs @@ -21,7 +21,6 @@ namespace StockTicker.Actions using System; using Caliburn.Micro; using FluentAssertions; - using FluentAssertions.EventMonitoring; using Moq; using StockTicker.TestHelpers; diff --git a/source/StockTicker.Test/Actions/UseActionsActivationStrategyTest.cs b/source/StockTicker.Test/Actions/UseActionsActivationStrategyTest.cs new file mode 100644 index 0000000..87c0a76 --- /dev/null +++ b/source/StockTicker.Test/Actions/UseActionsActivationStrategyTest.cs @@ -0,0 +1,63 @@ +//------------------------------------------------------------------------------- +// +// Copyright (c) 2012 +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//------------------------------------------------------------------------------- + +namespace StockTicker.Actions +{ + using System; + + using FluentAssertions; + + using Moq; + + using Ninject; + using Ninject.Activation.Strategies; + + using Xunit; + + public class UseActionsActivationStrategyTest + { + private readonly StandardKernel kernel; + + public UseActionsActivationStrategyTest() + { + this.kernel = new StandardKernel(); + this.kernel.Bind().ToSelf(); + this.kernel.Bind().ToMethod(ctx => Mock.Of()); + + this.kernel.Components.Add(); + } + + private interface ITestObjectWithUseAction : IUseActions + { + } + + [Fact] + public void WhenActivatedObjectUsesActions_ShouldAttachActionBuilder() + { + var useActions = this.kernel.Get(); + + useActions.Actions.Should().NotBeNull(); + useActions.Actions().Should().NotBeNull(); + } + + private class TestObjectWithUseActions : ITestObjectWithUseAction + { + public Func Actions { internal get; set; } + } + } +} \ No newline at end of file diff --git a/source/StockTicker.Test/Authentication/AuthenticateTest.cs b/source/StockTicker.Test/Authentication/AuthenticateTest.cs deleted file mode 100644 index 782b9b0..0000000 --- a/source/StockTicker.Test/Authentication/AuthenticateTest.cs +++ /dev/null @@ -1,60 +0,0 @@ -//------------------------------------------------------------------------------- -// -// Copyright (c) 2012 -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//------------------------------------------------------------------------------- - -namespace StockTicker.Authentication -{ - using System.Dynamic; - - using Caliburn.Micro; - - using Moq; - - using StockTicker.TestHelpers; - using Xunit; - - public class AuthenticateTest - { - private readonly Mock authenticationViewModel; - - private readonly Mock windowManager; - - private readonly Authenticate testee; - - public AuthenticateTest() - { - this.authenticationViewModel = new Mock(); - this.windowManager = new Mock(); - - this.testee = new Authenticate(this.windowManager.Object, this.authenticationViewModel.Object); - } - - [Fact] - public void ShouldRaiseCompleted() - { - this.testee.ShouldRaiseCompleted(); - } - - [Fact] - public void ShouldOpenAuthenticationWizard() - { - this.testee.Execute(new ActionExecutionContext()); - - this.windowManager.Verify(w => w.ShowDialog(this.authenticationViewModel.Object, null, It.IsAny())); - } - } -} \ No newline at end of file diff --git a/source/StockTicker.Test/Authentication/AuthenticationViewModelTest.cs b/source/StockTicker.Test/Authentication/AuthenticationViewModelTest.cs deleted file mode 100644 index 35e1d24..0000000 --- a/source/StockTicker.Test/Authentication/AuthenticationViewModelTest.cs +++ /dev/null @@ -1,86 +0,0 @@ -//------------------------------------------------------------------------------- -// -// Copyright (c) 2012 -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//------------------------------------------------------------------------------- - -namespace StockTicker.Authentication -{ - using System.Collections.Generic; - using Caliburn.Micro; - using FluentAssertions; - using Moq; - - using StockTicker.Actions; - - using Xunit; - - public class AuthenticationViewModelTest - { - private readonly Mock authenticationStepFactory; - - private readonly AuthenticationViewModel testee; - - public AuthenticationViewModelTest() - { - this.authenticationStepFactory = new Mock(); - - this.testee = new AuthenticationViewModel(this.authenticationStepFactory.Object, Mock.Of()); - } - - [Fact] - public void ShouldInitializeWizardSteps() - { - var firstStep = new FakeStep(); - var secondStep = new FakeStep(); - - this.authenticationStepFactory.SetupSequence(f => f.CreateSteps()).Returns( - new List { firstStep, secondStep }); - - this.testee.As().Activate(); - - this.testee.Items.Should().HaveCount(2) - .And.HaveElementAt(0, firstStep) - .And.HaveElementAt(1, secondStep); - - this.testee.ActiveItem.Should().Be(firstStep); - } - - [Fact] - public void Next_ShouldMoveToNextStep() - { - var firstStep = new FakeStep(); - var secondStep = new FakeStep(); - - this.authenticationStepFactory.SetupSequence(f => f.CreateSteps()).Returns( - new List { firstStep, secondStep }); - - this.Activate(); - - this.testee.Next(); - - this.testee.ActiveItem.Should().Be(secondStep); - } - - private void Activate() - { - this.testee.As().Activate(); - } - - private class FakeStep : Screen, IAuthenticationStep - { - } - } -} \ No newline at end of file diff --git a/source/StockTicker.Test/Authentication/ChoosePasswordViewModelTest.cs b/source/StockTicker.Test/Authentication/ChoosePasswordViewModelTest.cs deleted file mode 100644 index 3c9cddd..0000000 --- a/source/StockTicker.Test/Authentication/ChoosePasswordViewModelTest.cs +++ /dev/null @@ -1,66 +0,0 @@ -//------------------------------------------------------------------------------- -// -// Copyright (c) 2012 -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//------------------------------------------------------------------------------- - -namespace StockTicker.Authentication -{ - using System.Security; - - using FluentAssertions.EventMonitoring; - - using FluentValidation; - - using Moq; - - using Xunit; - - public class ChoosePasswordViewModelTest - { - private readonly Mock validatorFactory; - - private readonly ChoosePasswordViewModel testee; - - public ChoosePasswordViewModelTest() - { - this.validatorFactory = new Mock(); - - this.testee = new ChoosePasswordViewModel(this.validatorFactory.Object); - } - - [Fact] - public void Password_ShouldRaisePropertyChanged() - { - this.testee.MonitorEvents(); - - this.testee.Password = new SecureString(); - - this.testee.ShouldRaisePropertyChangeFor(t => t.Password); - this.testee.ShouldRaisePropertyChangeFor(t => t.PasswordRetype); - } - - [Fact] - public void PasswordRetype_ShouldRaisePropertyChanged() - { - this.testee.MonitorEvents(); - - this.testee.PasswordRetype = new SecureString(); - - this.testee.ShouldRaisePropertyChangeFor(t => t.PasswordRetype); - this.testee.ShouldRaisePropertyChangeFor(t => t.Password); - } - } -} \ No newline at end of file diff --git a/source/StockTicker.Test/Authentication/ChooseUserNameViewModelTest.cs b/source/StockTicker.Test/Authentication/ChooseUserNameViewModelTest.cs deleted file mode 100644 index a7525ae..0000000 --- a/source/StockTicker.Test/Authentication/ChooseUserNameViewModelTest.cs +++ /dev/null @@ -1,60 +0,0 @@ -//------------------------------------------------------------------------------- -// -// Copyright (c) 2012 -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//------------------------------------------------------------------------------- - -namespace StockTicker.Authentication -{ - using Caliburn.Micro; - - using FluentAssertions; - using FluentAssertions.EventMonitoring; - - using Moq; - - using Xunit; - - public class ChooseUserNameViewModelTest - { - private readonly ChooseUserNameViewModel testee; - - public ChooseUserNameViewModelTest() - { - this.testee = new ChooseUserNameViewModel(); - } - - [Fact] - public void UserName_ShouldRaisePropertyChanged() - { - this.testee.MonitorEvents(); - - this.testee.UserName = "AnyName"; - - this.testee.ShouldRaisePropertyChangeFor(t => t.UserName); - } - - [Fact] - public void ShouldRaisePropertyChangedForHasSuggestions() - { - this.testee.MonitorEvents(); - - this.testee.Suggestions.Add("AnySuggestion"); - - this.testee.ShouldRaisePropertyChangeFor(x => x.HasSuggestions); - this.testee.HasSuggestions.Should().BeTrue(); - } - } -} \ No newline at end of file diff --git a/source/StockTicker.Test/Authentication/SuggestUsernamesTest.cs b/source/StockTicker.Test/Authentication/SuggestUsernamesTest.cs deleted file mode 100644 index 8487990..0000000 --- a/source/StockTicker.Test/Authentication/SuggestUsernamesTest.cs +++ /dev/null @@ -1,90 +0,0 @@ -//------------------------------------------------------------------------------- -// -// Copyright (c) 2012 -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//------------------------------------------------------------------------------- - -namespace StockTicker.Authentication -{ - using System.Collections.Generic; - - using Caliburn.Micro; - - using FluentAssertions; - - using Moq; - - using StockTicker.Actions; - using StockTicker.Externals; - using StockTicker.TestHelpers; - - using Xunit; - - public class SuggestUsernamesTest - { - private readonly Mock authenticationService; - - private readonly PotentialNewUserModel potentialNewUser; - - private readonly SuggestUsernames testee; - - private readonly List suggestions; - - public SuggestUsernamesTest() - { - this.authenticationService = new Mock(); - this.potentialNewUser = new PotentialNewUserModel("AnyFirstname", "AnyLastname"); - this.suggestions = new List(); - - this.testee = new SuggestUsernames(this.authenticationService.Object, this.potentialNewUser, this.suggestions); - } - - [Fact] - public void ShouldRaiseCompleted() - { - this.testee.ShouldRaiseCompleted(); - } - - [Fact] - public void ShouldRequestAsynchronousExecution() - { - this.testee.Should().BeDecoratedWith(); - } - - [Fact] - public void ShouldFillFoundStocks() - { - var expectedSearchModels = new List { "First", "Second", }; - - this.authenticationService.Setup(s => s.SuggestUsernames(this.potentialNewUser)) - .Returns(expectedSearchModels); - - this.testee.Execute(new ActionExecutionContext()); - - this.suggestions.Should().BeEquivalentTo(expectedSearchModels); - } - - [Fact] - public void ShouldClearInputCollection() - { - this.suggestions.Add("First"); - this.suggestions.Add("Second"); - - this.testee.Execute(new ActionExecutionContext()); - - this.suggestions.Should().BeEmpty(); - } - } -} \ No newline at end of file diff --git a/source/StockTicker.Test/ContentViewModelFactoryTest.cs b/source/StockTicker.Test/ContentViewModelFactoryTest.cs deleted file mode 100644 index 4b5be4a..0000000 --- a/source/StockTicker.Test/ContentViewModelFactoryTest.cs +++ /dev/null @@ -1,74 +0,0 @@ -//------------------------------------------------------------------------------- -// -// Copyright (c) 2012 -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//------------------------------------------------------------------------------- - -namespace StockTicker -{ - using System; - - using FluentAssertions; - - using Moq; - - using Ninject; - - using StockTicker.Externals; - using StockTicker.ManageStocks; - using StockTicker.News; - - using Xunit; - - public class ContentViewModelFactoryTest : IDisposable - { - private readonly StandardKernel kernel; - - private readonly ContentViewModelFactory testee; - - public ContentViewModelFactoryTest() - { - this.kernel = new StandardKernel(new NinjectSettings { LoadExtensions = false }); - this.kernel.Bind().ToConstant(Mock.Of()); - this.kernel.Bind().ToConstant(Mock.Of()); - - this.testee = new ContentViewModelFactory(this.kernel); - } - - [Fact] - public void ShouldReturnNewsViewModelAsDefaultContent() - { - IStockTickerContentViewModel result = this.testee.CreateContent(null); - - result.Should().NotBeNull() - .And.BeAssignableTo(); - } - - [Fact] - public void ShouldReturnDetailsViewModelForSearchedContent() - { - IStockTickerContentViewModel result = - this.testee.CreateContent(new AnyStockDetailModel()); - - result.Should().NotBeNull() - .And.BeAssignableTo(); - } - - public void Dispose() - { - this.kernel.Dispose(); - } - } -} \ No newline at end of file diff --git a/source/StockTicker.Test/FindStocks/SearchViewModelTest.cs b/source/StockTicker.Test/FindStocks/SearchViewModelTest.cs index e52e37b..81070b7 100644 --- a/source/StockTicker.Test/FindStocks/SearchViewModelTest.cs +++ b/source/StockTicker.Test/FindStocks/SearchViewModelTest.cs @@ -18,20 +18,27 @@ namespace StockTicker.FindStocks { + using System.Windows.Input; + using FluentAssertions; - using FluentAssertions.EventMonitoring; using StockTicker.Externals; + using StockTicker.TestHelpers; using Xunit; public class SearchViewModelTest { + private readonly ActionBuilderMock actionBuilder; + private readonly SearchViewModel testee; public SearchViewModelTest() { - this.testee = new SearchViewModel(); + this.actionBuilder = new ActionBuilderMock(); + + this.testee = new SearchViewModel() + .AttachBuilder(this.actionBuilder); } [Fact] @@ -66,5 +73,23 @@ public void ShouldRaisePropertyChangedForPattern() this.testee.ShouldRaisePropertyChangeFor(t => t.Pattern); } + + [Fact] + public void ShouldSearch_WhenEnter() + { + this.testee.Search("AnySymbol", new KeyEventArgs(null, new FakePresentationSource(), 21, Key.Enter)); + + this.actionBuilder + .Should().NotBeEmpty(); + } + + [Fact] + public void ShouldNotSearch_WhenNotEnter() + { + this.testee.Search("AnySymbol", new KeyEventArgs(null, new FakePresentationSource(), 21, Key.A)); + + this.actionBuilder + .Should().BeEmpty(); + } } } \ No newline at end of file diff --git a/source/StockTicker.Test/ManageStocks/ConductStockTickerContentTest.cs b/source/StockTicker.Test/ManageStocks/ConductStockTickerContentTest.cs deleted file mode 100644 index 4f4ba3b..0000000 --- a/source/StockTicker.Test/ManageStocks/ConductStockTickerContentTest.cs +++ /dev/null @@ -1,89 +0,0 @@ -//------------------------------------------------------------------------------- -// -// Copyright (c) 2012 -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//------------------------------------------------------------------------------- - -namespace StockTicker.ManageStocks -{ - using Caliburn.Micro; - - using FluentAssertions; - - using Moq; - - using StockTicker.Externals; - using StockTicker.TestHelpers; - - using Xunit; - - public class ConductStockTickerContentTest - { - private readonly FutureMock searchModel; - - private readonly Mock contentFactory; - - private IStockTickerContentViewModel detail; - - public ConductStockTickerContentTest() - { - this.searchModel = new AnyStockDetailModel().AsFuture(); - this.contentFactory = new Mock(); - } - - [Fact] - public void ShouldRaiseCompleted() - { - ConductStockTickerContent testee = this.CreateTestee(); - - testee.ShouldRaiseCompleted(); - } - - [Fact] - public void ShouldAllowNullSearchModel() - { - var future = new FutureMock(); - - ConductStockTickerContent testee = this.CreateTestee(future); - - System.Action act = () => testee.Execute(new ActionExecutionContext()); - - act.ShouldNotThrow(); - } - - [Fact] - public void ShouldConductCreatedDetailViewModel() - { - var contentViewModel = Mock.Of(); - this.contentFactory.Setup(f => f.CreateContent(It.IsAny())).Returns(contentViewModel); - - var testee = this.CreateTestee(); - - testee.Execute(new ActionExecutionContext()); - - this.detail.Should().Be(contentViewModel); - } - - private ConductStockTickerContent CreateTestee(FutureMock search) - { - return new ConductStockTickerContent(search, d => this.detail = d, this.contentFactory.Object); - } - - private ConductStockTickerContent CreateTestee() - { - return this.CreateTestee(this.searchModel); - } - } -} \ No newline at end of file diff --git a/source/StockTicker.Test/ManageStocks/DollarConverterTest.cs b/source/StockTicker.Test/ManageStocks/DollarConverterTest.cs deleted file mode 100644 index 5c46516..0000000 --- a/source/StockTicker.Test/ManageStocks/DollarConverterTest.cs +++ /dev/null @@ -1,53 +0,0 @@ -//------------------------------------------------------------------------------- -// -// Copyright (c) 2012 -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//------------------------------------------------------------------------------- - -namespace StockTicker.ManageStocks -{ - using System; - using System.Globalization; - - using FluentAssertions; - - using Xunit; - - public class DollarConverterTest - { - private readonly DollarConverter testee; - - public DollarConverterTest() - { - this.testee = new DollarConverter(); - } - - [Fact] - public void ShouldNotConvertBack() - { - Action act = () => this.testee.ConvertBack(null, null, null, null); - - act.ShouldThrow(); - } - - [Fact] - public void ShouldAppendDollar() - { - var result = this.testee.Convert(10.00m, null, null, CultureInfo.InvariantCulture); - - result.As().Should().NotBeNull().And.Be("$10.00"); - } - } -} \ No newline at end of file diff --git a/source/StockTicker.Test/ManageStocks/GetStockDetailsTest.cs b/source/StockTicker.Test/ManageStocks/GetStockDetailsTest.cs deleted file mode 100644 index bf5cf8e..0000000 --- a/source/StockTicker.Test/ManageStocks/GetStockDetailsTest.cs +++ /dev/null @@ -1,100 +0,0 @@ -//------------------------------------------------------------------------------- -// -// Copyright (c) 2012 -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//------------------------------------------------------------------------------- - -namespace StockTicker.ManageStocks -{ - using System; - - using Caliburn.Micro; - - using FluentAssertions; - - using Moq; - - using StockTicker.Actions; - using StockTicker.Externals; - using StockTicker.TestHelpers; - - using Xunit; - - using Action = System.Action; - - public class GetStockDetailsTest - { - private readonly Mock stockService; - - private readonly string symbol; - - private readonly FutureMock detail; - - public GetStockDetailsTest() - { - this.symbol = "AnySymbol"; - this.detail = new FutureMock(); - - this.stockService = new Mock(); - } - - [Fact] - public void ShouldNotAllowNullSearchModel() - { - Action act = () => this.CreateTestee(null); - - act.ShouldThrow(); - } - - [Fact] - public void ShouldRaiseCompleted() - { - var testee = this.CreateTestee(); - - testee.ShouldRaiseCompleted(); - } - - [Fact] - public void ShouldRequestAsynchronousExecution() - { - var testee = this.CreateTestee(); - - testee.Should().BeDecoratedWith(); - } - - [Fact] - public void ShouldReturnDetails() - { - var expectedDetail = new AnyStockDetailModel(); - this.stockService.Setup(s => s.Get(this.symbol)).Returns(expectedDetail); - - var testee = this.CreateTestee(); - - testee.Execute(new ActionExecutionContext()); - - this.detail.Value.Should().Be(expectedDetail); - } - - private GetStockDetails CreateTestee() - { - return this.CreateTestee(this.symbol); - } - - private GetStockDetails CreateTestee(string symbol) - { - return new GetStockDetails(this.stockService.Object, symbol, this.detail); - } - } -} \ No newline at end of file diff --git a/source/StockTicker.Test/ManageStocks/RangeToTextConverterTest.cs b/source/StockTicker.Test/ManageStocks/RangeToTextConverterTest.cs deleted file mode 100644 index 35fe091..0000000 --- a/source/StockTicker.Test/ManageStocks/RangeToTextConverterTest.cs +++ /dev/null @@ -1,73 +0,0 @@ -//------------------------------------------------------------------------------- -// -// Copyright (c) 2012 -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//------------------------------------------------------------------------------- - -namespace StockTicker.ManageStocks -{ - using System; - using System.Collections; - using System.Collections.Generic; - using System.Globalization; - - using FluentAssertions; - - using StockTicker.Externals; - - using Xunit; - using Xunit.Extensions; - - public class RangeToTextConverterTest - { - private readonly RangeToTextConverter testee; - - public RangeToTextConverterTest() - { - this.testee = new RangeToTextConverter(); - } - - [Fact] - public void ShouldNotConvertBack() - { - Action act = () => this.testee.ConvertBack(null, null, null, null); - - act.ShouldThrow(); - } - - [Theory] - [ClassData(typeof(RangeData))] - public void ShouldConvertRange(decimal @from, decimal to, string expected) - { - var result = this.testee.Convert(new Range(from, to), null, null, CultureInfo.InvariantCulture); - - result.As().Should().NotBeNull().And.Be(expected); - } - - private class RangeData : IEnumerable - { - public IEnumerator GetEnumerator() - { - yield return new object[] { 10.00m, 11.05m, "$10.00 - $11.05" }; - yield return new object[] { -10.00m, 11.05m, "$-10.00 - $11.05" }; - } - - IEnumerator IEnumerable.GetEnumerator() - { - return this.GetEnumerator(); - } - } - } -} \ No newline at end of file diff --git a/source/StockTicker.Test/ManageStocks/StockDetailModelToTitleConverterTest.cs b/source/StockTicker.Test/ManageStocks/StockDetailModelToTitleConverterTest.cs deleted file mode 100644 index f1739c6..0000000 --- a/source/StockTicker.Test/ManageStocks/StockDetailModelToTitleConverterTest.cs +++ /dev/null @@ -1,65 +0,0 @@ -//------------------------------------------------------------------------------- -// -// Copyright (c) 2012 -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//------------------------------------------------------------------------------- - -namespace StockTicker.ManageStocks -{ - using System; - using System.Globalization; - - using FluentAssertions; - - using StockTicker.Externals; - - using Xunit; - - public class StockDetailModelToTitleConverterTest - { - private readonly StockDetailModelToTitleConverter testee; - - public StockDetailModelToTitleConverterTest() - { - this.testee = new StockDetailModelToTitleConverter(); - } - - [Fact] - public void ShouldNotConvertBack() - { - Action act = () => this.testee.ConvertBack(null, null, null, null); - - act.ShouldThrow(); - } - - [Fact] - public void ShouldConvertOnlySearchDetailModel() - { - object result = this.testee.Convert(new object(), null, null, CultureInfo.InvariantCulture); - - result.Should().BeNull(); - } - - [Fact] - public void ShouldConvertSearchDetailModel() - { - var expected = new AnyStockDetailModel(); - - object result = this.testee.Convert(expected, null, null, CultureInfo.InvariantCulture); - - result.As().Should().NotBeNull().And.Be("AnyCompany\r\nAnyFund:AnySymbol"); - } - } -} \ No newline at end of file diff --git a/source/StockTicker.Test/StockTicker.Test.csproj b/source/StockTicker.Test/StockTicker.Test.csproj index 317b991..88f1850 100644 --- a/source/StockTicker.Test/StockTicker.Test.csproj +++ b/source/StockTicker.Test/StockTicker.Test.csproj @@ -3,42 +3,55 @@ StockTicker Test + ..\ + true {F9E20B24-DEB5-40B9-8C4B-44F3F39067E4} Library - - ..\packages\Caliburn.Micro\lib\net40\Caliburn.Micro.dll - - + False - ..\packages\FluentAssertions\Lib\net40\FluentAssertions.dll + ..\packages\Caliburn.Micro.1.5.1\lib\net40\Caliburn.Micro.dll - - ..\packages\FluentValidation\lib\Net40\FluentValidation.dll + + ..\packages\FluentAssertions.2.0.1\lib\net40\FluentAssertions.dll - - ..\packages\Moq\lib\NET40\Moq.dll + + False + ..\packages\FluentValidation.3.4.6.0\lib\Net40\FluentValidation.dll + + + False + ..\packages\Moq.4.0.10827\lib\NET40\Moq.dll - ..\packages\Ninject\lib\net40\Ninject.dll + False + ..\packages\Ninject.3.0.1.10\lib\net40\Ninject.dll + + + False + ..\packages\Caliburn.Micro.1.5.1\lib\net40\System.Windows.Interactivity.dll + - - ..\packages\xunit\lib\xunit.dll + + + False + ..\packages\xunit.1.9.1\lib\net20\xunit.dll - - ..\packages\xunit.extensions\lib\xunit.extensions.dll + + False + ..\packages\xunit.extensions.1.9.1\lib\net20\xunit.extensions.dll @@ -48,22 +61,15 @@ - - - - - + - - - - - - + + + @@ -75,9 +81,8 @@ - - + @@ -89,4 +94,5 @@ + \ No newline at end of file diff --git a/source/StockTicker.Test/TestHelpers/ActionBuilderMock.cs b/source/StockTicker.Test/TestHelpers/ActionBuilderMock.cs new file mode 100644 index 0000000..9a593e8 --- /dev/null +++ b/source/StockTicker.Test/TestHelpers/ActionBuilderMock.cs @@ -0,0 +1,111 @@ +//------------------------------------------------------------------------------- +// +// Copyright (c) 2012 +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +//------------------------------------------------------------------------------- + +namespace StockTicker.TestHelpers +{ + using System; + using System.Collections; + using System.Collections.Generic; + using System.Linq; + + using Caliburn.Micro; + + using Moq; + + using StockTicker.Actions; + + public class ActionBuilderMock : IActionBuilder, IEnumerable + { + private readonly List actionInfo; + + public ActionBuilderMock() + : this(new List()) + { + } + + private ActionBuilderMock(List actionInfo) + { + this.actionInfo = actionInfo; + } + + IEnumerator IEnumerable.GetEnumerator() + { + return this.actionInfo.GetEnumerator(); + } + + public IEnumerator GetEnumerator() + { + return this.actionInfo + .Select(info => Activator.CreateInstance(typeof(Mock<>).MakeGenericType(info.ResultType))) + .Select(mock => ((dynamic)mock).Object) + .Cast() + .GetEnumerator(); + } + + IEnumerator IEnumerable.GetEnumerator() + { + return this.GetEnumerator(); + } + + public IActionBuilder Execute() where TResult : IResult + { + this.actionInfo.Add(new ActionInfo(typeof(TResult), null)); + return this; + } + + public IActionBuilder Execute(object prototype) where TResult : IResult + { + this.actionInfo.Add(new ActionInfo(typeof(TResult), prototype)); + + return this; + } + + public IActionBuilder ScopeWith(Action builder, object enterPrototype, object exitPrototype) where TEnterResult : IResult where TExitResult : IResult + { + this.actionInfo.Add(new ActionInfo(typeof(TEnterResult), enterPrototype)); + + builder(new ActionBuilderMock(this.actionInfo)); + + this.actionInfo.Add(new ActionInfo(typeof(TExitResult), exitPrototype)); + + return this; + } + + public IActionBuilder ScopeWith(Action builder, object enterPrototype) where TEnterResult : IResult where TExitResult : IResult + { + this.actionInfo.Add(new ActionInfo(typeof(TEnterResult), enterPrototype)); + + builder(new ActionBuilderMock(this.actionInfo)); + + this.actionInfo.Add(new ActionInfo(typeof(TExitResult), null)); + + return this; + } + + public IActionBuilder ScopeWith(Action builder) where TEnterResult : IResult where TExitResult : IResult + { + this.actionInfo.Add(new ActionInfo(typeof(TEnterResult), null)); + + builder(new ActionBuilderMock(this.actionInfo)); + + this.actionInfo.Add(new ActionInfo(typeof(TExitResult), null)); + + return this; + } + } +} \ No newline at end of file diff --git a/source/StockTicker.Test/TestHelpers/FutureExtensions.cs b/source/StockTicker.Test/TestHelpers/ActionBuilderMockExtensions.cs similarity index 67% rename from source/StockTicker.Test/TestHelpers/FutureExtensions.cs rename to source/StockTicker.Test/TestHelpers/ActionBuilderMockExtensions.cs index 52988a4..6a1efe3 100644 --- a/source/StockTicker.Test/TestHelpers/FutureExtensions.cs +++ b/source/StockTicker.Test/TestHelpers/ActionBuilderMockExtensions.cs @@ -1,5 +1,5 @@ //------------------------------------------------------------------------------- -// +// // Copyright (c) 2012 // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,13 +18,16 @@ namespace StockTicker.TestHelpers { - public static class FutureExtensions + using StockTicker.Actions; + + public static class ActionBuilderMockExtensions { - public static FutureMock AsFuture(this TValue value) - { - var future = new FutureMock(); - future.SetValue(value); - return future; - } + public static T AttachBuilder(this T actionsAware, ActionBuilderMock builder) + where T : IUseActions + { + actionsAware.Actions = () => builder; + + return actionsAware; + } } } \ No newline at end of file diff --git a/source/StockTicker/Authentication/IChooseUsernameViewModel.cs b/source/StockTicker.Test/TestHelpers/ActionInfo.cs similarity index 66% rename from source/StockTicker/Authentication/IChooseUsernameViewModel.cs rename to source/StockTicker.Test/TestHelpers/ActionInfo.cs index b6c0d6e..e58263b 100644 --- a/source/StockTicker/Authentication/IChooseUsernameViewModel.cs +++ b/source/StockTicker.Test/TestHelpers/ActionInfo.cs @@ -1,5 +1,5 @@ //------------------------------------------------------------------------------- -// +// // Copyright (c) 2012 // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,16 +16,20 @@ // //------------------------------------------------------------------------------- -namespace StockTicker.Authentication +namespace StockTicker.TestHelpers { - using StockTicker.Actions; + using System; - public interface IChooseUserNameViewModel : IAuthenticationStep, IUseActions + public class ActionInfo { - string FirstName { get; } + public ActionInfo(Type resultType, object input) + { + this.ResultType = resultType; + this.Input = input; + } - string LastName { get; } + public Type ResultType { get; private set; } - string UserName { get; } + public object Input { get; private set; } } } \ No newline at end of file diff --git a/source/StockTicker/Authentication/ChoosePasswordView.cs b/source/StockTicker.Test/TestHelpers/FakePresentationSource.cs similarity index 62% rename from source/StockTicker/Authentication/ChoosePasswordView.cs rename to source/StockTicker.Test/TestHelpers/FakePresentationSource.cs index f38458e..0f98860 100644 --- a/source/StockTicker/Authentication/ChoosePasswordView.cs +++ b/source/StockTicker.Test/TestHelpers/FakePresentationSource.cs @@ -1,5 +1,5 @@ //------------------------------------------------------------------------------- -// +// // Copyright (c) 2012 // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,23 +16,26 @@ // //------------------------------------------------------------------------------- -namespace StockTicker.Authentication +namespace StockTicker.TestHelpers { - public partial class ChoosePasswordView + using System.Windows; + using System.Windows.Media; + + internal class FakePresentationSource : PresentationSource { - public static object SampleData + public override Visual RootVisual { get; set; } + + public override bool IsDisposed { get { - var choosePasswordViewModel = new ChoosePasswordViewModel(null) - { - FirstName = "User", - LastName = "Fritz", - UserName = "user.fritz" - }; - - return choosePasswordViewModel; + return false; } } + + protected override CompositionTarget GetCompositionTargetCore() + { + throw new System.NotImplementedException(); + } } } \ No newline at end of file diff --git a/source/StockTicker.Test/TestHelpers/ResultExtensionsForTesting.cs b/source/StockTicker.Test/TestHelpers/ResultExtensionsForTesting.cs index 72feeec..208d429 100644 --- a/source/StockTicker.Test/TestHelpers/ResultExtensionsForTesting.cs +++ b/source/StockTicker.Test/TestHelpers/ResultExtensionsForTesting.cs @@ -24,8 +24,8 @@ namespace StockTicker.TestHelpers using Caliburn.Micro; - using FluentAssertions.Assertions; - using FluentAssertions.EventMonitoring; + using FluentAssertions; + using FluentAssertions.Primitives; using Moq; @@ -66,7 +66,7 @@ public static void BeDecoratedWith(this ObjectAssertions assertions) { IEnumerable attributes = assertions.Subject.GetType().GetAttributes(false); - FluentAssertions.Execute + FluentAssertions.Execution.Execute .Verification .ForCondition(attributes.Any()) .BecauseOf("Attribute {0} could not be found.", typeof(TAttribute).FullName) diff --git a/source/StockTicker.Test/packages.config b/source/StockTicker.Test/packages.config index 318b8e8..cc6dbaf 100644 --- a/source/StockTicker.Test/packages.config +++ b/source/StockTicker.Test/packages.config @@ -1,11 +1,10 @@  - - - + + + - - - - + + + \ No newline at end of file diff --git a/source/StockTicker.msbuild b/source/StockTicker.msbuild index a5f9c4e..703b905 100644 --- a/source/StockTicker.msbuild +++ b/source/StockTicker.msbuild @@ -187,7 +187,7 @@ - + \ No newline at end of file diff --git a/source/StockTicker.sln b/source/StockTicker.sln index d3e69c0..2463cb6 100644 --- a/source/StockTicker.sln +++ b/source/StockTicker.sln @@ -1,12 +1,20 @@  -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StockTicker", "StockTicker\StockTicker.csproj", "{ECE87891-83C1-4CB9-A253-3EA7D1914269}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StockTicker.Test", "StockTicker.Test\StockTicker.Test.csproj", "{F9E20B24-DEB5-40B9-8C4B-44F3F39067E4}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StockTicker.Specification", "StockTicker.Specification\StockTicker.Specification.csproj", "{FA85776B-D3B5-439D-A349-5CD1108CE8CB}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{B864226C-68C6-4BA6-842D-C9D69C627957}" + ProjectSection(SolutionItems) = preProject + .nuget\NuGet.Config = .nuget\NuGet.Config + .nuget\NuGet.exe = .nuget\NuGet.exe + .nuget\NuGet.targets = .nuget\NuGet.targets + .nuget\packages.config = .nuget\packages.config + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU diff --git a/source/StockTicker/Actions/ActionsModule.cs b/source/StockTicker/Actions/ActionsModule.cs index fb9b9da..ac68e7c 100644 --- a/source/StockTicker/Actions/ActionsModule.cs +++ b/source/StockTicker/Actions/ActionsModule.cs @@ -20,6 +20,7 @@ namespace StockTicker.Actions { using Caliburn.Micro; + using Ninject.Activation.Strategies; using Ninject.Extensions.Conventions; using Ninject.Modules; @@ -27,6 +28,8 @@ public class ActionsModule : NinjectModule { public override void Load() { + this.Kernel.Components.Add(); + this.Bind().To(); this.Bind().To(); this.Bind().To(); diff --git a/source/StockTicker.Test/TestHelpers/FutureMock.cs b/source/StockTicker/Actions/UseActionsActivationStrategy.cs similarity index 60% rename from source/StockTicker.Test/TestHelpers/FutureMock.cs rename to source/StockTicker/Actions/UseActionsActivationStrategy.cs index af65dd3..015333d 100644 --- a/source/StockTicker.Test/TestHelpers/FutureMock.cs +++ b/source/StockTicker/Actions/UseActionsActivationStrategy.cs @@ -1,5 +1,5 @@ //------------------------------------------------------------------------------- -// +// // Copyright (c) 2012 // // Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,24 +16,18 @@ // //------------------------------------------------------------------------------- -namespace StockTicker.TestHelpers +namespace StockTicker.Actions { - public sealed class FutureMock : IFutureValueSetter, IFutureValue + using Ninject; + using Ninject.Activation.Strategies; + + public class UseActionsActivationStrategy : ActivationStrategy { - public FutureMock() + public override void Activate(Ninject.Activation.IContext context, Ninject.Activation.InstanceReference reference) { - } + reference.IfInstanceIs(useAction => { useAction.Actions = () => context.Kernel.Get(); }); - public FutureMock(TValue value) - { - this.SetValue(value); - } - - public TValue Value { get; private set; } - - public void SetValue(TValue value) - { - this.Value = value; + base.Activate(context, reference); } } } \ No newline at end of file diff --git a/source/StockTicker/AppBootstrapper.cs b/source/StockTicker/AppBootstrapper.cs index 2e25143..7ee31a9 100644 --- a/source/StockTicker/AppBootstrapper.cs +++ b/source/StockTicker/AppBootstrapper.cs @@ -26,10 +26,9 @@ namespace StockTicker using Ninject; - using StockTicker.Actions; using StockTicker.Localization; - public class AppBootstrapper : Bootstrapper + public class AppBootstrapper : BootstrapperBase { private ILocalizer localizer; @@ -41,6 +40,7 @@ public AppBootstrapper() public AppBootstrapper(bool useApplication) : base(useApplication) { + this.Start(); } protected StandardKernel Kernel { get; private set; } @@ -57,22 +57,6 @@ protected override IEnumerable SelectAssemblies() protected override void Configure() { - // NOTE: This shows how to hook into Caliburn.Micro magic. Everytime a new view model is binded I check - // whether the view model wants to use action builders. If this is the case a factory is provided for the - // target view model. The default Bind Delegate must be saved in local variable and reintroduced in the - // anonymous delegate. - var defaultBindingAction = ViewModelBinder.Bind; - ViewModelBinder.Bind = (rootModel, view, context) => - { - defaultBindingAction(rootModel, view, context); - - var useAction = rootModel as IUseActions; - if (useAction != null) - { - useAction.Actions = () => this.Kernel.Get(); - } - }; - this.Kernel = new StandardKernel(); this.Kernel.Load(this.SelectAssemblies()); } @@ -82,7 +66,7 @@ protected override void OnStartup(object sender, System.Windows.StartupEventArgs this.localizer = this.Kernel.Get(); this.localizer.Initialize(); - DisplayRootViewFor(typeof(IStockTickerViewModel)); + this.DisplayRootViewFor(typeof(IStockTickerViewModel)); } protected override void OnExit(object sender, EventArgs e) diff --git a/source/StockTicker/Authentication/Authenticate.cs b/source/StockTicker/Authentication/Authenticate.cs deleted file mode 100644 index 760041a..0000000 --- a/source/StockTicker/Authentication/Authenticate.cs +++ /dev/null @@ -1,55 +0,0 @@ -//------------------------------------------------------------------------------- -// -// Copyright (c) 2012 -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//------------------------------------------------------------------------------- - -namespace StockTicker.Authentication -{ - using System; - using System.Dynamic; - using System.Windows; - using System.Windows.Controls.Primitives; - - using Caliburn.Micro; - - // NOTE: IResult which opens a dialog window with dynamic placement on the screen. The window manager takes care of all the rest. - internal class Authenticate : IAuthenticate - { - private readonly IWindowManager windowManager; - - private readonly IAuthenticationViewModel authenticationViewModel; - - public Authenticate(IWindowManager windowManager, IAuthenticationViewModel authenticationViewModel) - { - this.windowManager = windowManager; - this.authenticationViewModel = authenticationViewModel; - } - - public event EventHandler Completed = delegate { }; - - public void Execute(ActionExecutionContext context) - { - dynamic settings = new ExpandoObject(); - settings.Placement = PlacementMode.Center; - settings.ResizeMode = ResizeMode.NoResize; - settings.ShowInTaskbar = false; - - this.windowManager.ShowDialog(this.authenticationViewModel, null, settings); - - this.Completed(this, new ResultCompletionEventArgs()); - } - } -} \ No newline at end of file diff --git a/source/StockTicker/Authentication/Authentication.Designer.cs b/source/StockTicker/Authentication/Authentication.Designer.cs deleted file mode 100644 index 945b8a5..0000000 --- a/source/StockTicker/Authentication/Authentication.Designer.cs +++ /dev/null @@ -1,162 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.261 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace StockTicker.Authentication { - using System; - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Authentication { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Authentication() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("StockTicker.Authentication.Authentication", typeof(Authentication).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to Authentication. - /// - internal static string AuthenticationTitle { - get { - return ResourceManager.GetString("AuthenticationTitle", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Let's choose your password. - /// - internal static string ChoosePassword { - get { - return ResourceManager.GetString("ChoosePassword", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Let's choose your username. - /// - internal static string ChooseUserName { - get { - return ResourceManager.GetString("ChooseUserName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to First name. - /// - internal static string FirstName { - get { - return ResourceManager.GetString("FirstName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to How about one of these?. - /// - internal static string HowAbout { - get { - return ResourceManager.GetString("HowAbout", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Last name. - /// - internal static string LastName { - get { - return ResourceManager.GetString("LastName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Create a password. - /// - internal static string Password { - get { - return ResourceManager.GetString("Password", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Retyped password must match!. - /// - internal static string PasswordRetypeDoesNotMatch { - get { - return ResourceManager.GetString("PasswordRetypeDoesNotMatch", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Pick a username. - /// - internal static string PickUserName { - get { - return ResourceManager.GetString("PickUserName", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Fetching suggestion.... - /// - internal static string Suggestion { - get { - return ResourceManager.GetString("Suggestion", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to User name. - /// - internal static string UserName { - get { - return ResourceManager.GetString("UserName", resourceCulture); - } - } - } -} diff --git a/source/StockTicker/Authentication/Authentication.resx b/source/StockTicker/Authentication/Authentication.resx deleted file mode 100644 index 65c7cb8..0000000 --- a/source/StockTicker/Authentication/Authentication.resx +++ /dev/null @@ -1,153 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - Authentication - - - Let's choose your password - - - Let's choose your username - - - First name - - - How about one of these? - - - Last name - - - Create a password - - - Retyped password must match! - - - Pick a username - - - Fetching suggestion... - - - User name - - \ No newline at end of file diff --git a/source/StockTicker/Authentication/AuthenticationExtensions.cs b/source/StockTicker/Authentication/AuthenticationExtensions.cs deleted file mode 100644 index a884e3d..0000000 --- a/source/StockTicker/Authentication/AuthenticationExtensions.cs +++ /dev/null @@ -1,52 +0,0 @@ -//------------------------------------------------------------------------------- -// -// Copyright (c) 2012 -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//------------------------------------------------------------------------------- - -namespace StockTicker.Authentication -{ - using System; - using System.Collections.Generic; - - using StockTicker.Actions; - using StockTicker.Externals; - - // NOTE: Provides not only smarter syntax for actions but also some convenience mapping methods which could also be achieved with tools like AutoMapper. - internal static class AuthenticationExtensions - { - public static IActionBuilder WithLogin(this IActionBuilder builder, Action configure) - { - return builder.ScopeWith(configure); - } - - public static IActionBuilder SuggestUsernames(this IActionBuilder builder, PotentialNewUserModel potentialNewUser, ICollection suggestedUsernames) - { - return builder.Execute(new { potentialNewUser, suggestedUsernames }); - } - - public static UserNameChosen ToUserNameChosen(this IChooseUserNameViewModel chooseUserNameViewModel) - { - return new UserNameChosen(chooseUserNameViewModel.FirstName, chooseUserNameViewModel.LastName, chooseUserNameViewModel.UserName); - } - - public static void FromChosenUserName(this IChoosePasswordViewModel choosePasswordViewModel, UserNameChosen message) - { - choosePasswordViewModel.FirstName = message.FirstName; - choosePasswordViewModel.LastName = message.LastName; - choosePasswordViewModel.UserName = message.UserName; - } - } -} \ No newline at end of file diff --git a/source/StockTicker/Authentication/AuthenticationModule.cs b/source/StockTicker/Authentication/AuthenticationModule.cs deleted file mode 100644 index a2af990..0000000 --- a/source/StockTicker/Authentication/AuthenticationModule.cs +++ /dev/null @@ -1,41 +0,0 @@ -//------------------------------------------------------------------------------- -// -// Copyright (c) 2012 -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//------------------------------------------------------------------------------- - -namespace StockTicker.Authentication -{ - using FluentValidation; - - using Ninject.Modules; - - using StockTicker.Extensions; - - public class AuthenticationModule : NinjectModule - { - public override void Load() - { - this.Bind().To(); - - this.Bind().To().RegisterOnEventAggregator(); - this.Bind().To().RegisterOnEventAggregator(); - - this.Bind().To().InSingletonScope(); - - this.Bind>().To(); - } - } -} \ No newline at end of file diff --git a/source/StockTicker/Authentication/AuthenticationStepFactory.cs b/source/StockTicker/Authentication/AuthenticationStepFactory.cs deleted file mode 100644 index 7f0835a..0000000 --- a/source/StockTicker/Authentication/AuthenticationStepFactory.cs +++ /dev/null @@ -1,42 +0,0 @@ -//------------------------------------------------------------------------------- -// -// Copyright (c) 2012 -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -//------------------------------------------------------------------------------- - -namespace StockTicker.Authentication -{ - using System.Collections.Generic; - - using Ninject; - using Ninject.Syntax; - - // NOTE: Concrete step factory which knows how the wizard steps are composed. - internal class AuthenticationStepFactory : IAuthenticationStepFactory - { - private readonly IResolutionRoot resolutionRoot; - - public AuthenticationStepFactory(IResolutionRoot resolutionRoot) - { - this.resolutionRoot = resolutionRoot; - } - - public IEnumerable CreateSteps() - { - yield return this.resolutionRoot.Get(); - yield return this.resolutionRoot.Get(); - } - } -} \ No newline at end of file diff --git a/source/StockTicker/Authentication/AuthenticationView.xaml b/source/StockTicker/Authentication/AuthenticationView.xaml deleted file mode 100644 index ceb6cbf..0000000 --- a/source/StockTicker/Authentication/AuthenticationView.xaml +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - -