├── IronTwit
├── .getignore
├── Mockups
│ └── Main UI.png
├── build
│ └── Unite.Setup.msi
├── IronTwit
│ ├── WPF.Themes.dll
│ ├── WPFToolkit.dll
│ ├── UI
│ │ ├── WPF.Themes.dll
│ │ ├── WPFToolkit.dll
│ │ ├── Properties
│ │ │ ├── Settings.settings
│ │ │ ├── Settings.Designer.cs
│ │ │ ├── AssemblyInfo.cs
│ │ │ ├── Resources.Designer.cs
│ │ │ └── Resources.resx
│ │ ├── Utilities
│ │ │ ├── Extensions.cs
│ │ │ ├── UIThreadManager.cs
│ │ │ ├── UiMessage.cs
│ │ │ ├── ContactProvider.cs
│ │ │ ├── InlineUrls.cs
│ │ │ └── GuiInteractionContext.cs
│ │ ├── Controls
│ │ │ ├── MessageView.xaml.cs
│ │ │ ├── MessageView.xaml
│ │ │ └── MessageTextView.cs
│ │ ├── ViewModels
│ │ │ ├── SendMessageCommand.cs
│ │ │ ├── DelegateCommand.cs
│ │ │ ├── UserCredentialsViewModel.cs
│ │ │ └── ReceiveMessagesCommand.cs
│ │ ├── App.xaml.cs
│ │ ├── Themes
│ │ │ └── Generic.xaml
│ │ ├── IoC_Configuration.cs
│ │ ├── Views
│ │ │ ├── UserCredentials.xaml.cs
│ │ │ ├── UserCredentials.xaml
│ │ │ ├── MainView.xaml.cs
│ │ │ └── MainView.xaml
│ │ └── DraggableWindow.cs
│ ├── Messaging
│ │ ├── Services
│ │ │ ├── IPluginFinder.cs
│ │ │ ├── IServiceResolver.cs
│ │ │ ├── ISettingsProvider.cs
│ │ │ ├── MessageReceivedEventArgs.cs
│ │ │ ├── IServiceProvider.cs
│ │ │ ├── ServiceResolver.cs
│ │ │ ├── PluginFinder.cs
│ │ │ ├── ServiceProvider.cs
│ │ │ └── ServicesManager.cs
│ │ ├── Entities
│ │ │ ├── IServiceInformation.cs
│ │ │ ├── IMessage.cs
│ │ │ ├── Credentials.cs
│ │ │ ├── Contact.cs
│ │ │ ├── ServiceInformation.cs
│ │ │ └── Identity.cs
│ │ ├── Prompts
│ │ │ └── IInteractionContext.cs
│ │ ├── Messages
│ │ │ ├── IMessagingServiceManager.cs
│ │ │ ├── IMessagingServiceRegistry.cs
│ │ │ ├── ICredentialCache.cs
│ │ │ ├── MessagingAccount.cs
│ │ │ ├── CredentialEventArgs.cs
│ │ │ └── IMessagingService.cs
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ └── Unite.Messaging.csproj
│ ├── Specs
│ │ ├── New_Starting_Application_Specs
│ │ │ ├── Sending_message.cs
│ │ │ ├── Starting_app_vanilla_with_messages.cs
│ │ │ ├── FakePlugin.cs
│ │ │ ├── When_application_starts_receiving_with_no_valid_credentials.cs
│ │ │ └── ScenarioRepository.cs
│ │ ├── TwitterServicesScope
│ │ │ ├── Formatting_messages_for_twitter.cs
│ │ │ ├── When_sending_large_messages.cs
│ │ │ ├── When_receiving_messages.cs
│ │ │ └── When_sending_normal_messages.cs
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ ├── Application_running
│ │ │ ├── Class1.cs
│ │ │ ├── When_replying_to_a_message.cs
│ │ │ └── Context.cs
│ │ ├── UnitTests
│ │ │ ├── ServiceResolverTests.cs
│ │ │ └── InlineUrlsTests.cs
│ │ ├── Starting_Application
│ │ │ ├── Start_application_receive_message_specs.cs
│ │ │ ├── User_enters_wrong_password_when_prompted.cs
│ │ │ └── Start_application_send_message_spec.cs
│ │ ├── Using_Services
│ │ │ └── When_getting_messages.cs
│ │ ├── Utilities
│ │ │ └── SpecUnit.cs
│ │ ├── Contacts
│ │ │ └── When_receiving_messages_with_known_contacts.cs
│ │ └── Unite.Specs.csproj
│ ├── Plug Ins
│ │ ├── IronTwitterPlugIn
│ │ │ ├── ITwitterDataAccess.cs
│ │ │ ├── DataObjects
│ │ │ │ ├── TwitterUser.cs
│ │ │ │ └── Tweet.cs
│ │ │ ├── TwitterDataAccess.cs
│ │ │ ├── Properties
│ │ │ │ └── AssemblyInfo.cs
│ │ │ └── IronTwitterPlugIn.csproj
│ │ └── GoogleTalkPlugIn
│ │ │ ├── GTalkMessage.cs
│ │ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ │ ├── GoogleTalkDataAccess.cs
│ │ │ ├── GoogleTalkPlugIn.csproj
│ │ │ └── GoogleTalkMessagingService.cs
│ ├── Unite.TestHarness
│ │ ├── Properties
│ │ │ └── AssemblyInfo.cs
│ │ ├── Program.cs
│ │ └── Unite.TestHarness.csproj
│ └── Unite.Setup
│ │ └── Unite.Setup.wixproj
├── ThirdParty
│ ├── IoC
│ │ ├── StructureMap.chm
│ │ ├── StructureMap.dll
│ │ └── StructureMap.AutoMocking.dll
│ ├── Mocking
│ │ └── Rhino.Mocks.dll
│ ├── WPFToolKit
│ │ ├── WPF.Themes.dll
│ │ └── WPFToolkit.dll
│ ├── JabberLibrary
│ │ ├── jabber-net.dll
│ │ ├── netlib.Dns.dll
│ │ └── zlib.net.dll
│ ├── UnitTesting
│ │ ├── nunit.core.dll
│ │ ├── nunit.util.dll
│ │ ├── nunit-console.exe
│ │ ├── nunit.framework.dll
│ │ ├── nunit-console-runner.dll
│ │ ├── nunit.core.interfaces.dll
│ │ ├── nunit.framework.extensions.dll
│ │ └── nunit-console.exe.config
│ ├── TwitterComm
│ │ ├── Yedda.Twitter.dll
│ │ └── Newtonsoft.Json.dll
│ └── WpfBindingHelpers
│ │ └── Bound.Net.dll
├── InstallGems.bat
├── RakeFile
└── BuildUtils.rb
└── .gitignore
/IronTwit/.getignore:
--------------------------------------------------------------------------------
1 | build
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | _ReSharper*
2 | *.resharper*
3 | bin
4 | obj
5 | *.suo
6 | *.zip
7 | *.cache
--------------------------------------------------------------------------------
/IronTwit/Mockups/Main UI.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/Mockups/Main UI.png
--------------------------------------------------------------------------------
/IronTwit/build/Unite.Setup.msi:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/build/Unite.Setup.msi
--------------------------------------------------------------------------------
/IronTwit/IronTwit/WPF.Themes.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/IronTwit/WPF.Themes.dll
--------------------------------------------------------------------------------
/IronTwit/IronTwit/WPFToolkit.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/IronTwit/WPFToolkit.dll
--------------------------------------------------------------------------------
/IronTwit/IronTwit/UI/WPF.Themes.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/IronTwit/UI/WPF.Themes.dll
--------------------------------------------------------------------------------
/IronTwit/IronTwit/UI/WPFToolkit.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/IronTwit/UI/WPFToolkit.dll
--------------------------------------------------------------------------------
/IronTwit/ThirdParty/IoC/StructureMap.chm:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/ThirdParty/IoC/StructureMap.chm
--------------------------------------------------------------------------------
/IronTwit/ThirdParty/IoC/StructureMap.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/ThirdParty/IoC/StructureMap.dll
--------------------------------------------------------------------------------
/IronTwit/ThirdParty/Mocking/Rhino.Mocks.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/ThirdParty/Mocking/Rhino.Mocks.dll
--------------------------------------------------------------------------------
/IronTwit/ThirdParty/WPFToolKit/WPF.Themes.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/ThirdParty/WPFToolKit/WPF.Themes.dll
--------------------------------------------------------------------------------
/IronTwit/ThirdParty/WPFToolKit/WPFToolkit.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/ThirdParty/WPFToolKit/WPFToolkit.dll
--------------------------------------------------------------------------------
/IronTwit/ThirdParty/JabberLibrary/jabber-net.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/ThirdParty/JabberLibrary/jabber-net.dll
--------------------------------------------------------------------------------
/IronTwit/ThirdParty/JabberLibrary/netlib.Dns.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/ThirdParty/JabberLibrary/netlib.Dns.dll
--------------------------------------------------------------------------------
/IronTwit/ThirdParty/JabberLibrary/zlib.net.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/ThirdParty/JabberLibrary/zlib.net.dll
--------------------------------------------------------------------------------
/IronTwit/ThirdParty/UnitTesting/nunit.core.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/ThirdParty/UnitTesting/nunit.core.dll
--------------------------------------------------------------------------------
/IronTwit/ThirdParty/UnitTesting/nunit.util.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/ThirdParty/UnitTesting/nunit.util.dll
--------------------------------------------------------------------------------
/IronTwit/ThirdParty/TwitterComm/Yedda.Twitter.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/ThirdParty/TwitterComm/Yedda.Twitter.dll
--------------------------------------------------------------------------------
/IronTwit/ThirdParty/UnitTesting/nunit-console.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/ThirdParty/UnitTesting/nunit-console.exe
--------------------------------------------------------------------------------
/IronTwit/ThirdParty/IoC/StructureMap.AutoMocking.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/ThirdParty/IoC/StructureMap.AutoMocking.dll
--------------------------------------------------------------------------------
/IronTwit/ThirdParty/TwitterComm/Newtonsoft.Json.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/ThirdParty/TwitterComm/Newtonsoft.Json.dll
--------------------------------------------------------------------------------
/IronTwit/ThirdParty/UnitTesting/nunit.framework.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/ThirdParty/UnitTesting/nunit.framework.dll
--------------------------------------------------------------------------------
/IronTwit/ThirdParty/WpfBindingHelpers/Bound.Net.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/ThirdParty/WpfBindingHelpers/Bound.Net.dll
--------------------------------------------------------------------------------
/IronTwit/ThirdParty/UnitTesting/nunit-console-runner.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/ThirdParty/UnitTesting/nunit-console-runner.dll
--------------------------------------------------------------------------------
/IronTwit/ThirdParty/UnitTesting/nunit.core.interfaces.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/ThirdParty/UnitTesting/nunit.core.interfaces.dll
--------------------------------------------------------------------------------
/IronTwit/ThirdParty/UnitTesting/nunit.framework.extensions.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/jcbozonier/irontwit/master/IronTwit/ThirdParty/UnitTesting/nunit.framework.extensions.dll
--------------------------------------------------------------------------------
/IronTwit/IronTwit/UI/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Messaging/Services/IPluginFinder.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace Unite.Messaging.Services
5 | {
6 | public interface IPluginFinder
7 | {
8 | IEnumerable GetAllPlugins();
9 | }
10 | }
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Messaging/Services/IServiceResolver.cs:
--------------------------------------------------------------------------------
1 | using Unite.Messaging.Entities;
2 |
3 | namespace Unite.Messaging.Services
4 | {
5 | public interface IServiceResolver
6 | {
7 | ServiceInformation GetService(string address);
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Specs/New_Starting_Application_Specs/Sending_message.cs:
--------------------------------------------------------------------------------
1 | using NUnit.Framework;
2 |
3 | namespace Unite.Specs.New_Starting_Application_Specs
4 | {
5 | [TestFixture]
6 | public class When_sending_a_message
7 | {
8 |
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Messaging/Entities/IServiceInformation.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Unite.Messaging.Entities
4 | {
5 | public interface IServiceInformation
6 | {
7 | string ServiceName { get; }
8 | Guid ServiceID { get; }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Messaging/Entities/IMessage.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Unite.Messaging.Entities
4 | {
5 | public interface IMessage
6 | {
7 | string Text { get; set; }
8 | IIdentity Address { get; set; }
9 | DateTime TimeStamp { get; set; }
10 | }
11 | }
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Messaging/Prompts/IInteractionContext.cs:
--------------------------------------------------------------------------------
1 | using Unite.Messaging.Entities;
2 |
3 | namespace Unite.Messaging
4 | {
5 | public interface IInteractionContext
6 | {
7 | Credentials GetCredentials(IServiceInformation serviceInformation);
8 | bool AuthenticationFailedRetryQuery();
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Messaging/Services/ISettingsProvider.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Unite.Messaging.Services
7 | {
8 | public interface ISettingsProvider
9 | {
10 | IEnumerable GetStoredCredentials();
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Messaging/Messages/IMessagingServiceManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Unite.Messaging.Messages;
6 |
7 | namespace Unite.Messaging
8 | {
9 | public interface IMessagingServiceManager : IMessagingService
10 | {
11 | void SendMessage(string recipient, string message);
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Messaging/Messages/IMessagingServiceRegistry.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 |
4 | namespace Unite.Messaging.Messages
5 | {
6 | public interface IMessagingServiceRegistry
7 | {
8 | List RegisteredServices { get; }
9 |
10 | void Register(IMessagingService service);
11 |
12 | IMessagingService Get(Guid id);
13 | }
14 | }
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Messaging/Messages/ICredentialCache.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Unite.Messaging.Messages
4 | {
5 | public interface ICredentialCache
6 | {
7 | void Add(Guid serviceId, Credentials credentials);
8 | void Clear(Guid serviceId, string userName);
9 | bool Contains(Guid serviceId, string userName);
10 | void Clear(Guid serviceId);
11 | void ClearAll();
12 | }
13 | }
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Messaging/Messages/MessagingAccount.cs:
--------------------------------------------------------------------------------
1 | namespace Unite.Messaging.Messages
2 | {
3 | public struct MessagingAccount
4 | {
5 | public MessagingAccount(IMessagingService service, Credentials credentials)
6 | {
7 | Service = service;
8 | Credentials = credentials;
9 | }
10 |
11 | public IMessagingService Service;
12 | public Credentials Credentials;
13 | }
14 | }
--------------------------------------------------------------------------------
/IronTwit/InstallGems.bat:
--------------------------------------------------------------------------------
1 | @ECHO *** Installing Rake
2 | @call gem install rake --include-dependencies
3 |
4 | @ECHO *** Installing ActiveRecord
5 | @call gem install activerecord --include-dependencies
6 |
7 | @ECHO *** Installing RubyZip
8 | @call gem install rubyzip --include-dependencies
9 |
10 | @ECHO *** Installing Rails
11 | @call gem install rails --include-dependencies
12 |
13 | @ECHO *** Installing Guid
14 | @call gem install guid --include-dependencies
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Messaging/Entities/Credentials.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Unite.Messaging.Entities;
6 |
7 | namespace Unite.Messaging
8 | {
9 | public class Credentials
10 | {
11 | public string UserName { get; set; }
12 | public string Password { get; set; }
13 | public IServiceInformation ServiceInformation { get; set; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Messaging/Entities/Contact.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Unite.Messaging
7 | {
8 | public class Contact
9 | {
10 | public Guid ContactId
11 | {
12 | get; set;
13 | }
14 |
15 | public IEnumerable Identities
16 | {
17 | get; set;
18 | }
19 |
20 | public string Name
21 | {
22 | get; set;
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Plug Ins/IronTwitterPlugIn/ITwitterDataAccess.cs:
--------------------------------------------------------------------------------
1 | using Unite.Messaging;
2 |
3 | namespace IronTwitterPlugIn
4 | {
5 | public interface ITwitterDataAccess
6 | {
7 | ///
8 | /// Returns a status in JSON.
9 | ///
10 | ///
11 | ///
12 | ///
13 | string SendMessage(Credentials credentials, string message);
14 | string GetMessages(Credentials credentials);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Messaging/Services/MessageReceivedEventArgs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Unite.Messaging.Entities;
6 |
7 | namespace Unite.Messaging.Services
8 | {
9 | public class MessagesReceivedEventArgs : EventArgs
10 | {
11 | public MessagesReceivedEventArgs(IEnumerable messages)
12 | {
13 | Messages = messages;
14 | }
15 |
16 | public IEnumerable Messages
17 | {
18 | get; set;
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/UI/Utilities/Extensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Unite.UI.Utilities
7 | {
8 | public static class Unit3Extensions
9 | {
10 | public static IEnumerable Convert(this IEnumerable items, Func converter)
11 | {
12 | var result = new List();
13 |
14 | foreach(var item in items)
15 | {
16 | result.Add(converter(item));
17 | }
18 |
19 | return result;
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Messaging/Services/IServiceProvider.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Unite.Messaging.Entities;
4 | using Unite.Messaging.Messages;
5 |
6 | namespace Unite.Messaging.Services
7 | {
8 | public interface IServiceProvider
9 | {
10 | void Add(params IMessagingService[] services);
11 | IEnumerable GetServices();
12 | event EventHandler CredentialsRequested;
13 | event EventHandler AuthorizationFailed;
14 | IMessagingService GetService(ServiceInformation info);
15 | }
16 | }
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Plug Ins/IronTwitterPlugIn/DataObjects/TwitterUser.cs:
--------------------------------------------------------------------------------
1 | using Unite.Messaging;
2 | using Unite.Messaging.Entities;
3 |
4 | namespace IronTwitterPlugIn.DataObjects
5 | {
6 | public class TwitterUser : IIdentity
7 | {
8 | ///
9 | /// for de/serialization only (alias to UserName)
10 | ///
11 | public string screen_name
12 | {
13 | get { return UserName; }
14 | set { UserName = value; }
15 | }
16 |
17 | public string UserName { get; set; }
18 | public ServiceInformation ServiceInfo
19 | {
20 | get; set;
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/IronTwit/IronTwit/UI/Controls/MessageView.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows;
6 | using System.Windows.Controls;
7 | using System.Windows.Data;
8 | using System.Windows.Documents;
9 | using System.Windows.Input;
10 | using System.Windows.Media;
11 | using System.Windows.Media.Imaging;
12 | using System.Windows.Navigation;
13 | using System.Windows.Shapes;
14 |
15 | namespace Unite.UI.Controls
16 | {
17 | public partial class MessageView : UserControl
18 | {
19 | public MessageView()
20 | {
21 | InitializeComponent();
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/UI/Utilities/UIThreadManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading;
6 | using System.Windows.Threading;
7 |
8 | namespace Unite.UI.Utilities
9 | {
10 | public class UIThreadManager
11 | {
12 | private Thread _Thread;
13 |
14 | public UIThreadManager(Thread thread)
15 | {
16 | _Thread = thread;
17 | }
18 |
19 | public void Execute(Action action)
20 | {
21 | var dispatcher = Dispatcher.FromThread(_Thread);
22 | dispatcher.Invoke(DispatcherPriority.Normal, action);
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Messaging/Messages/CredentialEventArgs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Unite.Messaging.Entities;
3 |
4 | namespace Unite.Messaging.Messages
5 | {
6 | public class CredentialEventArgs : EventArgs
7 | {
8 | public ServiceInformation ServiceInfo;
9 |
10 | public bool Equals(CredentialEventArgs obj)
11 | {
12 | if (ReferenceEquals(null, obj)) return false;
13 | if (ReferenceEquals(this, obj)) return true;
14 | return Equals(obj.ServiceInfo, ServiceInfo);
15 | }
16 |
17 | public override int GetHashCode()
18 | {
19 | return (ServiceInfo != null ? ServiceInfo.GetHashCode() : 0);
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Specs/TwitterServicesScope/Formatting_messages_for_twitter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Unite.UI.Utilities;
6 | using NUnit.Framework;
7 | using SpecUnit;
8 |
9 | namespace Unite.Specs.UnitTests
10 | {
11 | [TestFixture]
12 | public class Formatting_messages_for_twitter
13 | {
14 | [Test]
15 | public void TestOne()
16 | {
17 | var finalMessage = "@darkxanthos This";
18 | //var result = TwitterUtilities._GetMessageToSend(finalMessage.Length, "This is my message.");
19 |
20 | //result.ShouldEqual(finalMessage);
21 | }
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/UI/ViewModels/SendMessageCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Input;
3 | using Unite.UI.Utilities;
4 | using StructureMap;
5 |
6 | namespace Unite.UI.ViewModels
7 | {
8 | public class SendMessageCommand : ICommand
9 | {
10 | private Action _OnSendMessage;
11 |
12 | public SendMessageCommand(Action onSendMessage)
13 | {
14 | _OnSendMessage = onSendMessage;
15 | }
16 |
17 | public event EventHandler CanExecuteChanged;
18 | public void Execute(object parameter)
19 | {
20 | if (_OnSendMessage != null)
21 | _OnSendMessage();
22 | }
23 |
24 | public bool CanExecute(object parameter)
25 | {
26 | return true;
27 | }
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Messaging/Services/ServiceResolver.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Unite.Messaging.Entities;
3 | using Unite.Messaging.Messages;
4 |
5 | namespace Unite.Messaging.Services
6 | {
7 | public class ServiceResolver : IServiceResolver
8 | {
9 | public ServiceResolver(IServiceProvider provider)
10 | {
11 | _Services = provider.GetServices();
12 | }
13 |
14 | private readonly IEnumerable _Services;
15 |
16 | public ServiceInformation GetService(string address)
17 | {
18 | foreach(var service in _Services)
19 | {
20 | if (service.CanFind(address))
21 | return service.GetInformation();
22 | }
23 |
24 | return null;
25 | }
26 | }
27 | }
--------------------------------------------------------------------------------
/IronTwit/IronTwit/UI/App.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Collections.ObjectModel;
4 | using System.Configuration;
5 | using System.Data;
6 | using System.Linq;
7 | using System.Windows;
8 | using Unite.UI.ViewModels;
9 | using StructureMap;
10 |
11 | namespace Unite.UI
12 | {
13 | ///
14 | /// Interaction logic for App.xaml
15 | ///
16 | public partial class App : Application
17 | {
18 | public App()
19 | {
20 | Startup += App_Startup;
21 | }
22 |
23 | void App_Startup(object sender, StartupEventArgs e)
24 | {
25 | ContainerBootstrapper.BootstrapStructureMap();
26 |
27 | var view = ObjectFactory.GetInstance();
28 | view.Show();
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Messaging/Messages/IMessagingService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Unite.Messaging.Entities;
4 | using Unite.Messaging.Services;
5 |
6 | namespace Unite.Messaging.Messages
7 | {
8 | public interface IMessagingService
9 | {
10 | bool CanAccept(Credentials credentials);
11 | List GetMessages();
12 | void SendMessage(IIdentity recipient, string message);
13 | void SetCredentials(Credentials credentials);
14 | event EventHandler CredentialsRequested;
15 | event EventHandler AuthorizationFailed;
16 | bool CanFind(string address);
17 | ServiceInformation GetInformation();
18 | void StartReceiving();
19 | void StopReceiving();
20 | event EventHandler MessagesReceived;
21 | }
22 | }
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Plug Ins/GoogleTalkPlugIn/GTalkMessage.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Unite.Messaging;
6 | using Unite.Messaging.Entities;
7 |
8 | namespace GoogleTalkPlugIn
9 | {
10 | internal class GTalkMessage : IMessage
11 | {
12 | public string Text
13 | {
14 | get; set;
15 | }
16 |
17 | public IIdentity Address
18 | {
19 | get; set;
20 | }
21 |
22 | public DateTime TimeStamp
23 | {
24 | get; set;
25 | }
26 | }
27 |
28 | internal class GTalkUser : IIdentity
29 | {
30 | public string UserName
31 | {
32 | get; set;
33 | }
34 |
35 | public ServiceInformation ServiceInfo
36 | {
37 | get; set;
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/UI/Utilities/UiMessage.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Unite.Messaging;
6 | using Unite.Messaging.Entities;
7 |
8 | namespace Unite.UI.Utilities
9 | {
10 | public class UiMessage : IMessage
11 | {
12 | public UiMessage(IMessage message, Contact contact)
13 | {
14 | Address = message.Address;
15 | Text = message.Text;
16 | TimeStamp = message.TimeStamp;
17 | Contact = contact;
18 | }
19 |
20 | public string Text
21 | {
22 | get; set;
23 | }
24 |
25 | public IIdentity Address
26 | {
27 | get; set;
28 | }
29 |
30 | public DateTime TimeStamp
31 | {
32 | get; set;
33 | }
34 |
35 | public Contact Contact
36 | {
37 | get; set;
38 | }
39 | }
40 | }
--------------------------------------------------------------------------------
/IronTwit/IronTwit/UI/Themes/Generic.xaml:
--------------------------------------------------------------------------------
1 |
5 |
6 |
19 |
20 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/UI/Controls/MessageView.xaml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Plug Ins/IronTwitterPlugIn/TwitterDataAccess.cs:
--------------------------------------------------------------------------------
1 | using Unite.Messaging;
2 | using Yedda;
3 |
4 | namespace IronTwitterPlugIn
5 | {
6 | public class TwitterDataAccess : ITwitterDataAccess
7 | {
8 | public string SendMessage(Credentials credentials, string message)
9 | {
10 | var twit = new Twitter();
11 | twit.TwitterClient = "Unite";
12 | twit.TwitterClientUrl = "http://github.com/jcbozonier/irontwit/tree/master";
13 | twit.TwitterClientVersion = "0.1";
14 |
15 | var result = twit.UpdateAsJSON(credentials.UserName, credentials.Password, message);
16 | return result;
17 | }
18 |
19 | public string GetMessages(Credentials credentials)
20 | {
21 | var twit = new Twitter();
22 | twit.TwitterClient = "Unite";
23 | twit.TwitterClientUrl = "http://github.com/jcbozonier/irontwit/tree/master";
24 | twit.TwitterClientVersion = "0.1";
25 |
26 | var result = twit.GetFriendsTimelineAsJSON(credentials.UserName, credentials.Password);
27 | return result;
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Plug Ins/IronTwitterPlugIn/DataObjects/Tweet.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Unite.Messaging;
3 | using Unite.Messaging.Entities;
4 |
5 | namespace IronTwitterPlugIn.DataObjects
6 | {
7 | public class Tweet : IMessage
8 | {
9 | ///
10 | /// for de/serialization only (alias to Text)
11 | ///
12 | public string text
13 | {
14 | get { return Text; }
15 | set { Text = value; }
16 | }
17 |
18 | public string Text { get; set; }
19 |
20 | ///
21 | /// for de/serialization only (alias to Sender)
22 | ///
23 | public TwitterUser user
24 | {
25 | get { return (TwitterUser)Address; }
26 | set
27 | {
28 | if (!value.UserName.StartsWith("@"))
29 | value.UserName = "@" + value.UserName;
30 | Address = value;
31 | }
32 | }
33 | public int id { get; set; }
34 |
35 | public IIdentity Address { get; set; }
36 | public DateTime TimeStamp
37 | {
38 | get; set;
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/IronTwit/IronTwit/UI/IoC_Configuration.cs:
--------------------------------------------------------------------------------
1 | using System.Threading;
2 | using Unite.Messaging.Services;
3 | using Unite.UI.Utilities;
4 | using StructureMap;
5 | using Unite.Messaging;
6 |
7 | namespace Unite.UI
8 | {
9 | public static class ContainerBootstrapper
10 | {
11 | public static void BootstrapStructureMap()
12 | {
13 | // Initialize the static ObjectFactory container
14 | ObjectFactory.Initialize(x =>
15 | {
16 | x.ForRequestedType().TheDefaultIsConcreteType();
17 | x.ForRequestedType().TheDefault.IsThis(
18 | new GuiInteractionContext(Thread.CurrentThread));
19 | x.ForRequestedType().TheDefaultIsConcreteType();
20 | x.ForRequestedType().TheDefaultIsConcreteType();
21 | x.ForRequestedType().TheDefaultIsConcreteType();
22 | x.ForRequestedType().TheDefaultIsConcreteType();
23 | });
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/UI/ViewModels/DelegateCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows.Input;
6 |
7 | namespace Unite.UI.ViewModels
8 | {
9 | public class Do : ICommand
10 | {
11 | private Action _Action;
12 | private Predicate _Pred;
13 |
14 | public Do(Action action)
15 | {
16 | _Action = action;
17 | }
18 |
19 | public void If(Predicate pred)
20 | {
21 | _Pred = pred;
22 | }
23 |
24 | public event EventHandler CanExecuteChanged;
25 |
26 | public void Execute(object parameter)
27 | {
28 | if(!(parameter is T))
29 | throw new ArgumentException("parameter doesn't match the type.");
30 | _Action((T) parameter);
31 | }
32 |
33 | public bool CanExecute(object parameter)
34 | {
35 | if(_Pred == null)
36 | throw new NullReferenceException("You must provide a predicate to tell when an action can be carried out.");
37 | return _Pred((T) parameter);
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/UI/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:2.0.50727.1434
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace Unite.UI.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/UI/Views/UserCredentials.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows;
6 | using System.Windows.Controls;
7 | using System.Windows.Data;
8 | using System.Windows.Documents;
9 | using System.Windows.Input;
10 | using System.Windows.Media;
11 | using System.Windows.Media.Imaging;
12 | using System.Windows.Shapes;
13 | using Unite.UI.ViewModels;
14 |
15 | namespace Unite.UI.Views
16 | {
17 | ///
18 | /// Interaction logic for UserCredentials.xaml
19 | ///
20 | public partial class UserCredentialsWindow : DraggableWindow
21 | {
22 | public UserCredentialsWindow()
23 | {
24 | InitializeComponent();
25 | }
26 |
27 | private void Password_PasswordChanged(object sender, RoutedEventArgs e)
28 | {
29 | ((UserCredentialsViewModel) DataContext).Password = Password.Password;
30 | }
31 |
32 | private void Ok_Click(object sender, RoutedEventArgs e)
33 | {
34 | DialogResult = true;
35 | }
36 |
37 | private void Cancel_Click(object sender, RoutedEventArgs e)
38 | {
39 | DialogResult = false;
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/UI/ViewModels/UserCredentialsViewModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows;
6 |
7 | namespace Unite.UI.ViewModels
8 | {
9 | public class UserCredentialsViewModel : DependencyObject
10 | {
11 | public static DependencyProperty UserNameProperty = DependencyProperty
12 | .Register("UserName", typeof (string), typeof (UserCredentialsViewModel));
13 | public string UserName
14 | {
15 | get
16 | {
17 | return (string)GetValue(UserNameProperty);
18 | }
19 | set
20 | {
21 | SetValue(UserNameProperty, value);
22 | }
23 | }
24 |
25 | public static DependencyProperty PasswordProperty = DependencyProperty
26 | .Register("Password", typeof(string), typeof(UserCredentialsViewModel));
27 | public string Password
28 | {
29 | get
30 | {
31 | return (string)GetValue(PasswordProperty);
32 | }
33 | set
34 | {
35 | SetValue(PasswordProperty, value);
36 | }
37 | }
38 |
39 | public string Caption { get; set; }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/UI/ViewModels/ReceiveMessagesCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Windows.Input;
4 | using System.Net;
5 |
6 | namespace Unite.UI.ViewModels
7 | {
8 | public class ReceiveMessagesCommand : ICommand
9 | {
10 | private Action _OnExecute;
11 |
12 | public ReceiveMessagesCommand(Action onExecute)
13 | {
14 | _OnExecute = onExecute;
15 | }
16 |
17 | public event EventHandler CanExecuteChanged;
18 |
19 | public void Execute(object parameter, Action webExceptionHandler)
20 | {
21 | if (_OnExecute != null)
22 | {
23 | try
24 | {
25 | _OnExecute();
26 | }
27 | catch (WebException exception)
28 | {
29 | if (webExceptionHandler != null)
30 | webExceptionHandler(exception);
31 | else
32 | throw;
33 | }
34 | }
35 | }
36 |
37 | public void Execute(object parameter)
38 | {
39 | Execute(parameter, null);
40 | }
41 |
42 | public bool CanExecute(object parameter)
43 | {
44 | return true;
45 | }
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/UI/Utilities/ContactProvider.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Unite.Messaging;
6 |
7 | namespace Unite.UI.Utilities
8 | {
9 | public interface IContactProvider
10 | {
11 | Contact Get(IIdentity identity);
12 | void Add(Contact contact);
13 | }
14 |
15 | public class ContactProvider : IContactProvider
16 | {
17 | private List Contacts;
18 |
19 | public ContactProvider()
20 | {
21 | Contacts = new List();
22 | }
23 |
24 | public Contact Get(IIdentity identity)
25 | {
26 | foreach(var contact in Contacts)
27 | {
28 | foreach(var contactIdentity in contact.Identities)
29 | {
30 | if(contactIdentity.Equals(identity)) return contact;
31 | }
32 | }
33 |
34 | return new Contact()
35 | {
36 | Identities = new[] {identity},
37 | Name = identity.UserName
38 | };
39 | }
40 |
41 | public void Add(Contact contact)
42 | {
43 | Contacts.Add(contact);
44 | }
45 |
46 | public void Clear()
47 | {
48 | Contacts.Clear();
49 | }
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Specs/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Unite.Specs")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Unite.Specs")]
13 | [assembly: AssemblyCopyright("Copyright © 2009")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("f4c2aebd-c320-4d1c-b246-2220348c2d3a")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Messaging/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Unite.Messaging")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Unite.Messaging")]
13 | [assembly: AssemblyCopyright("Copyright © 2009")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("aad6cc69-9201-48b4-8958-a5b129c9afd6")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Unite.TestHarness/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Unite.TestHarness")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Unite.TestHarness")]
13 | [assembly: AssemblyCopyright("Copyright © 2009")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("751cbebd-12c7-4e49-8044-1ae780e99f2d")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Plug Ins/GoogleTalkPlugIn/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("GoogleTalkPlugIn")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("GoogleTalkPlugIn")]
13 | [assembly: AssemblyCopyright("Copyright © 2009")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("cebbd923-77df-4612-8643-101d463eb260")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Plug Ins/IronTwitterPlugIn/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("IronTwitterPlugIn")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("IronTwitterPlugIn")]
13 | [assembly: AssemblyCopyright("Copyright © 2009")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("692c986e-f34a-4ec7-b40f-7ad19a1f03b9")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Specs/New_Starting_Application_Specs/Starting_app_vanilla_with_messages.cs:
--------------------------------------------------------------------------------
1 | using System.Linq;
2 | using NUnit.Framework;
3 | using Rhino.Mocks;
4 | using Rhino.Mocks.Constraints;
5 | using SpecUnit;
6 | using StructureMap;
7 | using Unite.Messaging;
8 | using Unite.Messaging.Messages;
9 | using Unite.UI.ViewModels;
10 |
11 | namespace Unite.Specs.New_Starting_Application_Specs
12 | {
13 | [TestFixture]
14 | public class When_application_starts : no_cached_credentials_no_settings
15 | {
16 | protected override void Context()
17 | {
18 | FakeRepo.FakePluginFinder
19 | .Stub(x => x.GetAllPlugins())
20 | .Return(new[] { typeof(IMessagingService) });
21 |
22 | ViewModel = FakeRepo.GetMainView();
23 | }
24 |
25 | protected override void Because()
26 | {
27 | ViewModel.Init();
28 | }
29 |
30 | [Test]
31 | public void It_should_start_receiving_messages()
32 | {
33 | FakeRepo.FakeMessagePlugin.AssertWasCalled(x => x.StartReceiving());
34 | }
35 | }
36 |
37 | public abstract class no_cached_credentials_no_settings
38 | {
39 | protected MainView ViewModel;
40 | protected ScenarioRepository FakeRepo;
41 |
42 | [TestFixtureSetUp]
43 | public void Setup()
44 | {
45 | FakeRepo = new ScenarioRepository();
46 |
47 | Context();
48 | Because();
49 | }
50 |
51 | protected abstract void Because();
52 |
53 | protected abstract void Context();
54 | }
55 | }
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Messaging/Entities/ServiceInformation.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace Unite.Messaging.Entities
4 | {
5 | public class ServiceInformation : IServiceInformation
6 | {
7 | public string ServiceName
8 | {
9 | get; set;
10 | }
11 |
12 | public Guid ServiceID
13 | {
14 | get; set;
15 | }
16 |
17 | public override bool Equals(object obj)
18 | {
19 | return AreEqual(this, obj);
20 | }
21 |
22 | public bool Equals(ServiceInformation obj)
23 | {
24 | return AreEqual(this, obj);
25 | }
26 |
27 | public static bool AreEqual(object a, object b)
28 | {
29 | if (ReferenceEquals(null, a) || ReferenceEquals(null, b)) return false;
30 | if (ReferenceEquals(a, b)) return true;
31 | if (!(a is IServiceInformation) || !(b is IServiceInformation)) return false;
32 | return AreEqual((IServiceInformation) a, (IServiceInformation) b);
33 | }
34 |
35 | public static bool AreEqual(IServiceInformation a, IServiceInformation b)
36 | {
37 | if (ReferenceEquals(null, a) || ReferenceEquals(null, b)) return false;
38 | if (ReferenceEquals(a, b)) return true;
39 | return Equals(a.ServiceName, b.ServiceName) && a.ServiceID.Equals(b.ServiceID);
40 | }
41 |
42 | public override int GetHashCode()
43 | {
44 | unchecked
45 | {
46 | return ((ServiceName != null ? ServiceID.GetHashCode() : 0) * 397) ^ ServiceID.GetHashCode();
47 | }
48 | }
49 | }
50 | }
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Specs/New_Starting_Application_Specs/FakePlugin.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using Unite.Messaging;
5 | using Unite.Messaging.Entities;
6 | using Unite.Messaging.Messages;
7 | using Unite.Messaging.Services;
8 |
9 | namespace Unite.Specs.New_Starting_Application_Specs
10 | {
11 | public class FakePlugin : IMessagingService
12 | {
13 | public event EventHandler AuthorizationFailed;
14 | public virtual event EventHandler CredentialsRequested;
15 | public event EventHandler MessagesReceived;
16 |
17 | public virtual bool CanAccept(Credentials credentials)
18 | {
19 | return true;
20 | }
21 |
22 | public virtual List GetMessages()
23 | {
24 | return new List();
25 | }
26 |
27 | public virtual void SendMessage(IIdentity recipient, string message)
28 | {
29 |
30 | }
31 |
32 | public virtual void SetCredentials(Credentials credentials)
33 | {
34 |
35 | }
36 |
37 | public virtual bool CanFind(string address)
38 | {
39 | return true;
40 | }
41 |
42 | public virtual ServiceInformation GetInformation()
43 | {
44 | return new ServiceInformation(){ServiceID = Guid.NewGuid(), ServiceName = "Fake"};
45 | }
46 |
47 | public virtual void StartReceiving()
48 | {
49 |
50 | }
51 |
52 | public virtual void StopReceiving()
53 | {
54 |
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/UI/Utilities/InlineUrls.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Text.RegularExpressions;
6 |
7 | namespace Unite.UI.Utilities
8 | {
9 | public static class InlineUris
10 | {
11 | //http://www.regexguru.com/2008/11/detecting-urls-in-a-block-of-text/
12 | private const string URI_REGEX =
13 | @"\b(?:(?:https?|ftp|file)://|www\.|ftp\.)"
14 | + @"(?:\([-A-Z0-9+&@#/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#/%=~_|$?!:,.])*"
15 | + @"(?:\([-A-Z0-9+&@#/%=~_|$?!:,.]*\)|[A-Z0-9+&@#/%=~_|$])";// (free-spacing, case insensitive)
16 |
17 | private static Regex _regex = new Regex(URI_REGEX, RegexOptions.IgnoreCase);
18 |
19 | public static List Get(string text)
20 | {
21 | var uris = new List();
22 |
23 | if (string.IsNullOrEmpty(text))
24 | return uris;
25 |
26 | Match match;
27 | int index = 0;
28 | while (true)
29 | {
30 | match = _regex.Match(text, index);
31 | if (match == Match.Empty)
32 | break;
33 |
34 | uris.Add(new InlineUri(text.Substring(match.Index, match.Length), match.Index, match.Length));
35 | index = match.Index + match.Length;
36 | };
37 |
38 | return uris;
39 | }
40 | }
41 |
42 | public class InlineUri : Uri
43 | {
44 | public int StartIndex { get; private set; }
45 | public int Length { get; private set; }
46 |
47 | public InlineUri(string uriString, int startIndex, int length) : base(uriString)
48 | {
49 | StartIndex = startIndex;
50 | Length = length;
51 | }
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Specs/Application_running/Class1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using NUnit.Framework;
3 | using SpecUnit;
4 | using StructureMap;
5 | using Unite.Messaging.Messages;
6 | using Unite.UI.ViewModels;
7 |
8 | namespace Unite.Specs.Application_running.Managing_Plugins
9 | {
10 | [TestFixture]
11 | public class When_a_message_is_received_while_messages_already_exist : context
12 | {
13 | [Test]
14 | public void It_should_increase_the_number_of_viewable_messages_by_one()
15 | {
16 | Model.Messages.Count.ShouldEqual(2);
17 | }
18 |
19 | [Test]
20 | public void It_should_place_the_most_recent_message_at_the_top_of_the_list()
21 | {
22 | Model.Messages[0].TimeStamp.CompareTo(Model.Messages[1].TimeStamp).ShouldEqual(1);
23 | }
24 |
25 | protected override void Context()
26 | {
27 | Model = ObjectFactory.GetInstance();
28 | Model.Init();
29 |
30 | Model.Messages.Count.ShouldEqual(1);
31 | }
32 |
33 | protected override void Because()
34 | {
35 | Model.ReceiveMessage.Execute(null);
36 | }
37 |
38 | }
39 |
40 | public abstract class context
41 | {
42 | protected MainView Model;
43 | protected TestTwitterUtilities Utilities;
44 |
45 |
46 | [TestFixtureSetUp]
47 | public void Setup()
48 | {
49 | ContainerBootstrapper.BootstrapStructureMap();
50 |
51 | Utilities = new TestTwitterUtilities();
52 | ObjectFactory.EjectAllInstancesOf();
53 | ObjectFactory.Inject(Utilities);
54 |
55 | Context();
56 | Because();
57 | }
58 |
59 | protected abstract void Because();
60 |
61 | protected abstract void Context();
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Unite.Setup/Unite.Setup.wixproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | Debug
4 | x86
5 | 3.0
6 | {8092133e-60b2-4e7f-9575-5d7cd52fbf11}
7 | 2.0
8 | Unite.Setup
9 | Package
10 | $(MSBuildExtensionsPath)\Microsoft\WiX\v3.0\Wix.targets
11 |
12 |
13 | bin\$(Configuration)\
14 | obj\$(Configuration)\
15 | Debug
16 |
17 |
18 | bin\$(Configuration)\
19 | obj\$(Configuration)\
20 |
21 |
22 |
23 |
24 |
25 |
26 | Unite.UI
27 | {df1a7919-466c-4321-bfef-c3aab6bf4841}
28 | True
29 |
30 |
31 |
32 |
33 | $(WixExtDir)\WixUIExtension.dll
34 |
35 |
36 |
37 |
45 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Messaging/Services/PluginFinder.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Reflection;
5 | using Unite.Messaging.Messages;
6 |
7 | namespace Unite.Messaging.Services
8 | {
9 | public class PluginFinder : IPluginFinder
10 | {
11 | public IEnumerable GetAllPlugins()
12 | {
13 | var mainExeDir = Environment.CurrentDirectory;
14 | var pluginDir = new DirectoryInfo(mainExeDir);
15 | var thisAssembly = Assembly.GetExecutingAssembly();
16 | var entryAssembly = Assembly.GetEntryAssembly();
17 |
18 | var result = new List();
19 |
20 | if (entryAssembly == null) return new List();
21 |
22 | foreach (var fileInfo in pluginDir.GetFiles("*.dll", SearchOption.TopDirectoryOnly))
23 | {
24 | if (string.Compare(fileInfo.FullName, thisAssembly.Location, true) == 0)
25 | continue;
26 | if (string.Compare(fileInfo.FullName, entryAssembly.Location, true) == 0)
27 | continue;
28 | try
29 | {
30 | var assembly = Assembly.LoadFrom(fileInfo.FullName);
31 | foreach (var type in assembly.GetTypes())
32 | {
33 | var found = false;
34 | foreach (var interfaceType in type.GetInterfaces())
35 | {
36 | if (interfaceType == typeof(IMessagingService))
37 | {
38 | result.Add(type);
39 | found = true;
40 | break;
41 | }
42 | }
43 | if (found)
44 | break;
45 | }
46 | }
47 | catch (Exception)
48 | { }
49 | }
50 |
51 | return result;
52 | }
53 | }
54 | }
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Messaging/Entities/Identity.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Unite.Messaging.Entities;
6 |
7 | namespace Unite.Messaging
8 | {
9 | //Service specific (i.e. not a "Contact" which is a semantic grouping of IIdentities under one friendly name)
10 | //Service specific "contacts" are called Identities because that is the actual identity for the system
11 | //General identities are call contacts because they represent a single person to contact.
12 | public interface IIdentity
13 | {
14 | ///
15 | /// For Twitter, e.g. '@darkxanthos'
16 | /// For Email, e.g. 'darkxanthos@gmail.com'
17 | ///
18 | string UserName { get; }
19 | ServiceInformation ServiceInfo { get; }
20 | }
21 |
22 | public class Identity : IIdentity
23 | {
24 | public Identity(string userName, ServiceInformation serviceInformation)
25 | {
26 | UserName = userName;
27 | ServiceInfo = serviceInformation;
28 | }
29 |
30 | public string UserName { get; private set; }
31 |
32 | public ServiceInformation ServiceInfo { get; private set; }
33 |
34 | public override bool Equals(object obj)
35 | {
36 | if (ReferenceEquals(null, obj)) return false;
37 | if (ReferenceEquals(this, obj)) return true;
38 | if (obj.GetType() != typeof(Identity)) return false;
39 | return Equals((Identity)obj);
40 | }
41 |
42 | public bool Equals(Identity obj)
43 | {
44 | if (ReferenceEquals(null, obj)) return false;
45 | if (ReferenceEquals(this, obj)) return true;
46 | return Equals(obj.UserName, UserName) && Equals(obj.ServiceInfo, ServiceInfo);
47 | }
48 |
49 | public override int GetHashCode()
50 | {
51 | unchecked
52 | {
53 | return (UserName.GetHashCode() * 397) ^ ServiceInfo.GetHashCode();
54 | }
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/UI/DraggableWindow.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows;
3 | using System.Windows.Input;
4 |
5 | namespace Unite.UI
6 | {
7 | public class DraggableWindow : Window
8 | {
9 | private Point? _mouseDownPoint;
10 | private bool _dragging;
11 |
12 | protected Point _resizeMouseDownPoint;
13 | protected Size _mouseDownSize;
14 | protected bool _resizing;
15 |
16 | protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
17 | {
18 | Console.WriteLine("DraggableWindow.OnMouseLeftButtonDown");
19 | _mouseDownPoint = e.MouseDevice.GetPosition(null);
20 |
21 | base.OnMouseLeftButtonDown(e);
22 | }
23 |
24 | protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
25 | {
26 | _mouseDownPoint = null;
27 |
28 | if (_dragging)
29 | {
30 | _dragging = false;
31 | ReleaseMouseCapture();
32 | }
33 |
34 | base.OnMouseLeftButtonUp(e);
35 | }
36 |
37 | protected override void OnMouseMove(MouseEventArgs e)
38 | {
39 | if (e.LeftButton != MouseButtonState.Pressed || _mouseDownPoint == null || _resizing)
40 | {
41 | base.OnMouseMove(e);
42 | return;
43 | }
44 |
45 | var currentPosition = e.MouseDevice.GetPosition(null);
46 | var moveVector = Point.Subtract(currentPosition, (Point)_mouseDownPoint);
47 |
48 | if (_dragging)
49 | {
50 | DragWindow(e, moveVector);
51 | return;
52 | }
53 |
54 | if (moveVector.Length >= 3) //this is a drag
55 | {
56 | _dragging = true;
57 | CaptureMouse();
58 | return;
59 | }
60 |
61 | base.OnMouseMove(e);
62 | }
63 |
64 | private void DragWindow(MouseEventArgs e, Vector dragVector)
65 | {
66 | var newPosition = PointToScreen(new Point(dragVector.X, dragVector.Y));
67 |
68 | Left = newPosition.X;
69 | Top = newPosition.Y;
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Unite.TestHarness/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading;
7 | using jabber.client;
8 |
9 | namespace Unite.TestHarness
10 | {
11 | class Program
12 | {
13 | private static ManualResetEvent done = new ManualResetEvent(false);
14 | static void Main(string[] args)
15 | {
16 | var client = new JabberClient();
17 |
18 | client.AutoPresence = false;
19 | client.AutoRoster = false;
20 | client.AutoReconnect = -1;
21 |
22 | client.User = "herbstudent";
23 | client.Password = "samhain8";
24 | client.Server = "gmail.com";
25 | client.Port = 5222;
26 | client.Resource = "Pidgin";
27 |
28 | client.OnMessage += (s, e) =>
29 | {
30 | Console.WriteLine("Message sent...");
31 | };
32 |
33 | client.OnAuthError += (s, e) =>
34 | {
35 | Console.WriteLine("Auth Error: " + e.InnerText);
36 | client.Close();
37 | };
38 |
39 | client.OnAuthenticate += s =>
40 | {
41 | Console.WriteLine("Authenticated...");
42 | client.Message("darkxanthos@gmail.com", "Testing");
43 | };
44 |
45 | client.OnError += (s, e) =>
46 | {
47 | Console.WriteLine("Error! " + e.Message);
48 | client.Close();
49 | };
50 |
51 |
52 |
53 | client.Connect();
54 |
55 | done.WaitOne();
56 | client.Close();
57 | }
58 |
59 | static void client_OnError(object sender, Exception ex)
60 | {
61 |
62 | }
63 |
64 | static void client_OnMessage(object sender, jabber.protocol.client.Message msg)
65 | {
66 | throw new NotImplementedException();
67 | }
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/UI/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // General Information about an assembly is controlled through the following
8 | // set of attributes. Change these attribute values to modify the information
9 | // associated with an assembly.
10 | [assembly: AssemblyTitle("Unite.UI")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("")]
14 | [assembly: AssemblyProduct("Unite.UI")]
15 | [assembly: AssemblyCopyright("Copyright © 2009")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // Setting ComVisible to false makes the types in this assembly not visible
20 | // to COM components. If you need to access a type in this assembly from
21 | // COM, set the ComVisible attribute to true on that type.
22 | [assembly: ComVisible(false)]
23 |
24 | //In order to begin building localizable applications, set
25 | //CultureYouAreCodingWith in your .csproj file
26 | //inside a . For example, if you are using US english
27 | //in your source files, set the to en-US. Then uncomment
28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in
29 | //the line below to match the UICulture setting in the project file.
30 |
31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32 |
33 |
34 | [assembly: ThemeInfo(
35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
36 | //(used if a resource is not found in the page,
37 | // or application resource dictionaries)
38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
39 | //(used if a resource is not found in the page,
40 | // app, or any theme specific resource dictionaries)
41 | )]
42 |
43 |
44 | // Version information for an assembly consists of the following four values:
45 | //
46 | // Major Version
47 | // Minor Version
48 | // Build Number
49 | // Revision
50 | //
51 | // You can specify all the values or you can default the Build and Revision Numbers
52 | // by using the '*' as shown below:
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("1.0.0.0")]
55 | [assembly: AssemblyFileVersion("1.0.0.0")]
56 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Specs/New_Starting_Application_Specs/When_application_starts_receiving_with_no_valid_credentials.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using NUnit.Framework;
6 | using Rhino.Mocks;
7 | using Unite.Messaging;
8 | using Unite.Messaging.Entities;
9 | using Unite.Messaging.Messages;
10 | using Unite.UI.ViewModels;
11 |
12 | namespace Unite.Specs.New_Starting_Application_Specs
13 | {
14 | [TestFixture]
15 | public class When_messaging_service_needs_credentials : cached_credentials_no_settings
16 | {
17 | protected override void Context()
18 | {
19 | FakeRepo.FakePluginFinder
20 | .Stub(x => x.GetAllPlugins())
21 | .Return(new[] { typeof(IMessagingService) });
22 |
23 | FakeRepo.FakeContext
24 | .Stub(x => x.GetCredentials(null))
25 | .Return(FakeRepo.CreateFakeCredentials());
26 |
27 | ViewModel = FakeRepo.GetMainView();
28 | }
29 |
30 | protected override void Because()
31 | {
32 | ViewModel.Init();
33 | }
34 |
35 | [Test]
36 | public void It_should_ask_ui_for_credentials()
37 | {
38 | FakeRepo.FakeContext
39 | .AssertWasCalled(x => x.GetCredentials(null));
40 | }
41 | }
42 |
43 | public class GetCredentialsPlugIn : FakePlugin
44 | {
45 | public override event EventHandler CredentialsRequested;
46 |
47 | public override void StartReceiving()
48 | {
49 | CredentialsRequested(this, new CredentialEventArgs());
50 | }
51 | }
52 |
53 | public abstract class cached_credentials_no_settings
54 | {
55 | protected MainView ViewModel;
56 | protected ScenarioRepository FakeRepo;
57 | protected IMessagingService FakeMessagingPlugin;
58 |
59 | [TestFixtureSetUp]
60 | public void Setup()
61 | {
62 | FakeMessagingPlugin = new GetCredentialsPlugIn();
63 |
64 | FakeRepo = new ScenarioRepository()
65 | {
66 | FakeMessagePlugin = FakeMessagingPlugin
67 | };
68 |
69 | Context();
70 | Because();
71 | }
72 |
73 | protected abstract void Because();
74 |
75 | protected abstract void Context();
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Plug Ins/GoogleTalkPlugIn/GoogleTalkDataAccess.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using jabber.client;
6 | using jabber.protocol.client;
7 |
8 | namespace GoogleTalkPlugIn
9 | {
10 | public class GoogleTalkDataAccess
11 | {
12 | private readonly JabberClient _Client;
13 | public bool IsConnected;
14 |
15 | public GoogleTalkDataAccess()
16 | {
17 | var client = new JabberClient();
18 |
19 | client.AutoLogin = true;
20 | client.AutoPresence = true;
21 | client.AutoRoster = false;
22 | client.AutoReconnect = 1;
23 |
24 | client.Server = "gmail.com";
25 | client.Port = 5222;
26 | client.Resource = "Unit3";
27 |
28 | client.OnConnect += (s, e) =>
29 | {
30 | IsConnected = e.Connected;
31 | };
32 |
33 | client.OnError += (s, e) =>
34 | {
35 | throw new Exception(e.Message);
36 | };
37 | client.OnAuthError += (s, e) => OnAuthError(s, null);
38 | client.OnMessage += (s, e) =>
39 | {
40 | OnMessage(s, new GTalkMessageEventArgs(e.From.User, e.Body));
41 | };
42 |
43 | _Client = client;
44 | }
45 |
46 | public event EventHandler OnAuthError;
47 | public event EventHandler OnMessage;
48 |
49 | public void Message(string name, string message)
50 | {
51 | _Client.Message(name, message);
52 | }
53 |
54 | public void Login(string name, string password)
55 | {
56 | _Client.User = name;
57 | _Client.Password = password;
58 | _Connect();
59 | }
60 |
61 | private void _Connect()
62 | {
63 | _Client.Connect();
64 | }
65 |
66 | internal void Logoff()
67 | {
68 | _Client.Close();
69 | }
70 | }
71 |
72 | public class GTalkMessageEventArgs : EventArgs
73 | {
74 | public GTalkMessageEventArgs(string user, string message)
75 | {
76 | Message = message;
77 | User = user;
78 | }
79 |
80 | public string Message;
81 | public string User;
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/UI/Views/UserCredentials.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Messaging/Services/ServiceProvider.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using StructureMap;
4 | using Unite.Messaging.Entities;
5 | using Unite.Messaging.Messages;
6 |
7 | namespace Unite.Messaging.Services
8 | {
9 | public class ServiceProvider : IServiceProvider
10 | {
11 | private readonly List Services;
12 |
13 | public ServiceProvider(IPluginFinder finder)
14 | {
15 | Services = new List();
16 |
17 | var plugins = finder.GetAllPlugins();
18 |
19 | foreach(var plugin in plugins)
20 | {
21 | _AddServiceProvider(plugin);
22 | }
23 | }
24 |
25 | private void _AddServiceProvider(Type serviceType)
26 | {
27 | var service = (IMessagingService)ObjectFactory.GetInstance(serviceType);
28 | Add(service);
29 | }
30 |
31 | public void Add(params IMessagingService[] services)
32 | {
33 | foreach(var service in services)
34 | {
35 | Add(service);
36 | }
37 | }
38 |
39 | private void Add(IMessagingService service)
40 | {
41 | service.CredentialsRequested += _GetCredentials;
42 | service.AuthorizationFailed += service_AuthorizationFailed;
43 | Services.Add(service);
44 | }
45 |
46 | void service_AuthorizationFailed(object sender, CredentialEventArgs e)
47 | {
48 | if (AuthorizationFailed != null)
49 | AuthorizationFailed(sender, e);
50 | }
51 |
52 | private void _GetCredentials(object sender, CredentialEventArgs e)
53 | {
54 | if (CredentialsRequested != null)
55 | CredentialsRequested(sender, e);
56 | }
57 |
58 | public IEnumerable GetServices()
59 | {
60 | return Services;
61 | }
62 |
63 | public event EventHandler CredentialsRequested;
64 | public event EventHandler AuthorizationFailed;
65 |
66 | public IMessagingService GetService(ServiceInformation info)
67 | {
68 | if(Services == null)
69 | throw new NullReferenceException("This service provider has a null collection of services. You should NEVER have this issue.");
70 |
71 | foreach (var service in Services)
72 | {
73 | if(service.GetInformation().Equals(info)) return service;
74 | }
75 |
76 | throw new InvalidOperationException("The requested service does not exist. You should NEVER see this.");
77 | }
78 | }
79 | }
--------------------------------------------------------------------------------
/IronTwit/RakeFile:
--------------------------------------------------------------------------------
1 | include FileTest
2 |
3 | require 'rubygems'
4 |
5 | gem 'rubyzip'
6 | require 'zip/zip'
7 | require 'zip/zipfilesystem'
8 | require "fileutils"
9 |
10 | require "BuildUtils.rb"
11 |
12 | COMPILE_TARGET = "release"
13 | RESULTS_DIR = "results"
14 | PRODUCT = "Falcon MobileServer"
15 | COPYRIGHT = 'Copyright 2008 JMT Systems Consulting, LLC';
16 | COMMON_ASSEMBLY_INFO = 'CommonAssemblyInfo';
17 | CLR_VERSION = "v3.5"
18 |
19 | VERSION_PREFIX = "2.0.0."
20 | BUILD_NUMBER = ENV["BUILD_NUMBER"].nil? ? "0" : ENV["BUILD_NUMBER"]
21 |
22 | VERSION_NUMBER = VERSION_PREFIX + BUILD_NUMBER;
23 |
24 | INSTALLER_FILENAME = File.basename("Unit3.msi", ".msi") + "-" + VERSION_NUMBER + ".msi"
25 |
26 | props = { :archive => "build" }
27 |
28 | desc "Compiles, unit tests, generates the database, and then runs integration tests"
29 | task :all => [:default]
30 |
31 | desc "**Default**, compiles and runs tests"
32 | task :default => [:compile, :unit_test, :move_artifacts]
33 |
34 | desc "Rebuild, cleans, compiles, and runs tests"
35 | task :rebuild => [:clean, :compile, :unit_test, :move_artifacts]
36 |
37 | desc "Update the version information for the build"
38 | task :version do
39 | puts "Updating Project Version to #{VERSION_NUMBER}"
40 |
41 | builder = AsmInfoBuilder.new(VERSION_NUMBER, {'Product' => PRODUCT, 'Copyright' => COPYRIGHT})
42 | buildNumber = builder.buildnumber
43 | builder.write COMMON_ASSEMBLY_INFO
44 | end
45 |
46 | # TODO Make clean actually clean build directories.
47 | desc "Prepares the working directory for a new build"
48 | task :clean do
49 | puts "Performing build clean..."
50 | Dir.glob(File.join(props[:archive], "*")){|file|
51 | FileUtils.rm(file) if File.file?(file)
52 | }
53 | Dir.mkdir props[:archive] unless exists?(props[:archive])
54 |
55 | file = "Server/Falcon.Server.Setup/setup.exe"
56 | FileUtils.rm(file) if File.file?(file)
57 | end
58 |
59 | desc "Compiles the app"
60 | task :compile do
61 | puts "Compiling the application..."
62 | MSBuildRunner.compile :compilemode => COMPILE_TARGET, :solutionfile => 'IronTwit/Unite.sln', :clrversion => CLR_VERSION
63 | end
64 |
65 | desc "Move Compilation Output to Build Directory"
66 | task :move_artifacts do
67 | puts "Gathering build artifacts..."
68 |
69 | def archive_files(source, glob_mask, destination)
70 | Dir.glob(File.join(source, glob_mask)) { |file|
71 | copy(file, destination) if File.file?(file)
72 | }
73 | end
74 |
75 | msiDir = "IronTwit/Unite.Setup/bin/#{COMPILE_TARGET}"
76 |
77 | archive_files(msiDir, "*.{msi}", props[:archive])
78 | end
79 |
80 | desc "Runs unit tests"
81 | task :unit_test do
82 | puts "Running unit tests..."
83 | runner = NUnitRunner.new :compilemode => COMPILE_TARGET, :results => './build', :source => './IronTwit', :platform => nil
84 | runner.executeTestInProject("Specs", "Unite.Specs")
85 | end
86 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/UI/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:2.0.50727.1434
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace Unite.UI.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Unite.UI.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Specs/UnitTests/ServiceResolverTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using IronTwitterPlugIn;
6 | using NUnit.Framework;
7 | using Unite.Messaging.Entities;
8 | using Unite.Messaging.Messages;
9 | using Unite.Messaging.Services;
10 | using IServiceProvider=Unite.Messaging.Services.IServiceProvider;
11 |
12 | namespace Unite.Specs.UnitTests
13 | {
14 | //[Ignore]
15 | [TestFixture]
16 | public class ServiceResolverTests
17 | {
18 | private const string TwitterAddress = "@darkxanthos";
19 | private const string EmailAddress = "darkxanthos@gmail.com";
20 | private const string GChatAddress = "darkxanthos";
21 |
22 | private ServiceResolver _resolver;
23 |
24 | [Test]
25 | public void DetectTwitterAddress()
26 | {
27 | Assert.AreEqual(TwitterUtilities.SERVICE_ID, _resolver.GetService(TwitterAddress).ServiceID,
28 | "Resolved service for Twitter address");
29 | Assert.AreEqual(TwitterUtilities.SERVICE_ID, _resolver.GetService(null).ServiceID, "Resolved service for null");
30 | Assert.AreEqual(TwitterUtilities.SERVICE_ID, _resolver.GetService("").ServiceID, "Resolved service for string.Empty");
31 | Assert.AreEqual(TwitterUtilities.SERVICE_ID, _resolver.GetService(" ").ServiceID, "Resolved service for whitespace");
32 | }
33 |
34 | [Test]
35 | public void DetectEmailAddress()
36 | {
37 | Assert.AreEqual(null, _resolver.GetService(EmailAddress), "Provider for Email addresses (not implemented yet)");
38 | }
39 |
40 | [Test]
41 | public void DetectGChatAddress()
42 | {
43 | Assert.AreEqual(null, _resolver.GetService(GChatAddress), "Provider for GChat addresses (not implemented yet)");
44 | }
45 |
46 | internal class TestServiceProvider : IServiceProvider
47 | {
48 | private List _services = new List();
49 |
50 | public void Add(params IMessagingService[] services)
51 | {
52 | _services.AddRange(services);
53 | }
54 |
55 | public IEnumerable GetServices()
56 | {
57 | return _services;
58 | }
59 |
60 | public event EventHandler CredentialsRequested;
61 | public event EventHandler AuthorizationFailed;
62 |
63 | public IMessagingService GetService(ServiceInformation info)
64 | {
65 | return _services.FirstOrDefault(service => service.GetInformation().Equals(info));
66 | }
67 | }
68 |
69 | [TestFixtureSetUp]
70 | public void FixtureSetup()
71 | {
72 | IServiceProvider serviceProvider = new TestServiceProvider();
73 | serviceProvider.Add(new TwitterUtilities());
74 | _resolver = new ServiceResolver(serviceProvider);
75 | }
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/UI/Utilities/GuiInteractionContext.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading;
6 | using System.Windows;
7 | using System.Windows.Threading;
8 | using Unite.Messaging.Entities;
9 | using Unite.UI.ViewModels;
10 | using Unite.UI.Views;
11 | using Unite.Messaging;
12 |
13 | namespace Unite.UI.Utilities
14 | {
15 | public class GuiInteractionContext : IInteractionContext
16 | {
17 | private Thread _mainThread;
18 |
19 | public GuiInteractionContext(Thread mainThread)
20 | {
21 | _mainThread = mainThread;
22 | }
23 |
24 | public Credentials GetCredentials(IServiceInformation serviceInformation)
25 | {
26 | var username = "";
27 | var password = "";
28 |
29 | var dispatcher = Dispatcher.FromThread(_mainThread);
30 | dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() =>
31 | {
32 | var model = new UserCredentialsViewModel()
33 | {
34 | Caption = serviceInformation.ServiceName + " Login"
35 | };
36 | var dialog = new UserCredentialsWindow
37 | {
38 | DataContext = model
39 | };
40 | var mainWindow = Application.Current.MainWindow;
41 | dialog.Owner = mainWindow;
42 | dialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
43 | dialog.ShowDialog();
44 | username = model.UserName;
45 | password = model.Password;
46 | }));
47 |
48 | return new Credentials()
49 | {
50 | UserName = username,
51 | Password = password,
52 | ServiceInformation = serviceInformation
53 | };
54 | }
55 |
56 | public bool AuthenticationFailedRetryQuery()
57 | {
58 | var result = MessageBox.Show("Username and/or password are not correct. Retry?",
59 | "Unit3 by Justin Bozonier",
60 | MessageBoxButton.YesNo);
61 | return result == MessageBoxResult.Yes;
62 | }
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/UI/Views/MainView.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows;
3 | using System.Windows.Input;
4 |
5 | namespace Unite.UI.Views
6 | {
7 | ///
8 | /// Interaction logic for Window1.xaml
9 | ///
10 | public partial class MainView : DraggableWindow
11 | {
12 | public MainView(ViewModels.MainView viewModel)
13 | {
14 | InitializeComponent();
15 | DataContext = viewModel;
16 | }
17 |
18 | protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
19 | {
20 | base.OnClosing(e);
21 | ((ViewModels.MainView)DataContext).Dispose();
22 | }
23 |
24 | void Window1_Loaded(object sender, RoutedEventArgs e)
25 | {
26 | ((ViewModels.IInitializeView)DataContext).Init();
27 | }
28 |
29 | private void Resizer_MouseDown(object sender, MouseButtonEventArgs e)
30 | {
31 | Resizer.CaptureMouse();
32 | _resizeMouseDownPoint = e.MouseDevice.GetPosition(null);
33 | _mouseDownSize = new Size(Width, Height);
34 | _resizing = true;
35 | }
36 |
37 | private void Resizer_MouseUp(object sender, MouseButtonEventArgs e)
38 | {
39 | _resizing = false;
40 | Resizer.ReleaseMouseCapture();
41 | }
42 |
43 | private void Resizer_MouseMove(object sender, MouseEventArgs e)
44 | {
45 | if (!_resizing)
46 | return;
47 |
48 | var currentPosition = e.MouseDevice.GetPosition(null);
49 | var moveVector = Point.Subtract(currentPosition, _resizeMouseDownPoint);
50 |
51 | if (_resizing)
52 | {
53 | ResizeWindow(moveVector);
54 | return;
55 | }
56 | }
57 |
58 | private void ResizeWindow(Vector dragVector)
59 | {
60 | var newWidth = _mouseDownSize.Width + dragVector.X;
61 | var newHeight = _mouseDownSize.Height + dragVector.Y;
62 | Width = Math.Max(newWidth, 200);
63 | Height = Math.Max(newHeight, 300);
64 | }
65 |
66 | private void MinimizeButton_Click(object sender, RoutedEventArgs e)
67 | {
68 | WindowState = WindowState.Minimized;
69 | }
70 |
71 | private void CloseButton_Click(object sender, RoutedEventArgs e)
72 | {
73 | Close();
74 | }
75 |
76 | private void MessageToSend_KeyUp(object sender, KeyEventArgs e)
77 | {
78 | if (e.Key == Key.Enter)
79 | {
80 | SendMessage.Focus(); //need to cause MessageToSend to lose focus so binding will update viewmodel
81 | SendMessage.Command.Execute(null);
82 | OnMessageSent();
83 | }
84 | }
85 |
86 | private void SendMessage_Click(object sender, RoutedEventArgs e)
87 | {
88 | OnMessageSent();
89 | }
90 |
91 | private void OnMessageSent()
92 | {
93 | Recipient.Focus();
94 | }
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Unite.TestHarness/Unite.TestHarness.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 9.0.21022
7 | 2.0
8 | {12FCE33F-792C-4AC6-8733-A75017ADC6A7}
9 | Exe
10 | Properties
11 | Unite.TestHarness
12 | Unite.TestHarness
13 | v3.5
14 | 512
15 |
16 |
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | pdbonly
27 | true
28 | bin\Release\
29 | TRACE
30 | prompt
31 | 4
32 |
33 |
34 |
35 | False
36 | ..\..\ThirdParty\JabberLibrary\jabber-net.dll
37 |
38 |
39 | False
40 | ..\..\ThirdParty\JabberLibrary\netlib.Dns.dll
41 |
42 |
43 |
44 | 3.5
45 |
46 |
47 | 3.5
48 |
49 |
50 | 3.5
51 |
52 |
53 |
54 |
55 | False
56 | ..\..\ThirdParty\JabberLibrary\zlib.net.dll
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
71 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Specs/TwitterServicesScope/When_sending_large_messages.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Unite.Messaging;
3 | using Unite.Messaging.Entities;
4 | using Unite.UI.Utilities;
5 | using IronTwitterPlugIn;
6 | using NUnit.Framework;
7 | using SpecUnit;
8 | using System.Collections.Generic;
9 |
10 | namespace Unite.Specs.Application_running.sending_messages
11 | {
12 | [TestFixture]
13 | public class When_sending_a_large_message_with_no_recipient : context
14 | {
15 | [Test]
16 | public void It_should_be_broken_up_into_multiple_messages()
17 | {
18 | DataAccess.MessagesSent.ShouldBeGreaterThan(1);
19 | }
20 |
21 | [Test]
22 | public void It_includes_the_recipient_in_each_message()
23 | {
24 | DataAccess.SentMessages.ForEach(message => message.Contains(Recipient).ShouldBeTrue());
25 | }
26 |
27 | [Test]
28 | public void It_clips_each_message_to_be_at_or_below_the_max_message_length()
29 | {
30 | DataAccess.SentMessages.ForEach(message => message.Length.ShouldBeLessThan(MaxMessageLength+1));
31 | }
32 |
33 | [Test]
34 | public void It_should_not_remove_any_letters_from_the_message()
35 | {
36 | DataAccess.SentMessages.Reverse();
37 | DataAccess.SentMessages[0].EndsWith("it.").ShouldBeTrue();
38 | }
39 |
40 | protected string Recipient = "@ChadBoyer" ;
41 |
42 | protected string Message =
43 | "I need to test to ensure that my twitter client is breaking up messages only at word boundaries. This will come in handy not just for making long tweets read better when split but also for displaying URLs. My code can't handle a single long word right now though (think a word larger than 140 chars :). Once that becomes a *real* problem, I'll look into fixing it.";
44 |
45 | protected override void Because()
46 | {
47 | Utilities.SendMessage(
48 | new FakeUser(){UserName = Recipient},
49 | Message);
50 | }
51 |
52 | protected override void Context()
53 | {
54 | }
55 | }
56 |
57 | [TestFixture]
58 | public abstract class context
59 | {
60 | protected TwitterUtilities Utilities;
61 | protected TestTwitterDataAccess DataAccess;
62 | protected readonly int MaxMessageLength = 140;
63 |
64 | [TestFixtureSetUp]
65 | public void Setup()
66 | {
67 | DataAccess = new TestTwitterDataAccess();
68 | Utilities = new TwitterUtilities(DataAccess, MaxMessageLength);
69 |
70 | Context();
71 | Because();
72 | }
73 |
74 | protected abstract void Because();
75 |
76 | protected abstract void Context();
77 | }
78 |
79 | public class TestTwitterDataAccess : ITwitterDataAccess
80 | {
81 | public int MessagesSent;
82 | public List SentMessages;
83 |
84 | public TestTwitterDataAccess()
85 | {
86 | SentMessages = new List();
87 | }
88 |
89 | public string SendMessage(Credentials credentials, string message)
90 | {
91 | MessagesSent++;
92 | SentMessages.Add(message);
93 | return "result message";
94 | }
95 |
96 | public string GetMessages(Credentials credentials)
97 | {
98 | return "result message";
99 | }
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Specs/TwitterServicesScope/When_receiving_messages.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using IronTwitterPlugIn;
6 | using NUnit.Framework;
7 | using SpecUnit;
8 | using Unite.Messaging;
9 | using Unite.Messaging.Entities;
10 | using Unite.Messaging.Messages;
11 |
12 | namespace Unite.Specs.TwitterServicesScope
13 | {
14 | [TestFixture]
15 | public class When_receiving_messages : receiving_context
16 | {
17 | [Test]
18 | public void It_should_use_the_credentials_provided_by_the_user()
19 | {
20 | DataAccess.ProvidedCredentials.ShouldEqual(UserCredentials);
21 | }
22 |
23 | [Test]
24 | public void It_should_request_credentials()
25 | {
26 | CredentialsRequested.ShouldBeTrue();
27 | }
28 |
29 | [Test]
30 | public void It_should_get_all_messages()
31 | {
32 | ReceivedMessages.Count.ShouldEqual(1);
33 | }
34 |
35 | protected override void Because()
36 | {
37 | ReceivedMessages = Utilities.GetMessages();
38 | }
39 |
40 | protected override void Context()
41 | {
42 |
43 | }
44 | }
45 |
46 | [TestFixture]
47 | public abstract class receiving_context
48 | {
49 | protected TwitterUtilities Utilities;
50 | protected TestRxTwitterDataAccess DataAccess;
51 | protected readonly int MaxMessageLength = 140;
52 | protected bool CredentialsRequested;
53 | protected List ReceivedMessages;
54 | protected Credentials UserCredentials;
55 |
56 | [TestFixtureSetUp]
57 | public void Setup()
58 | {
59 | DataAccess = new TestRxTwitterDataAccess();
60 | Utilities = new TwitterUtilities(DataAccess, MaxMessageLength);
61 | Utilities.CredentialsRequested += Utilities_CredentialsRequested;
62 |
63 | Context();
64 | Because();
65 | }
66 |
67 | void Utilities_CredentialsRequested(object sender, CredentialEventArgs e)
68 | {
69 | CredentialsRequested = true;
70 | UserCredentials = new Credentials()
71 | {
72 | UserName = "darkxanthos",
73 | Password = "password",
74 | ServiceInformation = e.ServiceInfo
75 | };
76 | Utilities.SetCredentials(UserCredentials);
77 | }
78 |
79 | protected abstract void Because();
80 |
81 | protected abstract void Context();
82 | }
83 |
84 | public class TestRxTwitterDataAccess : ITwitterDataAccess
85 | {
86 | public int MessagesSent;
87 | public List SentMessages;
88 | public Credentials ProvidedCredentials;
89 |
90 | public TestRxTwitterDataAccess()
91 | {
92 | SentMessages = new List();
93 | }
94 |
95 | public string SendMessage(Credentials credentials, string message)
96 | {
97 | ProvidedCredentials = credentials;
98 | MessagesSent++;
99 | SentMessages.Add(message);
100 | return "result message";
101 | }
102 |
103 | public string GetMessages(Credentials credentials)
104 | {
105 | ProvidedCredentials = credentials;
106 | return "[{text:'test message'}]";
107 | }
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Plug Ins/GoogleTalkPlugIn/GoogleTalkPlugIn.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 9.0.21022
7 | 2.0
8 | {6D6AD44D-28E7-4ED0-8A9F-68C36E9AFCC6}
9 | Library
10 | Properties
11 | GoogleTalkPlugIn
12 | GoogleTalkPlugIn
13 | v3.5
14 | 512
15 |
16 |
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | pdbonly
27 | true
28 | bin\Release\
29 | TRACE
30 | prompt
31 | 4
32 |
33 |
34 |
35 | False
36 | ..\..\..\ThirdParty\JabberLibrary\jabber-net.dll
37 |
38 |
39 | False
40 | ..\..\..\ThirdParty\JabberLibrary\netlib.Dns.dll
41 |
42 |
43 |
44 | 3.5
45 |
46 |
47 | 3.5
48 |
49 |
50 | 3.5
51 |
52 |
53 |
54 |
55 | False
56 | ..\..\..\ThirdParty\JabberLibrary\zlib.net.dll
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 | {7B3CBD74-D69D-420F-90F9-19174C7DE3FA}
68 | Unite.Messaging
69 |
70 |
71 |
72 |
79 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Specs/Starting_Application/Start_application_receive_message_specs.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Unite.Messaging.Entities;
3 | using Unite.Messaging.Services;
4 | using Unite.UI.Utilities;
5 | using Unite.UI.ViewModels;
6 | using IronTwitterPlugIn;
7 | using NUnit.Framework;
8 | using SpecUnit;
9 | using StructureMap;
10 | using Unite.Messaging;
11 | using IServiceProvider=Unite.Messaging.Services.IServiceProvider;
12 |
13 | namespace Unite.Specs.Application_starting.Receiving_messages
14 | {
15 | [Ignore("These tests fail inconsistently. Hints at something very bad but may be a threading thing.")]
16 | [TestFixture]
17 | public class When_refresh_is_requested : context
18 | {
19 | [Test]
20 | public void It_should_get_items()
21 | {
22 | Model.Messages.Count.ShouldBeGreaterThan(0);
23 | }
24 |
25 | [Test]
26 | public void It_should_be_able_to_refresh()
27 | {
28 | Model.ReceiveMessage.CanExecute(null).ShouldBeTrue();
29 | }
30 |
31 | protected override void Because()
32 | {
33 | Model.ReceiveMessage.Execute(null);
34 | }
35 |
36 | protected override void Context()
37 | {
38 | Model.Init();
39 | }
40 | }
41 |
42 | public abstract class context
43 | {
44 | protected MainView Model;
45 | protected TestTwitterUtilities Utilities;
46 |
47 | protected bool Message_was_sent
48 | {
49 | get;
50 | set;
51 | }
52 |
53 |
54 | [TestFixtureSetUp]
55 | public void Setup()
56 | {
57 | ContainerBootstrapper.BootstrapStructureMap();
58 | Model = ObjectFactory.GetInstance();
59 |
60 | Context();
61 | Because();
62 | }
63 |
64 | protected abstract void Because();
65 |
66 | protected abstract void Context();
67 | }
68 |
69 | public class TestDataAccess : ITwitterDataAccess
70 | {
71 | public string SendMessage(Credentials credentials, string message)
72 | {
73 | return "";
74 | }
75 |
76 | public string GetMessages(Credentials credentials)
77 | {
78 | return "[{text:'Message 1', user:{screen_name:'darkxanthos'}}]";
79 | }
80 | }
81 |
82 | public class TestingInteractionContext : IInteractionContext
83 | {
84 | public Credentials GetCredentials(IServiceInformation serviceInformation)
85 | {
86 | return new Credentials()
87 | {
88 | UserName = "testuser",
89 | Password = "testpw",
90 | ServiceInformation = serviceInformation
91 | };
92 | }
93 |
94 | public bool AuthenticationFailedRetryQuery()
95 | {
96 | return false;
97 | }
98 | }
99 |
100 | public static class ContainerBootstrapper
101 | {
102 |
103 | public static void BootstrapStructureMap()
104 | {
105 |
106 | var serviceProviders = new ServiceProvider(new PluginFinder());
107 | serviceProviders.Add(new TwitterUtilities(new TestDataAccess()));
108 |
109 | // Initialize the static ObjectFactory container
110 |
111 | ObjectFactory.Initialize(x =>
112 | {
113 | x.ForRequestedType().TheDefaultIsConcreteType();
114 | x.ForRequestedType().TheDefaultIsConcreteType();
115 | x.ForRequestedType().TheDefaultIsConcreteType();
116 | x.ForRequestedType().TheDefault.IsThis(serviceProviders);
117 | });
118 |
119 | }
120 |
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Messaging/Unite.Messaging.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 9.0.21022
7 | 2.0
8 | {7B3CBD74-D69D-420F-90F9-19174C7DE3FA}
9 | Library
10 | Properties
11 | Unite.Messaging
12 | Unite.Messaging
13 | v3.5
14 | 512
15 |
16 |
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | pdbonly
27 | true
28 | bin\Release\
29 | TRACE
30 | prompt
31 | 4
32 |
33 |
34 |
35 | False
36 | ..\..\ThirdParty\IoC\StructureMap.dll
37 |
38 |
39 |
40 | 3.5
41 |
42 |
43 | 3.5
44 |
45 |
46 | 3.5
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
84 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Specs/UnitTests/InlineUrlsTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using NUnit.Framework;
6 |
7 | namespace Unite.Specs.UnitTests
8 | {
9 | [TestFixture]
10 | public class InlineUrlsTests
11 | {
12 | [Test]
13 | public void SimpleUrlAtBeginningOfMessage()
14 | {
15 | var url = "http://wwww.yahoo.com";
16 | var message = string.Format("{0} is a cool site!", url);
17 | var inlineUris = UI.Utilities.InlineUris.Get(message);
18 | Assert.AreEqual(1, inlineUris.Count, "Number of InlineUris returned");
19 | var inlineUri = inlineUris[0];
20 | Assert.AreEqual(0, inlineUri.StartIndex, "Start index of InlineUri returned");
21 | Assert.AreEqual(url.Length, inlineUri.Length, "Lenth of InlineUri returned");
22 | Assert.AreEqual(url, inlineUri.OriginalString, "InlineUri original string");
23 | }
24 |
25 | [Test]
26 | public void SimpleUrlInMiddleOfMessage()
27 | {
28 | var url = "http://www.yahoo.com";
29 | var message = string.Format("@darkxanthos hey, {0} is a cool site!", url);
30 | var inlineUris = UI.Utilities.InlineUris.Get(message);
31 | Assert.AreEqual(1, inlineUris.Count, "Number of InlineUris returned");
32 | var inlineUri = inlineUris[0];
33 | Assert.AreEqual(message.IndexOf(url, 0), inlineUri.StartIndex, "Start index of InlineUri returned");
34 | Assert.AreEqual(url.Length, inlineUri.Length, "Lenth of InlineUri returned");
35 | Assert.AreEqual(url, inlineUri.OriginalString, "InlineUri original string");
36 | }
37 |
38 | [Test]
39 | public void SimpleUrlAtEndOfMessage()
40 | {
41 | var url = "http://www.yahoo.com";
42 | var message = string.Format("@darkxanthos hey, I think you should check out this cool site - {0}", url);
43 | var inlineUris = UI.Utilities.InlineUris.Get(message);
44 | Assert.AreEqual(1, inlineUris.Count, "Number of InlineUris returned");
45 | var inlineUri = inlineUris[0];
46 | Assert.AreEqual(message.IndexOf(url, 0), inlineUri.StartIndex, "Start index of InlineUri returned");
47 | Assert.AreEqual(url.Length, inlineUri.Length, "Lenth of InlineUri returned");
48 | Assert.AreEqual(url, inlineUri.OriginalString, "InlineUri original string");
49 | }
50 |
51 | [Test]
52 | public void TwoUrlsInMiddleAndAtEnd()
53 | {
54 | var urlA = "http://www.yahoo.com";
55 | var urlB = "http://www.microsoft.com";
56 | var message = string.Format("This place {0} really would have been better off going to this place {1}", urlA,
57 | urlB);
58 | var inlineUris = UI.Utilities.InlineUris.Get(message);
59 | Assert.AreEqual(2, inlineUris.Count, "Number of InlineUris returned");
60 | var inlineUriA = inlineUris[0];
61 | var inlineUriB = inlineUris[1];
62 | Assert.AreEqual(message.IndexOf(urlA, 0), inlineUriA.StartIndex, "Start index of first InlineUri");
63 | Assert.AreEqual(urlA.Length, inlineUriA.Length, "Lenght of first InlineUri");
64 | Assert.AreEqual(urlA, inlineUriA.OriginalString, "First InlineUri original string");
65 | Assert.AreEqual(message.IndexOf(urlB, 0), inlineUriB.StartIndex, "Start index of second InlineUri");
66 | Assert.AreEqual(urlB.Length, inlineUriB.Length, "Length of second InlineUri");
67 | Assert.AreEqual(urlB, inlineUriB.OriginalString, "Second InlineUri original string");
68 | }
69 |
70 | [Test]
71 | public void NullOrEmptyMessageText()
72 | {
73 | string text = null;
74 | var inlineUris = UI.Utilities.InlineUris.Get(text);
75 | Assert.AreEqual(0, inlineUris.Count, "Count of Inline Uris for null text");
76 | text = "";
77 | inlineUris = UI.Utilities.InlineUris.Get(text);
78 | Assert.AreEqual(0, inlineUris.Count, "Count of Inline Uris for empty string text");
79 | }
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Plug Ins/IronTwitterPlugIn/IronTwitterPlugIn.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 9.0.21022
7 | 2.0
8 | {7E90D07E-E532-4F57-BD4D-41A3C64F6B3E}
9 | Library
10 | Properties
11 | IronTwitterPlugIn
12 | IronTwitterPlugIn
13 | v3.5
14 | 512
15 |
16 |
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | pdbonly
27 | true
28 | bin\Release\
29 | TRACE
30 | prompt
31 | 4
32 |
33 |
34 |
35 | False
36 | ..\..\..\ThirdParty\TwitterComm\Newtonsoft.Json.dll
37 |
38 |
39 | False
40 | ..\..\..\ThirdParty\IoC\StructureMap.dll
41 |
42 |
43 | False
44 | ..\..\..\ThirdParty\IoC\StructureMap.AutoMocking.dll
45 |
46 |
47 |
48 | 3.5
49 |
50 |
51 | 3.5
52 |
53 |
54 | 3.5
55 |
56 |
57 |
58 |
59 | False
60 | ..\..\..\ThirdParty\TwitterComm\Yedda.Twitter.dll
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 | {7B3CBD74-D69D-420F-90F9-19174C7DE3FA}
74 | Unite.Messaging
75 |
76 |
77 |
78 |
85 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Specs/Application_running/When_replying_to_a_message.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using NUnit.Framework;
5 | using Rhino.Mocks;
6 | using SpecUnit;
7 | using StructureMap;
8 | using Unite.Messaging;
9 | using Unite.Messaging.Entities;
10 | using Unite.Messaging.Messages;
11 | using Unite.Messaging.Services;
12 | using Unite.UI.Utilities;
13 | using Unite.UI.ViewModels;
14 |
15 | namespace Unite.Specs.Application_running
16 | {
17 | [TestFixture]
18 | public class When_clicking_on_a_message : message_has_been_received
19 | {
20 | private string Sender;
21 |
22 | [Ignore]
23 | [Test]
24 | public void It_should_show_the_message_sender_in_the_recipient_field()
25 | {
26 | Model.Recipient.ShouldEqual(Model.SelectedMessage.Address.UserName);
27 | }
28 |
29 | protected override void Because()
30 | {
31 | Model.SelectedMessage = Model.Messages.First();
32 | }
33 |
34 | protected override void Context()
35 | {
36 | this.Model.ReceiveMessage.Execute(null);
37 | }
38 | }
39 |
40 | public abstract class message_has_been_received
41 | {
42 | protected MainView Model;
43 | protected UiMessage RecievedMessage;
44 |
45 | [TestFixtureSetUp]
46 | public void Setup()
47 | {
48 | var manager = new ServiceManager();
49 |
50 | ContainerBootstrapper.BootstrapStructureMap();
51 | Model = ObjectFactory.GetInstance();
52 | ObjectFactory.EjectAllInstancesOf();
53 | ObjectFactory.Inject(typeof(IMessagingServiceManager), manager);
54 |
55 | Model.Init();
56 |
57 | Context();
58 | Because();
59 | }
60 |
61 | protected abstract void Because();
62 |
63 | protected abstract void Context();
64 | }
65 |
66 | public class ServiceManager : IMessagingServiceManager
67 | {
68 | public bool CanAccept(Credentials credentials)
69 | {
70 | throw new System.NotImplementedException();
71 | }
72 |
73 | public List GetMessages()
74 | {
75 | return new List()
76 | {
77 | new Message() {Text = "Testing", Address = new Identity("test", new ServiceInformation())}
78 | };
79 | }
80 |
81 | public void SendMessage(IIdentity recipient, string message)
82 | {
83 | throw new System.NotImplementedException();
84 | }
85 |
86 | public void SetCredentials(Credentials credentials)
87 | {
88 | throw new System.NotImplementedException();
89 | }
90 |
91 | public event EventHandler CredentialsRequested;
92 | public event EventHandler AuthorizationFailed;
93 | public bool CanFind(string address)
94 | {
95 | throw new System.NotImplementedException();
96 | }
97 |
98 | public ServiceInformation GetInformation()
99 | {
100 | throw new System.NotImplementedException();
101 | }
102 |
103 | public void StartReceiving()
104 | {
105 | MessagesReceived(this, new MessagesReceivedEventArgs(GetMessages()));
106 | }
107 |
108 | public void StopReceiving()
109 | {
110 | throw new System.NotImplementedException();
111 | }
112 |
113 | public event EventHandler MessagesReceived;
114 | public void SendMessage(string recipient, string message)
115 | {
116 | throw new System.NotImplementedException();
117 | }
118 | }
119 |
120 | public class Message : IMessage
121 | {
122 | public string Text
123 | {
124 | get; set;
125 | }
126 |
127 | public IIdentity Address
128 | {
129 | get; set;
130 | }
131 |
132 | public DateTime TimeStamp
133 | {
134 | get; set;
135 | }
136 | }
137 | }
138 |
--------------------------------------------------------------------------------
/IronTwit/BuildUtils.rb:
--------------------------------------------------------------------------------
1 | require 'erb'
2 |
3 | class NUnitRunner
4 | include FileTest
5 |
6 | def initialize(paths)
7 | @sourceDir = paths.fetch(:source, 'source')
8 | @resultsDir = paths.fetch(:results, 'results')
9 | @compilePlatform = paths.fetch(:platform, 'x86')
10 | @compileTarget = paths.fetch(:compilemode, 'debug')
11 |
12 | @resultsDir = File.expand_path(@resultsDir)
13 |
14 | if ENV["teamcity.dotnet.nunitlauncher"] # check if we are running in TeamCity
15 | # We are not using the TeamCity nunit launcher. We use NUnit with the TeamCity NUnit Addin which needs tO be copied to our NUnit addins folder
16 | # http://blogs.jetbrains.com/teamcity/2008/07/28/unfolding-teamcity-addin-for-nunit-secrets/
17 | # The teamcity.dotnet.nunitaddin environment variable is not available until TeamCity 4.0, so we hardcode it for now
18 | @teamCityAddinPath = ENV["teamcity.dotnet.nunitaddin"] ? ENV["teamcity.dotnet.nunitaddin"] : 'c:/TeamCity/buildAgent/plugins/dotnetPlugin/bin/JetBrains.TeamCity.NUnitAddin-NUnit'
19 | cp @teamCityAddinPath + '-2.4.7.dll', 'tools/nunit/addins'
20 | end
21 |
22 | @nunitExe = File.join('ThirdParty', 'UnitTesting', "nunit-console#{(@compilePlatform.nil? ? '' : "-#{@compilePlatform}")}.exe").gsub('/','\\')
23 | @nunitExe = "\"" + File.expand_path(@nunitExe) + "\"" + ' /nothread'
24 | end
25 |
26 | def executeTests(assemblies)
27 | createResultDir()
28 |
29 | assemblies.each do |assem|
30 | file = File.expand_path("#{@sourceDir}/#{assem}/bin/#{(@compilePlatform.nil? ? '' : "#{@compilePlatform}/")}#{@compileTarget}/#{assem}.dll")
31 | executeTestOnAssembly(file, assem)
32 | end
33 | end
34 |
35 | def executeTestInProject(projectName, assembly)
36 | createResultDir()
37 |
38 | file = File.expand_path("#{@sourceDir}/#{projectName}/bin/#{(@compilePlatform.nil? ? '' : "#{@compilePlatform}/")}#{@compileTarget}/#{assembly}.dll")
39 | executeTestOnAssembly(file, projectName)
40 | end
41 |
42 | def createResultDir
43 | Dir.mkdir @resultsDir unless exists?(@resultsDir)
44 | end
45 |
46 | def executeTestOnAssembly(file, assemblyName)
47 | result = File.expand_path(File.join(@resultsDir, "#{assemblyName}-test.xml"))
48 | sh "#{@nunitExe} \"#{file}\" /xml:\"#{result}\""
49 | end
50 | end
51 |
52 | class MSBuildRunner
53 | def self.compile(attributes)
54 | version = attributes.fetch(:clrversion, 'v3.5')
55 | compileTarget = attributes.fetch(:compilemode, 'debug')
56 | solutionFile = attributes[:solutionfile]
57 |
58 | frameworkDir = File.join(ENV['windir'].dup, 'Microsoft.NET', 'Framework', version)
59 | msbuildFile = File.join(frameworkDir, 'msbuild.exe')
60 |
61 | sh "#{msbuildFile} #{solutionFile} /maxcpucount /v:m /property:BuildInParallel=false /property:Configuration=#{compileTarget} /t:Rebuild"
62 | end
63 | end
64 |
65 | class AsmInfoBuilder
66 | attr_reader :buildnumber
67 |
68 | def initialize(asmVersion, properties)
69 | @properties = properties;
70 |
71 | @buildnumber = asmVersion
72 | @properties['Version'] = @properties['InformationalVersion'] = buildnumber;
73 | end
74 |
75 | def write(baseFilename, language)
76 | if (language.casecmp("vb") == 0) then writeVB(baseFilename) end
77 | if (language.casecmp("cs") == 0) then writeCS(baseFilename) end
78 | raise "Specified Language for AsmInfo not 'CS' or 'VB'"
79 | end
80 |
81 | def writeCS(baseFilename)
82 | csTemplate = %q{
83 | using System;
84 | using System.Reflection;
85 | using System.Runtime.InteropServices;
86 |
87 | <% @properties.each {|k, v| %>
88 | [assembly: Assembly<%=k%>Attribute("<%=v%>")]
89 | <% } %>
90 | }.gsub(/^ /, '')
91 |
92 | filename = baseFilename + ".cs"
93 | writeAsmInfo(filename, csTemplate)
94 | end
95 |
96 | def writeVB(baseFilename)
97 | vbTemplate = %q{
98 | Imports System
99 | Imports System.Reflection
100 | Imports System.Runtime.InteropServices
101 |
102 | <% @properties.each {|k, v| %>
103 | Attribute("<%=v%>")>
104 | <% } %>
105 | }.gsub(/^ /, '')
106 |
107 | filename = baseFilename + ".vb"
108 | writeAsmInfo(filename, vbTemplate)
109 | end
110 |
111 | def writeAsmInfo(filename, template)
112 | erb = ERB.new(template, 0, "%<>")
113 |
114 | File.open(filename, 'w') do |file|
115 | file.puts erb.result(binding)
116 | end
117 | end
118 | end
--------------------------------------------------------------------------------
/IronTwit/ThirdParty/UnitTesting/nunit-console.exe.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
13 |
14 |
15 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
30 |
31 |
32 |
33 |
34 |
45 |
56 |
57 |
65 |
66 |
67 |
68 |
69 |
70 |
72 |
73 |
74 |
77 |
79 |
80 |
81 |
82 |
85 |
87 |
88 |
89 |
90 |
93 |
95 |
96 |
97 |
98 |
101 |
103 |
104 |
105 |
106 |
109 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Messaging/Services/ServicesManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using Unite.Messaging.Entities;
5 | using Unite.Messaging.Messages;
6 |
7 | namespace Unite.Messaging.Services
8 | {
9 | public class ServicesManager : IMessagingServiceManager
10 | {
11 | private readonly ServiceInformation _ServiceInfo = new ServiceInformation()
12 | {
13 | ServiceID = new Guid("{FC1DF655-BBA0-4036-B352-CA98E1B56001}"),
14 | ServiceName = "Service Manager"
15 | };
16 |
17 | private readonly IServiceProvider _Provider;
18 | private readonly IServiceResolver _Resolver;
19 |
20 | private readonly IEnumerable _Services;
21 |
22 | public event EventHandler AuthorizationFailed;
23 | public event EventHandler CredentialsRequested;
24 | public event EventHandler MessagesReceived;
25 |
26 | public ServicesManager(IServiceProvider provider)
27 | {
28 | _Provider = provider;
29 | _Provider.CredentialsRequested += Provider_CredentialsRequested;
30 | _Provider.AuthorizationFailed += Provider_AuthorizationFailed;
31 | _Resolver = new ServiceResolver(_Provider);
32 |
33 | _Services = _Provider.GetServices();
34 | }
35 |
36 | void Provider_AuthorizationFailed(object sender, CredentialEventArgs e)
37 | {
38 | if (AuthorizationFailed != null)
39 | AuthorizationFailed(sender, e);
40 | }
41 |
42 | void Provider_CredentialsRequested(object sender, CredentialEventArgs e)
43 | {
44 | if (CredentialsRequested != null)
45 | CredentialsRequested(sender, e);
46 | }
47 |
48 | public bool CanAccept(Credentials credentials)
49 | {
50 | return true;
51 | }
52 |
53 | public List GetMessages()
54 | {
55 | var messages = new List();
56 | var services = _Services;
57 |
58 | foreach (var service in services)
59 | {
60 | messages.AddRange(service.GetMessages());
61 | }
62 |
63 | return messages;
64 | }
65 |
66 | public void SendMessage(IIdentity recipient, string message)
67 | {
68 | var service = _Provider.GetService(recipient.ServiceInfo);
69 | service.SendMessage(recipient, message);
70 | }
71 |
72 | public void SetCredentials(Credentials credentials)
73 | {
74 | var services = _Services;
75 |
76 | foreach (var service in services)
77 | {
78 | if(service.CanAccept(credentials))
79 | service.SetCredentials(credentials);
80 | }
81 | }
82 |
83 | public bool CanFind(string address)
84 | {
85 | var foundService = _Resolver.GetService(address);
86 | return foundService != null;
87 | }
88 |
89 | public ServiceInformation GetInformation()
90 | {
91 | return _ServiceInfo;
92 | }
93 |
94 | public void StartReceiving()
95 | {
96 | var services = _Services;
97 |
98 | foreach (var service in services)
99 | {
100 | service.MessagesReceived += service_MessagesReceived;
101 | service.StartReceiving();
102 | }
103 | }
104 |
105 | private void service_MessagesReceived(object sender, MessagesReceivedEventArgs e)
106 | {
107 | if (MessagesReceived != null)
108 | MessagesReceived(sender, e);
109 | }
110 |
111 | public void StopReceiving()
112 | {
113 | var services = _Services;
114 |
115 | foreach (var service in services)
116 | {
117 | service.MessagesReceived -= service_MessagesReceived;
118 | service.StopReceiving();
119 | }
120 | }
121 |
122 | public void SendMessage(string recipient, string message)
123 | {
124 | var serviceToUse = _Resolver.GetService(recipient);
125 | SendMessage(new Identity(recipient, serviceToUse), message);
126 | }
127 | }
128 | }
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Specs/Using_Services/When_getting_messages.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using NUnit.Framework;
6 | using SpecUnit;
7 | using Unite.Messaging;
8 | using Unite.Messaging.Entities;
9 | using Unite.Messaging.Messages;
10 | using Unite.Messaging.Services;
11 |
12 | namespace Unite.Specs.Using_Services
13 | {
14 | [TestFixture]
15 | public class When_getting_messages : context
16 | {
17 | [Test]
18 | public void It_should_get_messages_from_all_available_services()
19 | {
20 | Messages.Count().ShouldEqual(2);
21 | }
22 |
23 | protected override void Because()
24 | {
25 |
26 | Messages = new List(ServiceManager.GetMessages());
27 | }
28 |
29 | protected override void Context()
30 | {
31 |
32 | }
33 | }
34 |
35 | public abstract class context
36 | {
37 | protected IMessagingService ServiceManager;
38 | protected ServiceProvider ServiceProvider;
39 | protected List Messages;
40 | protected Credentials MyCredentials;
41 |
42 | [TestFixtureSetUp]
43 | public void Setup()
44 | {
45 | MyCredentials = new Credentials() { UserName = "username", Password = "password" };
46 | ServiceProvider = new ServiceProvider(new PluginFinder());
47 | ServiceProvider.Add(new FauxMessageService("test 1"), new FauxMessageService("test2"));
48 | ServiceManager = new ServicesManager(ServiceProvider);
49 |
50 | Context();
51 | Because();
52 | }
53 |
54 | protected abstract void Because();
55 |
56 | protected abstract void Context();
57 | }
58 |
59 | public class FauxMessageService : IMessagingService
60 | {
61 | private string MessageText;
62 |
63 | public FauxMessageService(string messageText)
64 | {
65 | MessageText = messageText;
66 | }
67 |
68 | public bool CanAccept(Credentials credentials)
69 | {
70 | return true;
71 | }
72 |
73 | public List GetMessages()
74 | {
75 | return new List()
76 | {
77 | new Message()
78 | {
79 | Address = new Recipient(){UserName = "darkxanthos"},
80 | Text = MessageText,
81 | TimeStamp = DateTime.Now
82 | }
83 | };
84 | }
85 |
86 | public void SendMessage(IIdentity recipient, string message)
87 | {
88 | throw new System.NotImplementedException();
89 | }
90 |
91 | public void SetCredentials(Credentials credentials)
92 | {
93 |
94 | }
95 |
96 | public event EventHandler CredentialsRequested;
97 | public event EventHandler AuthorizationFailed;
98 |
99 | public bool CanFind(string address)
100 | {
101 | throw new System.NotImplementedException();
102 | }
103 |
104 | public ServiceInformation GetInformation()
105 | {
106 | throw new System.NotImplementedException();
107 | }
108 |
109 | public void StartReceiving()
110 | {
111 | throw new System.NotImplementedException();
112 | }
113 |
114 | public void StopReceiving()
115 | {
116 | throw new System.NotImplementedException();
117 | }
118 |
119 | public event EventHandler MessagesReceived;
120 | }
121 |
122 | public class Recipient : IIdentity
123 | {
124 | public string UserName
125 | {
126 | get; set;
127 | }
128 |
129 | public ServiceInformation ServiceInfo
130 | {
131 | get; set;
132 | }
133 | }
134 |
135 | public class Message : IMessage
136 | {
137 | public string Text
138 | {
139 | get; set;
140 | }
141 |
142 | public IIdentity Address
143 | {
144 | get; set;
145 | }
146 |
147 | public DateTime TimeStamp
148 | {
149 | get; set;
150 | }
151 | }
152 | }
153 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Specs/New_Starting_Application_Specs/ScenarioRepository.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using Rhino.Mocks;
5 | using StructureMap;
6 | using Unite.Messaging;
7 | using Unite.Messaging.Entities;
8 | using Unite.Messaging.Messages;
9 | using Unite.Messaging.Services;
10 | using Unite.UI.Utilities;
11 | using Unite.UI.ViewModels;
12 | using IServiceProvider=Unite.Messaging.Services.IServiceProvider;
13 |
14 | namespace Unite.Specs.New_Starting_Application_Specs
15 | {
16 | public class ScenarioRepository
17 | {
18 | public IInteractionContext FakeContext;
19 | public IPluginFinder FakePluginFinder;
20 | public ISettingsProvider FakeSettings;
21 | public IMessagingService FakeMessagePlugin;
22 |
23 | public ScenarioRepository()
24 | {
25 | FakeContext = MockRepository.GenerateMock();
26 | FakePluginFinder = MockRepository.GenerateMock();
27 | FakeSettings = MockRepository.GenerateMock();
28 | FakeMessagePlugin = MockRepository.GenerateMock();
29 | }
30 |
31 | public MainView GetMainView()
32 | {
33 | ContainerBootstrapper.BootstrapStructureMap(FakeContext, FakePluginFinder, FakeSettings, FakeMessagePlugin);
34 | return ObjectFactory.GetInstance();
35 | }
36 |
37 | public List GetMessages()
38 | {
39 | return new List
40 | {
41 | GetMessage(),
42 | GetMessage()
43 | };
44 | }
45 |
46 | public IMessage GetMessage()
47 | {
48 | return new Message()
49 | {
50 | Address = new Address(),
51 | Text = "Fake message",
52 | TimeStamp = DateTime.MinValue
53 | };
54 | }
55 |
56 | public Credentials CreateFakeCredentials()
57 | {
58 | return new Credentials
59 | {
60 | ServiceInformation = new ServiceInformation()
61 | {
62 | ServiceID = Guid.NewGuid(),
63 | ServiceName = "Fake"
64 | }
65 | };
66 | }
67 | }
68 |
69 | public class Address : IIdentity
70 | {
71 | public string UserName
72 | {
73 | get; set;
74 | }
75 |
76 | public ServiceInformation ServiceInfo
77 | {
78 | get; set;
79 | }
80 | }
81 |
82 | public class Message : IMessage
83 | {
84 | public string Text
85 | {
86 | get; set;
87 | }
88 |
89 | public IIdentity Address
90 | {
91 | get; set;
92 | }
93 |
94 | public DateTime TimeStamp
95 | {
96 | get; set;
97 | }
98 | }
99 |
100 | public static class ContainerBootstrapper
101 | {
102 | public static void BootstrapStructureMap(
103 | IInteractionContext gui,
104 | IPluginFinder pluginFinder,
105 | ISettingsProvider settings,
106 | IMessagingService plugin)
107 | {
108 | // Initialize the static ObjectFactory container
109 | ObjectFactory.Initialize(x =>
110 | {
111 | x.ForRequestedType().TheDefaultIsConcreteType();
112 | x.ForRequestedType().TheDefault.IsThis(gui);
113 | x.ForRequestedType().TheDefault.IsThis(plugin);
114 | x.ForRequestedType().TheDefault.IsThis(settings);
115 | x.ForRequestedType().TheDefaultIsConcreteType();
116 | x.ForRequestedType().TheDefaultIsConcreteType();
117 | x.ForRequestedType().TheDefaultIsConcreteType();
118 | x.ForRequestedType().TheDefault.IsThis(pluginFinder);
119 | });
120 | }
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Specs/TwitterServicesScope/When_sending_normal_messages.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Unite.Messaging;
6 | using Unite.Messaging.Entities;
7 | using Unite.Messaging.Messages;
8 | using Unite.UI.Utilities;
9 | using IronTwitterPlugIn;
10 | using NUnit.Framework;
11 | using SpecUnit;
12 |
13 |
14 | namespace Unite.Specs.TwitterServicesScope
15 | {
16 | [TestFixture]
17 | public class When_sending_a_large_message_with_no_recipient : context
18 | {
19 | [Test]
20 | public void It_should_not_be_broken_up_into_multiple_messages()
21 | {
22 | DataAccess.MessagesSent.ShouldEqual(1);
23 | }
24 |
25 | [Test]
26 | public void It_clips_each_message_to_be_at_or_below_the_max_message_length()
27 | {
28 | DataAccess.SentMessages.ForEach(message => message.Length.ShouldBeLessThan(MaxMessageLength + 1));
29 | }
30 |
31 | protected string Recipient = null;
32 |
33 | protected override void Because()
34 | {
35 | Utilities.SendMessage(
36 | new TestSender()
37 | {
38 | UserName = Recipient
39 | },
40 | "This is a test message from");
41 | }
42 |
43 | protected override void Context()
44 | {
45 | }
46 | }
47 |
48 | public class TestSender : IIdentity
49 | {
50 | public string UserName { get; set; }
51 |
52 | public ServiceInformation ServiceInfo
53 | {
54 | get; set;
55 | }
56 | }
57 |
58 | [TestFixture]
59 | public class When_sending_a_large_message_with_recipient_first_time : context
60 | {
61 | [Test]
62 | public void It_should_request_user_credentials()
63 | {
64 | CredentialsRequested.ShouldBeTrue();
65 | }
66 |
67 | [Test]
68 | public void It_should_not_be_broken_up_into_multiple_messages()
69 | {
70 | DataAccess.MessagesSent.ShouldEqual(1);
71 | }
72 |
73 | [Test]
74 | public void It_includes_the_recipient_in_the_message()
75 | {
76 | DataAccess.SentMessages.ForEach(message => message.Contains(Recipient).ShouldBeTrue());
77 | }
78 |
79 | [Test]
80 | public void It_clips_each_message_to_be_at_or_below_the_max_message_length()
81 | {
82 | DataAccess.SentMessages.ForEach(message => message.Length.ShouldBeLessThan(MaxMessageLength + 1));
83 | }
84 |
85 | protected string Recipient = "@ChadBoyer";
86 |
87 | protected override void Because()
88 | {
89 | Utilities.SendMessage(
90 | new FakeRecipient(){UserName = Recipient},
91 | "This is a test message from");
92 | }
93 |
94 | protected override void Context()
95 | {
96 | }
97 | }
98 |
99 | public class FakeRecipient : IIdentity
100 | {
101 | public string UserName { get; set; }
102 | public ServiceInformation ServiceInfo { get; set; }
103 | }
104 |
105 | [TestFixture]
106 | public abstract class context
107 | {
108 | protected TwitterUtilities Utilities;
109 | protected TestTwitterDataAccess DataAccess;
110 | protected readonly int MaxMessageLength = 140;
111 | protected bool CredentialsRequested;
112 |
113 | [TestFixtureSetUp]
114 | public void Setup()
115 | {
116 | DataAccess = new TestTwitterDataAccess();
117 | Utilities = new TwitterUtilities(DataAccess, MaxMessageLength);
118 | Utilities.CredentialsRequested += Utilities_CredentialsRequested;
119 |
120 | Context();
121 | Because();
122 | }
123 |
124 | void Utilities_CredentialsRequested(object sender, CredentialEventArgs e)
125 | {
126 | CredentialsRequested = true;
127 | }
128 |
129 | protected abstract void Because();
130 |
131 | protected abstract void Context();
132 | }
133 |
134 | public class TestTwitterDataAccess : ITwitterDataAccess
135 | {
136 | public int MessagesSent;
137 | public List SentMessages;
138 |
139 | public TestTwitterDataAccess()
140 | {
141 | SentMessages = new List();
142 | }
143 |
144 | public string SendMessage(Credentials credentials, string message)
145 | {
146 | MessagesSent++;
147 | SentMessages.Add(message);
148 | return "result message";
149 | }
150 |
151 | public string GetMessages(Credentials credentials)
152 | {
153 | return "result message";
154 | }
155 | }
156 | }
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Plug Ins/GoogleTalkPlugIn/GoogleTalkMessagingService.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using jabber.client;
6 | using jabber.protocol.client;
7 | using Unite.Messaging;
8 | using Unite.Messaging.Entities;
9 | using Unite.Messaging.Messages;
10 | using Unite.Messaging.Services;
11 |
12 | namespace GoogleTalkPlugIn
13 | {
14 | public class GoogleTalkMessagingService : IMessagingService
15 | {
16 | private readonly GoogleTalkDataAccess _DataAccess;
17 |
18 | private Credentials _Credentials;
19 | private readonly CredentialEventArgs _CredEventArgs;
20 |
21 | private static readonly ServiceInformation _ServiceInformation = new ServiceInformation()
22 | {
23 | ServiceID = Guid.NewGuid(),
24 | ServiceName = "GoogleTalk"
25 | };
26 |
27 | public GoogleTalkMessagingService()
28 | {
29 | _CredEventArgs = new CredentialEventArgs()
30 | {
31 | ServiceInfo = _ServiceInformation
32 | };
33 |
34 | _DataAccess = new GoogleTalkDataAccess();
35 | _DataAccess.OnMessage += _DataAccess_OnMessage;
36 | _DataAccess.OnAuthError += _DataAccess_OnAuthError;
37 | }
38 |
39 | void _DataAccess_OnAuthError(object sender, EventArgs e)
40 | {
41 | if (AuthorizationFailed != null)
42 | AuthorizationFailed(this, _CredEventArgs);
43 | }
44 |
45 | void _DataAccess_OnMessage(object sender, GTalkMessageEventArgs e)
46 | {
47 | _ReceiveMessage(e.User ?? _Credentials.UserName, e.Message);
48 | }
49 |
50 | private void _ReceiveMessage(string username, string message)
51 | {
52 | var user = new GTalkUser()
53 | {
54 | ServiceInfo = _ServiceInformation,
55 | UserName = username
56 | };
57 | var messageReceived = new GTalkMessage()
58 | {
59 | Address = user,
60 | Text = message
61 | };
62 | if (MessagesReceived != null)
63 | MessagesReceived(
64 | this,
65 | new MessagesReceivedEventArgs(new[] { messageReceived }));
66 | }
67 |
68 | public bool CanAccept(Credentials credentials)
69 | {
70 | return credentials.ServiceInformation == _ServiceInformation;
71 | }
72 |
73 | public List GetMessages()
74 | {
75 | return new List();
76 | }
77 |
78 | public void SendMessage(IIdentity recipient, string message)
79 | {
80 | _AuthenticateIfNeeded();
81 |
82 | if(_Credentials == null)
83 | throw new Exception("Your credentials can not still be null. This should NEVER happen.");
84 |
85 | var realUsername = !recipient.UserName.ToLowerInvariant().EndsWith("@gmail.com")
86 | ? recipient.UserName + "@gmail.com"
87 | : recipient.UserName;
88 |
89 | _DataAccess.Message(realUsername, message);
90 | }
91 |
92 | public void SetCredentials(Credentials credentials)
93 | {
94 | _Credentials = credentials;
95 | }
96 |
97 | public bool CanFind(string address)
98 | {
99 | // If the address contains an ampersand it can't start with it
100 | // or it just shouldn't have one at all.
101 | return address != null &&
102 | address.Trim() != String.Empty &&
103 | (
104 | (
105 | (!address.StartsWith("@") && address.Contains("@")
106 | ) ||
107 | !address.Contains("@"))
108 | );
109 | }
110 |
111 | public ServiceInformation GetInformation()
112 | {
113 | return _ServiceInformation;
114 | }
115 |
116 | public void StartReceiving()
117 | {
118 | _AuthenticateIfNeeded();
119 | }
120 |
121 | private void _AuthenticateIfNeeded()
122 | {
123 | if(!_DataAccess.IsConnected)
124 | {
125 | if (CredentialsRequested != null)
126 | CredentialsRequested(this, _CredEventArgs);
127 | _DataAccess.Login(_Credentials.UserName, _Credentials.Password);
128 | }
129 | }
130 |
131 | public void StopReceiving()
132 | {
133 | _DataAccess.Logoff();
134 | }
135 |
136 | public event EventHandler AuthorizationFailed;
137 | public event EventHandler CredentialsRequested;
138 | public event EventHandler MessagesReceived;
139 | }
140 | }
141 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Specs/Application_running/Context.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using IronTwitterPlugIn.DataObjects;
4 | using StructureMap;
5 | using Unite.Messaging;
6 | using Unite.Messaging.Entities;
7 | using Unite.Messaging.Messages;
8 | using Unite.Messaging.Services;
9 | using Unite.UI.Utilities;
10 | using IIdentity=Unite.Messaging.IIdentity;
11 | using IInteractionContext=Unite.Messaging.IInteractionContext;
12 | using IMessagingServiceManager=Unite.Messaging.IMessagingServiceManager;
13 |
14 | namespace Unite.Specs.Application_running
15 | {
16 | public class TestTwitterUtilities : IMessagingServiceManager
17 | {
18 | public Guid ServiceId { get { return Guid.NewGuid(); } }
19 | public string ServiceName { get { return "TestTwitter"; } }
20 |
21 | public Credentials Credentials;
22 | public string Message;
23 | public string Recipient;
24 |
25 | public int _Counter;
26 |
27 | public bool CanAccept(Credentials credentials)
28 | {
29 | return true;
30 | }
31 |
32 | public List GetMessages()
33 | {
34 | Credentials = new Credentials() { UserName = "username", Password = "password" };
35 |
36 | _Counter++;
37 |
38 | return _Counter == 1
39 | ? new List()
40 | {
41 | new Tweet() {
42 | Text = "testing",
43 | Address = new FakeUser() {UserName = "darkxanthos"},
44 | TimeStamp = DateTime.Now
45 | }
46 | }
47 | : new List();
48 | }
49 |
50 | public void SendMessage(IIdentity recipient, string message)
51 | {
52 | Credentials = new Credentials() { UserName = "username", Password = "password" };
53 | Message = message;
54 | Recipient = recipient.UserName;
55 | }
56 |
57 | public void SetCredentials(Credentials credentials)
58 | {
59 | Credentials = credentials;
60 | }
61 |
62 | public event EventHandler CredentialsRequested;
63 | public event EventHandler AuthorizationFailed;
64 |
65 | public bool CanFind(string address)
66 | {
67 | return true;
68 | }
69 |
70 | public ServiceInformation GetInformation()
71 | {
72 | return new ServiceInformation();
73 | }
74 |
75 | public void StartReceiving()
76 | {
77 | if(MessagesReceived != null)
78 | MessagesReceived(this, new MessagesReceivedEventArgs(new []
79 | {
80 | new Message()
81 | {
82 | Text = "Message",
83 | Address = new Identity("yada yada", GetInformation()),
84 | TimeStamp = DateTime.Now
85 | }
86 | }));
87 | }
88 |
89 | public void StopReceiving()
90 | {
91 |
92 | }
93 |
94 | public event EventHandler MessagesReceived;
95 |
96 | public void SendMessage(string recipient, string message)
97 | {
98 | Message = message;
99 | Recipient = recipient;
100 | }
101 | }
102 | public class FakeUser : IIdentity
103 | {
104 | public string UserName { get; set; }
105 | public ServiceInformation ServiceInfo { get; set; }
106 | }
107 | public class TestingInteractionContext : IInteractionContext
108 | {
109 | public Credentials GetCredentials(IServiceInformation serviceInformation)
110 | {
111 | return new Credentials()
112 | {
113 | UserName = "username",
114 | Password = "password",
115 | ServiceInformation = serviceInformation
116 | };
117 | }
118 |
119 | public bool AuthenticationFailedRetryQuery()
120 | {
121 | return false;
122 | }
123 | }
124 |
125 | public static class ContainerBootstrapper
126 | {
127 |
128 | public static void BootstrapStructureMap()
129 | {
130 |
131 | // Initialize the static ObjectFactory container
132 |
133 | ObjectFactory.Initialize(x =>
134 | {
135 | x.ForRequestedType().TheDefaultIsConcreteType();
136 | x.ForRequestedType().TheDefaultIsConcreteType();
137 | x.ForRequestedType().TheDefaultIsConcreteType();
138 | });
139 |
140 | }
141 |
142 | }
143 | }
144 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/UI/Controls/MessageTextView.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Data;
9 | using System.Windows.Documents;
10 | using System.Windows.Input;
11 | using System.Windows.Media;
12 | using System.Windows.Media.Imaging;
13 | using System.Windows.Navigation;
14 | using System.Windows.Shapes;
15 |
16 | namespace Unite.UI.Controls
17 | {
18 | ///
19 | /// Follow steps 1a or 1b and then 2 to use this custom control in a XAML file.
20 | ///
21 | /// Step 1a) Using this custom control in a XAML file that exists in the current project.
22 | /// Add this XmlNamespace attribute to the root element of the markup file where it is
23 | /// to be used:
24 | ///
25 | /// xmlns:MyNamespace="clr-namespace:Unite.UI.Views"
26 | ///
27 | ///
28 | /// Step 1b) Using this custom control in a XAML file that exists in a different project.
29 | /// Add this XmlNamespace attribute to the root element of the markup file where it is
30 | /// to be used:
31 | ///
32 | /// xmlns:MyNamespace="clr-namespace:Unite.UI.Views;assembly=Unite.UI.Views"
33 | ///
34 | /// You will also need to add a project reference from the project where the XAML file lives
35 | /// to this project and Rebuild to avoid compilation errors:
36 | ///
37 | /// Right click on the target project in the Solution Explorer and
38 | /// "Add Reference"->"Projects"->[Browse to and select this project]
39 | ///
40 | ///
41 | /// Step 2)
42 | /// Go ahead and use your control in the XAML file.
43 | ///
44 | ///
45 | ///
46 | ///
47 | [TemplatePart(Type=typeof(TextBlock), Name=NAME_PART_MESSAGE_TEXT)]
48 | public class MessageTextView : ContentControl
49 | {
50 | private const string NAME_PART_MESSAGE_TEXT = "PART_MessageText";
51 |
52 | protected TextBlock MessageText;
53 |
54 | static MessageTextView()
55 | {
56 | DefaultStyleKeyProperty.OverrideMetadata(typeof(MessageTextView), new FrameworkPropertyMetadata(typeof(MessageTextView)));
57 | }
58 |
59 | public override void OnApplyTemplate()
60 | {
61 | base.OnApplyTemplate();
62 |
63 | MessageText = (TextBlock) GetTemplateChild(NAME_PART_MESSAGE_TEXT);
64 |
65 | SetMessageText((string) Content);
66 | }
67 |
68 | protected override void OnContentChanged(object oldContent, object newContent)
69 | {
70 | base.OnContentChanged(oldContent, newContent);
71 |
72 | if (MessageText == null)
73 | return;
74 |
75 | SetMessageText((string) Content);
76 | }
77 |
78 | private List _hyperlinks = new List();
79 | private void SetMessageText(string messageText)
80 | {
81 | ClearHyperlinks();
82 | MessageText.Inlines.Clear();
83 |
84 | if (messageText == null)
85 | messageText = "";
86 |
87 | var inlineUris = Utilities.InlineUris.Get(messageText);
88 | var charIndex = 0;
89 | foreach (var inlineUri in inlineUris)
90 | {
91 | if (inlineUri.StartIndex > charIndex)
92 | {
93 | //add text before link
94 | var run = new Run(messageText.Substring(charIndex, inlineUri.StartIndex - charIndex));
95 | MessageText.Inlines.Add(run);
96 | charIndex += run.Text.Length;
97 | }
98 |
99 | //add Hyperlink
100 | var hyperlink = new Hyperlink();
101 | var displayRun = new Run(messageText.Substring(inlineUri.StartIndex, inlineUri.Length));
102 | hyperlink.Inlines.Add(displayRun);
103 | hyperlink.NavigateUri = new Uri(displayRun.Text);
104 | ListenToHyperlink(hyperlink, true);
105 | MessageText.Inlines.Add(hyperlink);
106 | charIndex += inlineUri.Length;
107 | }
108 |
109 | if (charIndex < messageText.Length)
110 | {
111 | //add text at end
112 | var run = new Run(messageText.Substring(charIndex));
113 | MessageText.Inlines.Add(run);
114 | }
115 | }
116 |
117 | private void ClearHyperlinks()
118 | {
119 | foreach (var hyperlink in _hyperlinks)
120 | {
121 | ListenToHyperlink(hyperlink, false);
122 | }
123 | }
124 |
125 | private void ListenToHyperlink(Hyperlink hyperlink, bool listen)
126 | {
127 | if (hyperlink == null)
128 | throw new ArgumentNullException("hyperlink");
129 |
130 | if (listen)
131 | {
132 | hyperlink.Click += hyperlink_Click;
133 | }
134 | else
135 | {
136 | hyperlink.Click -= hyperlink_Click;
137 | }
138 | }
139 |
140 | void hyperlink_Click(object sender, RoutedEventArgs e)
141 | {
142 | var hyperlink = (Hyperlink) sender;
143 | Process.Start(hyperlink.NavigateUri.ToString());
144 | }
145 | }
146 | }
147 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/UI/Views/MainView.xaml:
--------------------------------------------------------------------------------
1 |
14 |
15 | 20
16 | 20
17 | 25
18 | 15
19 | 15,0
20 |
21 |
22 |
23 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
46 |
53 |
54 |
55 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/UI/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Specs/Starting_Application/User_enters_wrong_password_when_prompted.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Net;
4 | using Unite.Messaging.Entities;
5 | using Unite.Messaging.Messages;
6 | using Unite.Messaging.Services;
7 | using Unite.UI.Utilities;
8 | using Unite.UI.ViewModels;
9 | using NUnit.Framework;
10 | using SpecUnit;
11 | using StructureMap;
12 | using Unite.Messaging;
13 |
14 | namespace Unite.Specs.Starting_Application
15 | {
16 | [TestFixture]
17 | public class When_wrong_credentials_are_provided_to_the_app : context
18 | {
19 | [Test]
20 | public void It_should_tell_the_user_and_ask_if_the_user_wants_to_try_again()
21 | {
22 | InteractionContext.IsUserNotifiedOfAuthenticationFailure.ShouldBeTrue();
23 | }
24 |
25 | protected override void Because()
26 | {
27 | Model.Init();
28 | }
29 |
30 | protected FakeInteractionContext InteractionContext;
31 |
32 | protected override void Context()
33 | {
34 | InteractionContext = new FakeInteractionContext();
35 |
36 | ObjectFactory.EjectAllInstancesOf();
37 | ObjectFactory.Inject(InteractionContext);
38 |
39 | Model = ObjectFactory.GetInstance();
40 | }
41 | }
42 |
43 | [TestFixture]
44 | public abstract class context
45 | {
46 | protected MainView Model;
47 | protected TestTwitterUtilities Utilities;
48 |
49 | protected bool Message_was_sent
50 | {
51 | get;
52 | set;
53 | }
54 |
55 |
56 | [TestFixtureSetUp]
57 | public void Setup()
58 | {
59 | ContainerBootstrapper.BootstrapStructureMap();
60 |
61 | Utilities = new TestTwitterUtilities();
62 | ObjectFactory.EjectAllInstancesOf();
63 | ObjectFactory.Inject(Utilities);
64 |
65 | Context();
66 | Because();
67 | }
68 |
69 | protected abstract void Because();
70 |
71 | protected abstract void Context();
72 | }
73 |
74 | public class FakeInteractionContext : IInteractionContext
75 | {
76 | public bool IsUserNotifiedOfAuthenticationFailure;
77 |
78 | public Credentials GetCredentials(IServiceInformation serviceInformation)
79 | {
80 | throw new System.NotImplementedException();
81 | }
82 |
83 | public bool AuthenticationFailedRetryQuery()
84 | {
85 | IsUserNotifiedOfAuthenticationFailure = true;
86 | return false;
87 | }
88 | }
89 |
90 | public class TestTwitterUtilities : IMessagingServiceManager
91 | {
92 | public Guid ServiceId { get { return Guid.NewGuid(); } }
93 | public string ServiceName { get { return "TestTwitter"; } }
94 |
95 | public Credentials Credentials;
96 | public string Message;
97 | public string Recipient;
98 |
99 | public bool CanAccept(Credentials credentials)
100 | {
101 | return true;
102 | }
103 |
104 | public List GetMessages()
105 | {
106 | var firstCredentials = new Credentials() { UserName = "username", Password = "password" };
107 | Credentials = firstCredentials;
108 |
109 | AuthorizationFailed(this, new CredentialEventArgs(){ServiceInfo = new ServiceInformation(){ServiceID = ServiceId, ServiceName = ServiceName}});
110 |
111 | return new List();
112 | }
113 |
114 | public void SendMessage(IIdentity recipient, string message)
115 | {
116 | Credentials = new Credentials() { UserName = "username", Password = "password" };
117 | Message = message;
118 | Recipient = recipient.UserName;
119 | }
120 |
121 | public void SetCredentials(Credentials credentials)
122 | {
123 | Credentials = credentials;
124 | }
125 |
126 | public event EventHandler CredentialsRequested;
127 | public event EventHandler AuthorizationFailed;
128 |
129 | public bool CanFind(string address)
130 | {
131 | throw new System.NotImplementedException();
132 | }
133 |
134 | public ServiceInformation GetInformation()
135 | {
136 | throw new System.NotImplementedException();
137 | }
138 |
139 | public void StartReceiving()
140 | {
141 | MessagesReceived(this, new MessagesReceivedEventArgs(GetMessages()));
142 | }
143 |
144 | public void StopReceiving()
145 | {
146 | throw new System.NotImplementedException();
147 | }
148 |
149 | public event EventHandler MessagesReceived;
150 |
151 | public void SendMessage(string recipient, string message)
152 | {
153 | Recipient = recipient;
154 | Message = message;
155 | }
156 | }
157 |
158 | public class TestingInteractionContext : IInteractionContext
159 | {
160 | public Credentials GetCredentials(IServiceInformation serviceInformation)
161 | {
162 | throw new WebException("Authentication failure");
163 | }
164 |
165 | public bool AuthenticationFailedRetryQuery()
166 | {
167 | return false;
168 | }
169 | }
170 |
171 | public static class ContainerBootstrapper
172 | {
173 |
174 | public static void BootstrapStructureMap()
175 | {
176 |
177 | // Initialize the static ObjectFactory container
178 |
179 | ObjectFactory.Initialize(x =>
180 | {
181 | x.ForRequestedType().TheDefaultIsConcreteType();
182 | x.ForRequestedType().TheDefaultIsConcreteType();
183 | x.ForRequestedType().TheDefaultIsConcreteType();
184 | });
185 |
186 | }
187 |
188 | }
189 |
190 | }
191 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Specs/Utilities/SpecUnit.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using NUnit.Framework;
4 |
5 | namespace SpecUnit
6 | {
7 | public delegate void MethodThatThrows();
8 |
9 | public static class SpecificationExtensions
10 | {
11 | public static void Is(this object expected)
12 | {
13 | expected.ShouldBeOfType(typeof(T));
14 | }
15 |
16 | public static void ShouldBeFalse(this bool condition)
17 | {
18 | Assert.IsFalse(condition);
19 | }
20 |
21 | public static void ShouldBeTrue(this bool condition)
22 | {
23 | Assert.IsTrue(condition);
24 | }
25 |
26 | public static object ShouldEqual(this object actual, object expected)
27 | {
28 | Assert.AreEqual(expected, actual);
29 | return expected;
30 | }
31 |
32 | public static object ShouldNotEqual(this object actual, object expected)
33 | {
34 | Assert.AreNotEqual(expected, actual);
35 | return expected;
36 | }
37 |
38 | public static void ShouldBeNull(this object anObject)
39 | {
40 | Assert.IsNull(anObject);
41 | }
42 |
43 | public static void ShouldNotBeNull(this object anObject)
44 | {
45 | Assert.IsNotNull(anObject);
46 | }
47 |
48 | public static object ShouldBeTheSameAs(this object actual, object expected)
49 | {
50 | Assert.AreSame(expected, actual);
51 | return expected;
52 | }
53 |
54 | public static object ShouldNotBeTheSameAs(this object actual, object expected)
55 | {
56 | Assert.AreNotSame(expected, actual);
57 | return expected;
58 | }
59 |
60 | public static void ShouldBeOfType(this object actual, Type expected)
61 | {
62 | Assert.IsInstanceOfType(expected, actual);
63 | }
64 |
65 | public static void ShouldBe(this object actual, Type expected)
66 | {
67 | Assert.IsInstanceOfType(expected, actual);
68 | }
69 |
70 | public static void ShouldNotBeOfType(this object actual, Type expected)
71 | {
72 | Assert.IsNotInstanceOfType(expected, actual);
73 | }
74 |
75 | public static void ShouldContain(this IList actual, object expected)
76 | {
77 | Assert.Contains(expected, actual);
78 | }
79 |
80 | public static void ShouldNotContain(this IList collection, object expected)
81 | {
82 | CollectionAssert.DoesNotContain(collection, expected);
83 | }
84 |
85 | public static IComparable ShouldBeGreaterThan(this IComparable arg1, IComparable arg2)
86 | {
87 | Assert.Greater(arg1, arg2);
88 | return arg2;
89 | }
90 |
91 | public static IComparable ShouldBeLessThan(this IComparable arg1, IComparable arg2)
92 | {
93 | Assert.Less(arg1, arg2);
94 | return arg2;
95 | }
96 |
97 | public static void ShouldBeEmpty(this ICollection collection)
98 | {
99 | Assert.IsEmpty(collection);
100 | }
101 |
102 | public static void ShouldBeEmpty(this string aString)
103 | {
104 | Assert.IsEmpty(aString);
105 | }
106 |
107 | public static void ShouldNotBeEmpty(this ICollection collection)
108 | {
109 | Assert.IsNotEmpty(collection);
110 | }
111 |
112 | public static void ShouldNotBeEmpty(this string aString)
113 | {
114 | Assert.IsNotEmpty(aString);
115 | }
116 |
117 | public static void ShouldContain(this string actual, string expected)
118 | {
119 | StringAssert.Contains(expected, actual);
120 | }
121 |
122 | public static void ShouldNotContain(this string actual, string expected)
123 | {
124 | try
125 | {
126 | StringAssert.Contains(expected, actual);
127 | }
128 | catch (AssertionException)
129 | {
130 | return;
131 | }
132 |
133 | throw new AssertionException(String.Format("\"{0}\" should not contain \"{1}\".", actual, expected));
134 | }
135 |
136 | public static string ShouldBeEqualIgnoringCase(this string actual, string expected)
137 | {
138 | StringAssert.AreEqualIgnoringCase(expected, actual);
139 | return expected;
140 | }
141 |
142 | public static void ShouldStartWith(this string actual, string expected)
143 | {
144 | StringAssert.StartsWith(expected, actual);
145 | }
146 |
147 | public static void ShouldEndWith(this string actual, string expected)
148 | {
149 | StringAssert.EndsWith(expected, actual);
150 | }
151 |
152 | public static void ShouldBeSurroundedWith(this string actual, string expectedStartDelimiter, string expectedEndDelimiter)
153 | {
154 | StringAssert.StartsWith(expectedStartDelimiter, actual);
155 | StringAssert.EndsWith(expectedEndDelimiter, actual);
156 | }
157 |
158 | public static void ShouldBeSurroundedWith(this string actual, string expectedDelimiter)
159 | {
160 | StringAssert.StartsWith(expectedDelimiter, actual);
161 | StringAssert.EndsWith(expectedDelimiter, actual);
162 | }
163 |
164 | public static void ShouldContainErrorMessage(this Exception exception, string expected)
165 | {
166 | StringAssert.Contains(expected, exception.Message);
167 | }
168 |
169 | public static Exception ShouldBeThrownBy(this Type exceptionType, MethodThatThrows method)
170 | {
171 | Exception exception = method.GetException();
172 |
173 | Assert.IsNotNull(exception);
174 | Assert.AreEqual(exceptionType, exception.GetType());
175 |
176 | return exception;
177 | }
178 |
179 | public static Exception GetException(this MethodThatThrows method)
180 | {
181 | Exception exception = null;
182 |
183 | try
184 | {
185 | method();
186 | }
187 | catch (Exception e)
188 | {
189 | exception = e;
190 | }
191 |
192 | return exception;
193 | }
194 | }
195 | }
196 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Specs/Contacts/When_receiving_messages_with_known_contacts.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using IronTwitterPlugIn.DataObjects;
6 | using NUnit.Framework;
7 | using SpecUnit;
8 | using StructureMap;
9 | using Unite.Messaging;
10 | using Unite.Messaging.Entities;
11 | using Unite.Messaging.Messages;
12 | using Unite.Messaging.Services;
13 | using Unite.UI.Utilities;
14 | using Unite.UI.ViewModels;
15 |
16 | namespace Unite.Specs.Contacts
17 | {
18 | [TestFixture]
19 | public class When_receiving_a_message_with_an_unknown_contact : contacts_context
20 | {
21 | [Test]
22 | public void It_should_have_the_name_be_the_same_as_the_username()
23 | {
24 | ViewModel.Messages.First().Contact.Name.ShouldEqual("darkxanthos");
25 | }
26 |
27 | protected override void Because()
28 | {
29 | ViewModel.ReceiveMessage.Execute(null);
30 | }
31 |
32 | protected override void Context()
33 | {
34 | TheContactProvider.Clear();
35 | }
36 | }
37 |
38 | [TestFixture]
39 | public class When_receiving_a_message_with_a_known_contact : contacts_context
40 | {
41 | [Test]
42 | public void Its_name_should_appear_in_message_list()
43 | {
44 | ViewModel.Messages.First().Contact.Name.ShouldEqual("Justin Bozonier");
45 | }
46 |
47 | protected override void Because()
48 | {
49 | ViewModel.ReceiveMessage.Execute(null);
50 | }
51 |
52 | protected override void Context()
53 | {
54 |
55 | }
56 | }
57 |
58 | public abstract class contacts_context
59 | {
60 | protected MainView ViewModel;
61 | protected FakeMessagingService ServiceManager;
62 | protected ContactProvider TheContactProvider;
63 |
64 | [TestFixtureSetUp]
65 | public void Setup()
66 | {
67 | var serviceInfo = new ServiceInformation()
68 | {
69 | ServiceID = Guid.NewGuid(),
70 | ServiceName = "test service"
71 | };
72 |
73 | ServiceManager = new FakeMessagingService(serviceInfo);
74 | TheContactProvider = new ContactProvider();
75 |
76 | TheContactProvider.Add(new Contact()
77 | {
78 | Name = "Justin Bozonier",
79 | ContactId = Guid.NewGuid(),
80 | Identities = new[]{new Identity("darkxanthos", serviceInfo)}
81 | });
82 |
83 | ObjectFactory.Initialize(x =>
84 | {
85 | x.ForRequestedType().TheDefaultIsConcreteType();
86 | x.ForRequestedType().TheDefaultIsConcreteType();
87 | x.ForRequestedType().TheDefault.IsThis(ServiceManager);
88 | x.ForRequestedType().TheDefault.IsThis(TheContactProvider);
89 | });
90 |
91 | ViewModel = ObjectFactory.GetInstance();
92 |
93 | Context();
94 | Because();
95 | }
96 |
97 | protected abstract void Because();
98 |
99 | protected abstract void Context();
100 | }
101 |
102 | public class TestingInterface : IInteractionContext
103 | {
104 | public Credentials GetCredentials(IServiceInformation serviceInformation)
105 | {
106 | return new Credentials()
107 | {
108 | Password = "password",
109 | UserName = "username",
110 | ServiceInformation = serviceInformation
111 | };
112 | }
113 |
114 | public bool AuthenticationFailedRetryQuery()
115 | {
116 | throw new System.NotImplementedException();
117 | }
118 | }
119 |
120 | public class FakeMessage : IMessage
121 | {
122 | public string Text { get; set; }
123 | public IIdentity Address { get; set; }
124 | public DateTime TimeStamp
125 | {
126 | get; set;
127 | }
128 | }
129 |
130 | public class FakeMessagingService : IMessagingServiceManager
131 | {
132 | public ServiceInformation ServiceInfo;
133 | private ServiceInformation _Information;
134 |
135 | public FakeMessagingService(ServiceInformation info)
136 | {
137 | _Information = info;
138 | }
139 |
140 | public bool CanAccept(Credentials credentials)
141 | {
142 | throw new System.NotImplementedException();
143 | }
144 |
145 | public List GetMessages()
146 | {
147 | return new List()
148 | {
149 | new FakeMessage()
150 | {
151 | Text = "message text",
152 | Address = new Identity("darkxanthos", _Information)
153 | }
154 | };
155 | }
156 |
157 | public void SendMessage(IIdentity recipient, string message)
158 | {
159 | throw new System.NotImplementedException();
160 | }
161 |
162 | public void SetCredentials(Credentials credentials)
163 | {
164 | throw new System.NotImplementedException();
165 | }
166 |
167 | public event EventHandler CredentialsRequested;
168 | public event EventHandler AuthorizationFailed;
169 |
170 | public bool CanFind(string address)
171 | {
172 | throw new System.NotImplementedException();
173 | }
174 |
175 | public ServiceInformation GetInformation()
176 | {
177 | throw new System.NotImplementedException();
178 | }
179 |
180 | public void StartReceiving()
181 | {
182 | throw new System.NotImplementedException();
183 | }
184 |
185 | public void StopReceiving()
186 | {
187 | throw new System.NotImplementedException();
188 | }
189 |
190 | public event EventHandler MessagesReceived;
191 |
192 | public void SendMessage(string recipient, string message)
193 | {
194 | throw new System.NotImplementedException();
195 | }
196 | }
197 | }
198 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Specs/Starting_Application/Start_application_send_message_spec.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using Unite.Messaging.Entities;
6 | using Unite.Messaging.Messages;
7 | using Unite.Messaging.Services;
8 | using Unite.UI.Utilities;
9 | using Unite.UI.ViewModels;
10 | using IronTwitterPlugIn;
11 | using NUnit.Framework;
12 | using SpecUnit;
13 | using StructureMap;
14 | using Bound.Net;
15 | using StructureMap.Pipeline;
16 | using Unite.Messaging;
17 |
18 | namespace Unite.Specs.Application_starting.Sending_messages
19 | {
20 | [TestFixture]
21 | public class When_user_requests_to_send_message : context
22 | {
23 | [Test]
24 | public void It_should_be_sent()
25 | {
26 | Utilities.Message.ShouldNotBeNull();
27 | }
28 |
29 | [Test]
30 | public void It_should_update_the_UI_with_the_new_data()
31 | {
32 | UIUpdated.ShouldBeTrue();
33 | }
34 |
35 | [Test]
36 | public void It_should_use_the_correct_user_name()
37 | {
38 | Utilities.Credentials.UserName.ShouldNotBeNull();
39 | }
40 |
41 | [Test]
42 | public void It_should_use_the_correct_password()
43 | {
44 | Utilities.Credentials.Password.ShouldNotBeEmpty();
45 | }
46 |
47 | [Test]
48 | public void It_should_be_able_to_send_the_message()
49 | {
50 | Model.SendMessage.CanExecute(null).ShouldBeTrue();
51 | }
52 |
53 | [Test]
54 | public void It_should_match_the_one_provided_by_the_user()
55 | {
56 | Utilities.Message.ShouldEqual(MessageSent);
57 | }
58 |
59 | [Test]
60 | public void It_should_be_sent_to_the_correct_recipient()
61 | {
62 | Utilities.Recipient.ShouldEqual(Recipient);
63 | }
64 |
65 | [Test]
66 | public void It_should_clear_the_recipient_field()
67 | {
68 | Model.Recipient.ShouldEqual("");
69 | }
70 |
71 | [Test]
72 | public void It_should_clear_the_message_field()
73 | {
74 | Model.MessageToSend.ShouldEqual("");
75 | }
76 |
77 | protected override void Because()
78 | {
79 | Model.SendMessage.Execute(null);
80 | }
81 |
82 | private string MessageSent;
83 | private string Recipient;
84 | protected bool UIUpdated;
85 |
86 | protected override void Context()
87 | {
88 | Model.Init();
89 | Model.PropertyChanged += (s, e) => UIUpdated = true;
90 | Model.MessageToSend = MessageSent = "This is my message.";
91 | Model.Recipient = Recipient = "@testuser";
92 | }
93 | }
94 |
95 | [TestFixture]
96 | public abstract class context
97 | {
98 | protected MainView Model;
99 | protected TestTwitterUtilities Utilities;
100 |
101 | protected bool Message_was_sent
102 | {
103 | get; set;
104 | }
105 |
106 |
107 | [TestFixtureSetUp]
108 | public void Setup()
109 | {
110 | ContainerBootstrapper.BootstrapStructureMap();
111 |
112 | Utilities = new TestTwitterUtilities();
113 |
114 | ObjectFactory.EjectAllInstancesOf();
115 | ObjectFactory.Inject(Utilities);
116 |
117 | Model = ObjectFactory.GetInstance();
118 | Context();
119 | Because();
120 | }
121 |
122 | protected abstract void Because();
123 |
124 | protected abstract void Context();
125 | }
126 |
127 | public class TestTwitterUtilities : IMessagingServiceManager
128 | {
129 | public Guid ServiceId { get { return Guid.NewGuid(); } }
130 | public string ServiceName { get { return "TestTwitter"; } }
131 |
132 | public Credentials Credentials;
133 | public string Message;
134 | public string Recipient;
135 |
136 | public bool CanAccept(Credentials credentials)
137 | {
138 | return true;
139 | }
140 |
141 | public List GetMessages()
142 | {
143 | Credentials = new Credentials() { UserName = "username", Password = "password" };
144 |
145 | return new List();
146 | }
147 |
148 | public void SendMessage(IIdentity recipient, string message)
149 | {
150 | Credentials = new Credentials() { UserName = "username", Password = "password" };
151 | Message = message;
152 | Recipient = recipient.UserName;
153 | }
154 |
155 | public void SetCredentials(Credentials credentials)
156 | {
157 | Credentials = credentials;
158 | }
159 |
160 | public event EventHandler CredentialsRequested;
161 | public event EventHandler AuthorizationFailed;
162 |
163 | public bool CanFind(string address)
164 | {
165 | throw new System.NotImplementedException();
166 | }
167 |
168 | public ServiceInformation GetInformation()
169 | {
170 | throw new System.NotImplementedException();
171 | }
172 |
173 | public void StartReceiving()
174 | {
175 |
176 | }
177 |
178 | public void StopReceiving()
179 | {
180 | throw new System.NotImplementedException();
181 | }
182 |
183 | public event EventHandler MessagesReceived;
184 |
185 | public void SendMessage(string recipient, string message)
186 | {
187 | Message = message;
188 | Recipient = recipient;
189 | }
190 | }
191 |
192 | public class TestingInteractionContext : IInteractionContext
193 | {
194 | public Credentials GetCredentials(IServiceInformation serviceInformation)
195 | {
196 | throw new System.NotImplementedException();
197 | }
198 |
199 | public bool AuthenticationFailedRetryQuery()
200 | {
201 | return false;
202 | }
203 | }
204 |
205 | public static class ContainerBootstrapper
206 | {
207 |
208 | public static void BootstrapStructureMap()
209 | {
210 |
211 | // Initialize the static ObjectFactory container
212 |
213 | ObjectFactory.Initialize(x =>
214 | {
215 | x.ForRequestedType().TheDefaultIsConcreteType();
216 | x.ForRequestedType().TheDefaultIsConcreteType();
217 | x.ForRequestedType().TheDefaultIsConcreteType();
218 | });
219 |
220 | }
221 |
222 | }
223 | }
224 |
--------------------------------------------------------------------------------
/IronTwit/IronTwit/Specs/Unite.Specs.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Debug
5 | AnyCPU
6 | 9.0.21022
7 | 2.0
8 | {FEBEE5E9-11DA-407E-8BF8-F52A9A4B72D6}
9 | Library
10 | Properties
11 | Unite.Specs
12 | Unite.Specs
13 | v3.5
14 | 512
15 |
16 |
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | pdbonly
27 | true
28 | bin\Release\
29 | TRACE
30 | prompt
31 | 4
32 |
33 |
34 |
35 | False
36 | ..\..\ThirdParty\WpfBindingHelpers\Bound.Net.dll
37 |
38 |
39 | False
40 | ..\..\ThirdParty\JabberLibrary\jabber-net.dll
41 |
42 |
43 | False
44 | ..\..\ThirdParty\UnitTesting\nunit.framework.dll
45 |
46 |
47 | False
48 | ..\..\ThirdParty\UnitTesting\nunit.framework.extensions.dll
49 |
50 |
51 | 3.0
52 |
53 |
54 | 3.0
55 |
56 |
57 | False
58 | ..\..\ThirdParty\Mocking\Rhino.Mocks.dll
59 |
60 |
61 | False
62 | ..\..\ThirdParty\IoC\StructureMap.dll
63 |
64 |
65 |
66 | 3.5
67 |
68 |
69 | 3.5
70 |
71 |
72 | 3.5
73 |
74 |
75 |
76 |
77 | 3.0
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 | {6D6AD44D-28E7-4ED0-8A9F-68C36E9AFCC6}
107 | GoogleTalkPlugIn
108 |
109 |
110 | {7E90D07E-E532-4F57-BD4D-41A3C64F6B3E}
111 | IronTwitterPlugIn
112 |
113 |
114 | {DF1A7919-466C-4321-BFEF-C3AAB6BF4841}
115 | Unite.UI
116 |
117 |
118 | {7B3CBD74-D69D-420F-90F9-19174C7DE3FA}
119 | Unite.Messaging
120 |
121 |
122 |
123 |
124 |
125 |
126 |
133 |
--------------------------------------------------------------------------------