diff --git a/Test.TwitterFriendsSearcher.Shared/ControlCenter.cs b/Test.TwitterFriendsSearcher.Shared/ControlCenter.cs new file mode 100644 index 0000000..1bd9ff5 --- /dev/null +++ b/Test.TwitterFriendsSearcher.Shared/ControlCenter.cs @@ -0,0 +1,8 @@ +namespace Test.TwitterFriendsSearcher.Shared +{ + public class ControlCenter + { + public int X { get; set; } + public int Y { get; set; } + } +} \ No newline at end of file diff --git a/Test.TwitterFriendsSearcher.Shared/Properties/AssemblyInfo.cs b/Test.TwitterFriendsSearcher.Shared/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..d7ddbc6 --- /dev/null +++ b/Test.TwitterFriendsSearcher.Shared/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using 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. +[assembly: AssemblyTitle("Test.TwitterFriendsSearcher.Shared")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("Test.TwitterFriendsSearcher.Shared")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2011")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("905010fd-6c58-423b-bdba-701607839963")] + +// 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")] diff --git a/Test.TwitterFriendsSearcher.Shared/Test.TwitterFriendsSearcher.Shared.csproj b/Test.TwitterFriendsSearcher.Shared/Test.TwitterFriendsSearcher.Shared.csproj new file mode 100644 index 0000000..97cbed2 --- /dev/null +++ b/Test.TwitterFriendsSearcher.Shared/Test.TwitterFriendsSearcher.Shared.csproj @@ -0,0 +1,54 @@ + + + + Debug + AnyCPU + 8.0.30703 + 2.0 + {D0AAAA20-2694-4AFD-A53D-1A701C5D6544} + Library + Properties + Test.TwitterFriendsSearcher.Shared + Test.TwitterFriendsSearcher.Shared + v4.0 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Test.TwitterFriendsSearcher/Bootstrapping/BootstrapperTest.cs b/Test.TwitterFriendsSearcher/Bootstrapping/BootstrapperTest.cs new file mode 100644 index 0000000..c7d673c --- /dev/null +++ b/Test.TwitterFriendsSearcher/Bootstrapping/BootstrapperTest.cs @@ -0,0 +1,25 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using StructureMap; +using TwitterFriendsSearcher.Bootstrapping; +using TwitterFriendsSearcher.FollowAlgorithm; + +namespace Test.TwitterFriendsSearcher.Bootstrapping +{ + [TestClass] + public class BootstrapperTest + { + + [TestMethod] + public void should_wire_IncreaseFollowersServices_dependencies() + { + new ApplicationBootstrapper().Bootstrap(); + + var increaseFollowersService = ObjectFactory.GetInstance(); + + var searchExecutor = ObjectFactory.GetInstance(); + + Assert.IsNotNull(increaseFollowersService); + } + + } +} \ No newline at end of file diff --git a/Test.TwitterFriendsSearcher/EndToEnd/ApplicationRunner.cs b/Test.TwitterFriendsSearcher/EndToEnd/ApplicationRunner.cs index 6b4bc7e..12c19a1 100644 --- a/Test.TwitterFriendsSearcher/EndToEnd/ApplicationRunner.cs +++ b/Test.TwitterFriendsSearcher/EndToEnd/ApplicationRunner.cs @@ -1,11 +1,16 @@ using System; using System.Diagnostics; +using System.Linq; using System.Threading; +using System.Windows; +using Test.TwitterFriendsSearcher.TwitterFriendsSearcherUiProvider; using TwitterFriendsSearcher; using TwitterFriendsSearcher.Twitter; using White.Core; +using White.Core.InputDevices; using White.Core.UIItems; using Microsoft.VisualStudio.TestTools.UnitTesting; +using White.Core.UIItems.WindowItems; namespace Test.TwitterFriendsSearcher.EndToEnd { @@ -13,35 +18,70 @@ public class ApplicationRunner { private Application application; + private Keyboard keyboard; + private Mouse mouse; + private Process twitterFriendsSearcherProccess; - public void Tweet(ITwitterWrapper twitterWrapper, string tweet) + public void Launch() { - new Thread(() => - { - Program.TwitterWrapper = twitterWrapper; - Program.Main(tweet); - }).Start(); + keyboard = Keyboard.Instance; + mouse = Mouse.Instance; - Thread.Sleep(1000); + LaunchTwitterFriendsSearcherAndHostTheService(); - var currentProcess = Process.GetCurrentProcess(); - application = Application.Attach(currentProcess.Id); + twitterFriendsSearcherProccess = Process.GetProcessesByName("TwitterFriendsSearcher.Runner")[0]; + + application = Application.Attach(twitterFriendsSearcherProccess.Id); + } + + private void LaunchTwitterFriendsSearcherAndHostTheService() + { + Process.Start(@"..\..\..\..\..\TwitterFriendsSearcher.Runner\bin\Debug\TwitterFriendsSearcher.Runner.exe"); + + // give it a chance to run and host a service + Thread.Sleep(10000); + } + + public void EnterKeywords(string keywords) + { + using (var serviceClient = new TwitterFriendsSearcherUiInfoProviderClient()) + { + var center = serviceClient.GetTextBoxCenterByName("tbKeywords"); + mouse.Click(new Point(center.X, center.Y)); + } + + keyboard.Enter(keywords); + } + + public void ClickButton(string buttonName) + { + using(var serviceClient = new TwitterFriendsSearcherUiInfoProviderClient()) + { + var center = serviceClient.GetButtonCenterByName(buttonName); + mouse.Location = new Point(center.X, center.Y); + mouse.Click(); + } } - public void ReadAndDisplayRecentTweet() + public bool DisplaysAtLeastOneFollowedUser() { - if (Program.MainForm.InvokeRequired) - Program.MainForm.Invoke(new Action(() => Program.MainForm.ReadLatestTweet())); - else - Program.MainForm.ReadLatestTweet(); + using(var serviceClient = new TwitterFriendsSearcherUiInfoProviderClient()) + { + return serviceClient.GetListBoxInfo("lbUsersFollowedAtTheMoment").Items.Length > 0; + } } - public void ShowsTweet(string tweet) + public void StopApplication() { - var mainWindow = application.GetWindow("TwitterFriendsSearcher"); - var label = mainWindow.Get