From bc155ce6579c0b4aafd38545b5bc3b7c4480fef8 Mon Sep 17 00:00:00 2001 From: Donatas Adamonis Date: Tue, 30 May 2017 17:48:36 +0200 Subject: unitest tests --- ApartmentManager/ApartmentManager.sln | 22 +++ .../ApartmentManager/ApartmentManager.csproj | 4 +- .../ApartmentManager/Handler/ApartmentHandler.cs | 4 +- .../ApartmentManager/Singletons/UserSingleton.cs | 5 +- .../ApartmentManagerUnitTestProject.csproj | 157 +++++++++++++++++++++ .../Assets/LockScreenLogo.scale-200.png | Bin 0 -> 1430 bytes .../Assets/SplashScreen.scale-200.png | Bin 0 -> 7700 bytes .../Assets/Square150x150Logo.scale-200.png | Bin 0 -> 2937 bytes .../Assets/Square44x44Logo.scale-200.png | Bin 0 -> 1647 bytes ...are44x44Logo.targetsize-24_altform-unplated.png | Bin 0 -> 1255 bytes .../Assets/StoreLogo.png | Bin 0 -> 1451 bytes .../Assets/Wide310x150Logo.scale-200.png | Bin 0 -> 3204 bytes .../Package.appxmanifest | 45 ++++++ .../Properties/AssemblyInfo.cs | 18 +++ .../Properties/UnitTestApp.rd.xml | 29 ++++ .../ApartmentManagerUnitTestProject/UnitTest.cs | 40 ++++++ .../UnitTestApp.xaml | 8 ++ .../UnitTestApp.xaml.cs | 102 +++++++++++++ 18 files changed, 429 insertions(+), 5 deletions(-) create mode 100644 ApartmentManager/ApartmentManagerUnitTestProject/ApartmentManagerUnitTestProject.csproj create mode 100644 ApartmentManager/ApartmentManagerUnitTestProject/Assets/LockScreenLogo.scale-200.png create mode 100644 ApartmentManager/ApartmentManagerUnitTestProject/Assets/SplashScreen.scale-200.png create mode 100644 ApartmentManager/ApartmentManagerUnitTestProject/Assets/Square150x150Logo.scale-200.png create mode 100644 ApartmentManager/ApartmentManagerUnitTestProject/Assets/Square44x44Logo.scale-200.png create mode 100644 ApartmentManager/ApartmentManagerUnitTestProject/Assets/Square44x44Logo.targetsize-24_altform-unplated.png create mode 100644 ApartmentManager/ApartmentManagerUnitTestProject/Assets/StoreLogo.png create mode 100644 ApartmentManager/ApartmentManagerUnitTestProject/Assets/Wide310x150Logo.scale-200.png create mode 100644 ApartmentManager/ApartmentManagerUnitTestProject/Package.appxmanifest create mode 100644 ApartmentManager/ApartmentManagerUnitTestProject/Properties/AssemblyInfo.cs create mode 100644 ApartmentManager/ApartmentManagerUnitTestProject/Properties/UnitTestApp.rd.xml create mode 100644 ApartmentManager/ApartmentManagerUnitTestProject/UnitTest.cs create mode 100644 ApartmentManager/ApartmentManagerUnitTestProject/UnitTestApp.xaml create mode 100644 ApartmentManager/ApartmentManagerUnitTestProject/UnitTestApp.xaml.cs diff --git a/ApartmentManager/ApartmentManager.sln b/ApartmentManager/ApartmentManager.sln index 86bb4ee..24bd7f5 100644 --- a/ApartmentManager/ApartmentManager.sln +++ b/ApartmentManager/ApartmentManager.sln @@ -10,6 +10,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApartmentManager", "Apartme EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HousingWebApi", "HousingWebApi\HousingWebApi.csproj", "{D777744A-9676-4193-BD59-6F30C724C87A}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApartmentManagerUnitTestProject", "ApartmentManagerUnitTestProject\ApartmentManagerUnitTestProject.csproj", "{A518A278-3296-4260-A15C-B3C165C28943}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -59,6 +61,26 @@ Global {D777744A-9676-4193-BD59-6F30C724C87A}.Release|x64.Build.0 = Release|Any CPU {D777744A-9676-4193-BD59-6F30C724C87A}.Release|x86.ActiveCfg = Release|Any CPU {D777744A-9676-4193-BD59-6F30C724C87A}.Release|x86.Build.0 = Release|Any CPU + {A518A278-3296-4260-A15C-B3C165C28943}.Debug|Any CPU.ActiveCfg = Debug|x86 + {A518A278-3296-4260-A15C-B3C165C28943}.Debug|ARM.ActiveCfg = Debug|ARM + {A518A278-3296-4260-A15C-B3C165C28943}.Debug|ARM.Build.0 = Debug|ARM + {A518A278-3296-4260-A15C-B3C165C28943}.Debug|ARM.Deploy.0 = Debug|ARM + {A518A278-3296-4260-A15C-B3C165C28943}.Debug|x64.ActiveCfg = Debug|x64 + {A518A278-3296-4260-A15C-B3C165C28943}.Debug|x64.Build.0 = Debug|x64 + {A518A278-3296-4260-A15C-B3C165C28943}.Debug|x64.Deploy.0 = Debug|x64 + {A518A278-3296-4260-A15C-B3C165C28943}.Debug|x86.ActiveCfg = Debug|x86 + {A518A278-3296-4260-A15C-B3C165C28943}.Debug|x86.Build.0 = Debug|x86 + {A518A278-3296-4260-A15C-B3C165C28943}.Debug|x86.Deploy.0 = Debug|x86 + {A518A278-3296-4260-A15C-B3C165C28943}.Release|Any CPU.ActiveCfg = Release|x86 + {A518A278-3296-4260-A15C-B3C165C28943}.Release|ARM.ActiveCfg = Release|ARM + {A518A278-3296-4260-A15C-B3C165C28943}.Release|ARM.Build.0 = Release|ARM + {A518A278-3296-4260-A15C-B3C165C28943}.Release|ARM.Deploy.0 = Release|ARM + {A518A278-3296-4260-A15C-B3C165C28943}.Release|x64.ActiveCfg = Release|x64 + {A518A278-3296-4260-A15C-B3C165C28943}.Release|x64.Build.0 = Release|x64 + {A518A278-3296-4260-A15C-B3C165C28943}.Release|x64.Deploy.0 = Release|x64 + {A518A278-3296-4260-A15C-B3C165C28943}.Release|x86.ActiveCfg = Release|x86 + {A518A278-3296-4260-A15C-B3C165C28943}.Release|x86.Build.0 = Release|x86 + {A518A278-3296-4260-A15C-B3C165C28943}.Release|x86.Deploy.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/ApartmentManager/ApartmentManager/ApartmentManager.csproj b/ApartmentManager/ApartmentManager/ApartmentManager.csproj index 44f97b5..377ee1a 100644 --- a/ApartmentManager/ApartmentManager/ApartmentManager.csproj +++ b/ApartmentManager/ApartmentManager/ApartmentManager.csproj @@ -11,8 +11,8 @@ ApartmentManager en-US UAP - 10.0.14393.0 - 10.0.10240.0 + 10.0.15063.0 + 10.0.15063.0 14 512 {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} diff --git a/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs b/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs index 34cbb7c..4cfa4fd 100644 --- a/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs +++ b/ApartmentManager/ApartmentManager/Handler/ApartmentHandler.cs @@ -77,9 +77,9 @@ namespace ApartmentManager.Handler { resident.Picture = "http://i.imgur.com/8KNkU26.png"; } - if (!string.IsNullOrEmpty(resident.FirstName) && !string.IsNullOrEmpty(resident.FirstName)) + if (!string.IsNullOrEmpty(resident.FirstName) && !string.IsNullOrEmpty(resident.LastName)) { - ApiClient.PostData("api/residents/", resident); + var response = ApiClient.PostData("api/residents/", resident); } GetApartmentResidents(); } diff --git a/ApartmentManager/ApartmentManager/Singletons/UserSingleton.cs b/ApartmentManager/ApartmentManager/Singletons/UserSingleton.cs index 1f291c9..37435f5 100644 --- a/ApartmentManager/ApartmentManager/Singletons/UserSingleton.cs +++ b/ApartmentManager/ApartmentManager/Singletons/UserSingleton.cs @@ -9,6 +9,9 @@ namespace ApartmentManager.Singletons public User CurrentUser { get; set; } - private UserSingleton() { } + private UserSingleton() + { + CurrentUser = new User(); + } } } diff --git a/ApartmentManager/ApartmentManagerUnitTestProject/ApartmentManagerUnitTestProject.csproj b/ApartmentManager/ApartmentManagerUnitTestProject/ApartmentManagerUnitTestProject.csproj new file mode 100644 index 0000000..315d0b1 --- /dev/null +++ b/ApartmentManager/ApartmentManagerUnitTestProject/ApartmentManagerUnitTestProject.csproj @@ -0,0 +1,157 @@ + + + + + Debug + x86 + {A518A278-3296-4260-A15C-B3C165C28943} + AppContainerExe + Properties + ApartmentManagerUnitTestProject + ApartmentManagerUnitTestProject + en-US + UAP + 10.0.15063.0 + 10.0.15063.0 + 14 + 512 + {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + ApartmentManagerUnitTestProject_TemporaryKey.pfx + $(VisualStudioVersion) + + + true + bin\x86\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + x86 + false + prompt + true + + + bin\x86\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + x86 + false + prompt + true + true + + + true + bin\ARM\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + ARM + false + prompt + true + + + bin\ARM\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + ARM + false + prompt + true + true + + + true + bin\x64\Debug\ + DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP + ;2008 + full + x64 + false + prompt + true + + + bin\x64\Release\ + TRACE;NETFX_CORE;WINDOWS_UWP + true + ;2008 + pdbonly + x64 + false + prompt + true + true + + + PackageReference + + + + + + + + UnitTestApp.xaml + + + + + + MSBuild:Compile + Designer + + + + + Designer + + + + + + + + + + + + + + + + 5.3.3 + + + 1.1.17 + + + 1.1.17 + + + + + {95401ed6-d03c-417d-8897-81b5454d2426} + ApartmentManager + + + + + + + 14.0 + + + + \ No newline at end of file diff --git a/ApartmentManager/ApartmentManagerUnitTestProject/Assets/LockScreenLogo.scale-200.png b/ApartmentManager/ApartmentManagerUnitTestProject/Assets/LockScreenLogo.scale-200.png new file mode 100644 index 0000000..735f57a Binary files /dev/null and b/ApartmentManager/ApartmentManagerUnitTestProject/Assets/LockScreenLogo.scale-200.png differ diff --git a/ApartmentManager/ApartmentManagerUnitTestProject/Assets/SplashScreen.scale-200.png b/ApartmentManager/ApartmentManagerUnitTestProject/Assets/SplashScreen.scale-200.png new file mode 100644 index 0000000..023e7f1 Binary files /dev/null and b/ApartmentManager/ApartmentManagerUnitTestProject/Assets/SplashScreen.scale-200.png differ diff --git a/ApartmentManager/ApartmentManagerUnitTestProject/Assets/Square150x150Logo.scale-200.png b/ApartmentManager/ApartmentManagerUnitTestProject/Assets/Square150x150Logo.scale-200.png new file mode 100644 index 0000000..af49fec Binary files /dev/null and b/ApartmentManager/ApartmentManagerUnitTestProject/Assets/Square150x150Logo.scale-200.png differ diff --git a/ApartmentManager/ApartmentManagerUnitTestProject/Assets/Square44x44Logo.scale-200.png b/ApartmentManager/ApartmentManagerUnitTestProject/Assets/Square44x44Logo.scale-200.png new file mode 100644 index 0000000..ce342a2 Binary files /dev/null and b/ApartmentManager/ApartmentManagerUnitTestProject/Assets/Square44x44Logo.scale-200.png differ diff --git a/ApartmentManager/ApartmentManagerUnitTestProject/Assets/Square44x44Logo.targetsize-24_altform-unplated.png b/ApartmentManager/ApartmentManagerUnitTestProject/Assets/Square44x44Logo.targetsize-24_altform-unplated.png new file mode 100644 index 0000000..f6c02ce Binary files /dev/null and b/ApartmentManager/ApartmentManagerUnitTestProject/Assets/Square44x44Logo.targetsize-24_altform-unplated.png differ diff --git a/ApartmentManager/ApartmentManagerUnitTestProject/Assets/StoreLogo.png b/ApartmentManager/ApartmentManagerUnitTestProject/Assets/StoreLogo.png new file mode 100644 index 0000000..7385b56 Binary files /dev/null and b/ApartmentManager/ApartmentManagerUnitTestProject/Assets/StoreLogo.png differ diff --git a/ApartmentManager/ApartmentManagerUnitTestProject/Assets/Wide310x150Logo.scale-200.png b/ApartmentManager/ApartmentManagerUnitTestProject/Assets/Wide310x150Logo.scale-200.png new file mode 100644 index 0000000..288995b Binary files /dev/null and b/ApartmentManager/ApartmentManagerUnitTestProject/Assets/Wide310x150Logo.scale-200.png differ diff --git a/ApartmentManager/ApartmentManagerUnitTestProject/Package.appxmanifest b/ApartmentManager/ApartmentManagerUnitTestProject/Package.appxmanifest new file mode 100644 index 0000000..f54fbcf --- /dev/null +++ b/ApartmentManager/ApartmentManagerUnitTestProject/Package.appxmanifest @@ -0,0 +1,45 @@ + + + + + + + + + ApartmentManagerUnitTestProject + Danix + Assets\StoreLogo.png + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/ApartmentManager/ApartmentManagerUnitTestProject/Properties/AssemblyInfo.cs b/ApartmentManager/ApartmentManagerUnitTestProject/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..742e0d1 --- /dev/null +++ b/ApartmentManager/ApartmentManagerUnitTestProject/Properties/AssemblyInfo.cs @@ -0,0 +1,18 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("ApartmentManagerUnitTestProject")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("ApartmentManagerUnitTestProject")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: AssemblyMetadata("TargetPlatform","UAP")] + +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] +[assembly: ComVisible(false)] \ No newline at end of file diff --git a/ApartmentManager/ApartmentManagerUnitTestProject/Properties/UnitTestApp.rd.xml b/ApartmentManager/ApartmentManagerUnitTestProject/Properties/UnitTestApp.rd.xml new file mode 100644 index 0000000..efee59d --- /dev/null +++ b/ApartmentManager/ApartmentManagerUnitTestProject/Properties/UnitTestApp.rd.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/ApartmentManager/ApartmentManagerUnitTestProject/UnitTest.cs b/ApartmentManager/ApartmentManagerUnitTestProject/UnitTest.cs new file mode 100644 index 0000000..52bcb27 --- /dev/null +++ b/ApartmentManager/ApartmentManagerUnitTestProject/UnitTest.cs @@ -0,0 +1,40 @@ + +using System; +using ApartmentManager.ViewModel; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace ApartmentManagerUnitTestProject +{ + [TestClass] + public class UnitTest1 + { + [TestMethod] + public void TestMethod1() + { + ApartmentViewModel model = new ApartmentViewModel(); + model.UserSingleton.CurrentUser.ApartmentId = 1; + model.NewResident.FirstName = "asd"; + model.NewResident.LastName = "lopas"; + model.ApartmentHandler.GetApartmentResidents(); + var currentDefects = model.CatalogSingleton.Residents.Count; + //test// + model.ApartmentHandler.CreateResident(); + Assert.AreNotEqual(currentDefects, model.CatalogSingleton.Residents); + + } + [TestMethod] + public void TestMethod2() + { + ApartmentViewModel model = new ApartmentViewModel(); + model.UserSingleton.CurrentUser.ApartmentId = 1; + model.NewResident.FirstName = "asd"; + model.NewResident.LastName = "lopas"; + model.ApartmentHandler.GetApartmentResidents(); + var currentDefects = model.CatalogSingleton.Residents.Count; + //test// + //model.ApartmentHandler.CreateResident(); + Assert.AreNotEqual(currentDefects, model.CatalogSingleton.Residents); + + } + } +} diff --git a/ApartmentManager/ApartmentManagerUnitTestProject/UnitTestApp.xaml b/ApartmentManager/ApartmentManagerUnitTestProject/UnitTestApp.xaml new file mode 100644 index 0000000..1081191 --- /dev/null +++ b/ApartmentManager/ApartmentManagerUnitTestProject/UnitTestApp.xaml @@ -0,0 +1,8 @@ + + + diff --git a/ApartmentManager/ApartmentManagerUnitTestProject/UnitTestApp.xaml.cs b/ApartmentManager/ApartmentManagerUnitTestProject/UnitTestApp.xaml.cs new file mode 100644 index 0000000..19b8201 --- /dev/null +++ b/ApartmentManager/ApartmentManagerUnitTestProject/UnitTestApp.xaml.cs @@ -0,0 +1,102 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using Windows.ApplicationModel; +using Windows.ApplicationModel.Activation; +using Windows.Foundation; +using Windows.Foundation.Collections; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; +using Windows.UI.Xaml.Controls.Primitives; +using Windows.UI.Xaml.Data; +using Windows.UI.Xaml.Input; +using Windows.UI.Xaml.Media; +using Windows.UI.Xaml.Navigation; + +namespace ApartmentManagerUnitTestProject +{ + /// + /// Provides application-specific behavior to supplement the default Application class. + /// + sealed partial class App : Application + { + /// + /// Initializes the singleton application object. This is the first line of authored code + /// executed, and as such is the logical equivalent of main() or WinMain(). + /// + public App() + { + this.InitializeComponent(); + this.Suspending += OnSuspending; + } + + /// + /// Invoked when the application is launched normally by the end user. Other entry points + /// will be used such as when the application is launched to open a specific file. + /// + /// Details about the launch request and process. + protected override void OnLaunched(LaunchActivatedEventArgs e) + { + +#if DEBUG + if (System.Diagnostics.Debugger.IsAttached) + { + this.DebugSettings.EnableFrameRateCounter = true; + } +#endif + + Frame rootFrame = Window.Current.Content as Frame; + + // Do not repeat app initialization when the Window already has content, + // just ensure that the window is active + if (rootFrame == null) + { + // Create a Frame to act as the navigation context and navigate to the first page + rootFrame = new Frame(); + + rootFrame.NavigationFailed += OnNavigationFailed; + + if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) + { + //TODO: Load state from previously suspended application + } + + // Place the frame in the current Window + Window.Current.Content = rootFrame; + } + + Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.CreateDefaultUI(); + + // Ensure the current window is active + Window.Current.Activate(); + + Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.Run(e.Arguments); + } + + /// + /// Invoked when Navigation to a certain page fails + /// + /// The Frame which failed navigation + /// Details about the navigation failure + void OnNavigationFailed(object sender, NavigationFailedEventArgs e) + { + throw new Exception("Failed to load Page " + e.SourcePageType.FullName); + } + + /// + /// Invoked when application execution is being suspended. Application state is saved + /// without knowing whether the application will be terminated or resumed with the contents + /// of memory still intact. + /// + /// The source of the suspend request. + /// Details about the suspend request. + private void OnSuspending(object sender, SuspendingEventArgs e) + { + var deferral = e.SuspendingOperation.GetDeferral(); + //TODO: Save application state and stop any background activity + deferral.Complete(); + } + } +} -- cgit v1.2.3