-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added navigation to WPF application. * Added essential services. This folder is not to be removed. Services should not be edited. * Added Logging * Updated .NET framework reference to match the PCL. Finished startup logic. * Lowered WPF Project to 4.5.1. Removed Unused reference in Weather.Core. * Added an Edit ViewModel * Removed unused projects. * Added Unit test. * Added logic to search for location by 'City, State' or 'Postal Code' or 'Latitude, Longitude. Added unit test to test logic.
- Loading branch information
1 parent
11521ec
commit 8bd5a59
Showing
41 changed files
with
1,666 additions
and
307 deletions.
There are no files selected for viewing
157 changes: 157 additions & 0 deletions
157
Weather.Universal/Weather.Core.Tests/AddLocationViewModelTests.vb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,157 @@ | ||
Imports System.Text | ||
Imports Microsoft.VisualStudio.TestTools.UnitTesting | ||
|
||
<TestClass()> | ||
Public Class AddLocationViewModelTests | ||
Inherits UnitTestBase | ||
|
||
|
||
<TestMethod()> | ||
Public Sub EmptySearchString_ShouldNotPerformSearch() | ||
' Prepare | ||
Dim isUsingLocationService As Boolean = False | ||
Dim locationService As New Services.Fakes.StubILocationService | ||
With locationService | ||
.GetLocationByCityAndStateAsyncStringStringInt32CancellationToken = Async Function() | ||
isUsingLocationService = True | ||
Await Task.Delay(0) | ||
Return Nothing | ||
End Function | ||
.GetLocationByLatitudeLongitudeAsyncDoubleDoubleInt32CancellationToken = Async Function() | ||
isUsingLocationService = True | ||
Await Task.Delay(0) | ||
Return Nothing | ||
End Function | ||
.GetLocationByPostalCodeAsyncStringInt32CancellationToken = Async Function() | ||
isUsingLocationService = True | ||
Await Task.Delay(0) | ||
Return Nothing | ||
End Function | ||
End With | ||
Dim viewModel As New ViewModels.AddLocationViewModel(CreateMessageBus, CreateDialogService, CreateNavigationService, locationService) | ||
|
||
' Execute | ||
viewModel.SearchCommand.Execute(Nothing) | ||
|
||
' Assert | ||
Assert.IsFalse(isUsingLocationService, "AddLocationViewModel is still trying to search when an empty search string.") | ||
End Sub | ||
|
||
<TestMethod()> | ||
Public Sub USZipCodeSearchString_ShouldPerformSearchWithPostalCodeQuery() | ||
' Prepare | ||
Dim isUsingLocationServiceByPostalCode As Boolean = False | ||
Dim isUsingLocationServiceByCityState As Boolean = False | ||
Dim isUsingLocationServiceByLatLon As Boolean = False | ||
Dim locationService As New Services.Fakes.StubILocationService | ||
With locationService | ||
.GetLocationByCityAndStateAsyncStringStringInt32CancellationToken = Async Function() | ||
isUsingLocationServiceByCityState = True | ||
Await Task.Delay(0) | ||
Return Nothing | ||
End Function | ||
|
||
.GetLocationByLatitudeLongitudeAsyncDoubleDoubleInt32CancellationToken = Async Function() | ||
isUsingLocationServiceByLatLon = True | ||
Await Task.Delay(0) | ||
Return Nothing | ||
End Function | ||
|
||
.GetLocationByPostalCodeAsyncStringInt32CancellationToken = Async Function() | ||
isUsingLocationServiceByPostalCode = True | ||
Await Task.Delay(0) | ||
Return Nothing | ||
End Function | ||
End With | ||
Dim viewModel As New ViewModels.AddLocationViewModel(CreateMessageBus, CreateDialogService, CreateNavigationService, locationService) | ||
viewModel.SearchString = "12345" | ||
|
||
' Execute | ||
viewModel.SearchCommand.Execute(Nothing) | ||
|
||
' Assert | ||
Assert.IsFalse(isUsingLocationServiceByCityState, "AddLocationViewModel is using City/State when using a US Postal Code search string.") | ||
Assert.IsFalse(isUsingLocationServiceByLatLon, "AddLocationViewModel is using Latitude/Longitude when using a US Postal Code search string.") | ||
Assert.IsTrue(isUsingLocationServiceByPostalCode, "AddLocationViewModel is not using Postal Code when using a US Postal Code search string.") | ||
|
||
End Sub | ||
|
||
<TestMethod()> | ||
Public Sub CityStateSearchString_ShouldPerformSearchWithPostalCodeQuery() | ||
' Prepare | ||
Dim isUsingLocationServiceByPostalCode As Boolean = False | ||
Dim isUsingLocationServiceByCityState As Boolean = False | ||
Dim isUsingLocationServiceByLatLon As Boolean = False | ||
Dim locationService As New Services.Fakes.StubILocationService | ||
With locationService | ||
.GetLocationByCityAndStateAsyncStringStringInt32CancellationToken = Async Function() | ||
isUsingLocationServiceByCityState = True | ||
Await Task.Delay(0) | ||
Return Nothing | ||
End Function | ||
|
||
.GetLocationByLatitudeLongitudeAsyncDoubleDoubleInt32CancellationToken = Async Function() | ||
isUsingLocationServiceByLatLon = True | ||
Await Task.Delay(0) | ||
Return Nothing | ||
End Function | ||
|
||
.GetLocationByPostalCodeAsyncStringInt32CancellationToken = Async Function() | ||
isUsingLocationServiceByPostalCode = True | ||
Await Task.Delay(0) | ||
Return Nothing | ||
End Function | ||
End With | ||
|
||
Dim viewModel As New ViewModels.AddLocationViewModel(CreateMessageBus, CreateDialogService, CreateNavigationService, locationService) | ||
viewModel.SearchString = "City, State" | ||
|
||
' Execute | ||
viewModel.SearchCommand.Execute(Nothing) | ||
|
||
' Assert | ||
Assert.IsTrue(isUsingLocationServiceByCityState, "AddLocationViewModel is not using City/State when using a <City>, <State> search string.") | ||
Assert.IsFalse(isUsingLocationServiceByLatLon, "AddLocationViewModel is using Latitude/Longitude when using a <City>, <State> search string.") | ||
Assert.IsFalse(isUsingLocationServiceByPostalCode, "AddLocationViewModel is using Postal Code when using a <City>, <State> search string.") | ||
End Sub | ||
|
||
<TestMethod()> | ||
Public Sub LatLonSearchString_ShouldPerformSearchWithPostalCodeQuery() | ||
' Prepare | ||
Dim isUsingLocationServiceByPostalCode As Boolean = False | ||
Dim isUsingLocationServiceByCityState As Boolean = False | ||
Dim isUsingLocationServiceByLatLon As Boolean = False | ||
Dim locationService As New Services.Fakes.StubILocationService | ||
With locationService | ||
.GetLocationByCityAndStateAsyncStringStringInt32CancellationToken = Async Function() | ||
isUsingLocationServiceByCityState = True | ||
Await Task.Delay(0) | ||
Return Nothing | ||
End Function | ||
|
||
.GetLocationByLatitudeLongitudeAsyncDoubleDoubleInt32CancellationToken = Async Function() | ||
isUsingLocationServiceByLatLon = True | ||
Await Task.Delay(0) | ||
Return Nothing | ||
End Function | ||
|
||
.GetLocationByPostalCodeAsyncStringInt32CancellationToken = Async Function() | ||
isUsingLocationServiceByPostalCode = True | ||
Await Task.Delay(0) | ||
Return Nothing | ||
End Function | ||
End With | ||
Dim viewModel As New ViewModels.AddLocationViewModel(CreateMessageBus, CreateDialogService, CreateNavigationService, locationService) | ||
viewModel.SearchString = "123.45, 123.45" | ||
|
||
' Execute | ||
viewModel.SearchCommand.Execute(Nothing) | ||
|
||
' Assert | ||
Assert.IsFalse(isUsingLocationServiceByCityState, "AddLocationViewModel is using City/State when using a <Latitude>, <Longitude> search string.") | ||
Assert.IsTrue(isUsingLocationServiceByLatLon, "AddLocationViewModel is not using Latitude/Longitude when using a <Latitude>, <Longitude> search string.") | ||
Assert.IsFalse(isUsingLocationServiceByPostalCode, "AddLocationViewModel is using Postal Code when using a <Latitude>, <Longitude> search string.") | ||
End Sub | ||
|
||
|
||
End Class |
Binary file not shown.
13 changes: 13 additions & 0 deletions
13
Weather.Universal/Weather.Core.Tests/My Project/Application.Designer.vb
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
Weather.Universal/Weather.Core.Tests/My Project/Application.myapp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<MyApplicationData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> | ||
<MySubMain>false</MySubMain> | ||
<SingleInstance>false</SingleInstance> | ||
<ShutdownMode>0</ShutdownMode> | ||
<EnableVisualStyles>true</EnableVisualStyles> | ||
<AuthenticationMode>0</AuthenticationMode> | ||
<ApplicationType>1</ApplicationType> | ||
<SaveMySettingsOnExit>true</SaveMySettingsOnExit> | ||
</MyApplicationData> |
35 changes: 35 additions & 0 deletions
35
Weather.Universal/Weather.Core.Tests/My Project/AssemblyInfo.vb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
Imports System | ||
Imports System.Reflection | ||
Imports System.Runtime.InteropServices | ||
|
||
' General Information about an assembly is controlled through the following | ||
' set of attributes. Change these attribute values to modify the information | ||
' associated with an assembly. | ||
|
||
' Review the values of the assembly attributes | ||
|
||
<Assembly: AssemblyTitle("Weather.Core.Tests")> | ||
<Assembly: AssemblyDescription("")> | ||
<Assembly: AssemblyCompany("")> | ||
<Assembly: AssemblyProduct("Weather.Core.Tests")> | ||
<Assembly: AssemblyCopyright("Copyright © 2018")> | ||
<Assembly: AssemblyTrademark("")> | ||
|
||
<Assembly: ComVisible(False)> | ||
|
||
'The following GUID is for the ID of the typelib if this project is exposed to COM | ||
<Assembly: Guid("fd7eec2b-4f7b-4ce3-a68b-f1f6616bf13d")> | ||
|
||
' Version information for an assembly consists of the following four values: | ||
' | ||
' Major Version | ||
' Minor Version | ||
' Build Number | ||
' Revision | ||
' | ||
' You can specify all the values or you can default the Build and Revision Numbers | ||
' by using the '*' as shown below: | ||
' <Assembly: AssemblyVersion("1.0.*")> | ||
|
||
<Assembly: AssemblyVersion("1.0.0.0")> | ||
<Assembly: AssemblyFileVersion("1.0.0.0")> |
63 changes: 63 additions & 0 deletions
63
Weather.Universal/Weather.Core.Tests/My Project/Resources.Designer.vb
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.