schnerring / SfSdk

Provides a .NET 4.5 API to easily communicate with Shakes & Fidget servers.
Other
8 stars 1 forks source link

SfSdk

Provides a .NET 4.5 API to easily communicate with Shakes & Fidget servers.

Getting started

1. Setup the NuGet Package Manager

To keep the size of the repository as small as possible, the .gitignore file in the packages folder includes all downloaded NuGet packages. As referenced packages cannot be initially resolved, you need to enable this option to keep things as easy as possible:


Source: NuGet Docs

2. Strong-Name signing

The SfSdk assembly is strong-name signed in order to be able to test its internals. To make the internals of the SfSdk assembly visible to the SfSdk.Tests assembly, the InternalsVisibleToAttribute is set in the SfSdk's AssemblyInfo.cs file.

To sign an assembly with a strong name, you must have a public/private key pair. This public and private cryptographic key pair is used during compilation to create a strong-named assembly. You can create a key pair using the Strong Name tool (Sn.exe). Key pair files usually have an .snk extension. Source: MSDN

In case you have not experienced strong-name signing of assemblies yet, check out this MSDN article to get started. Usually typing this in the Windows command line should do just fine though (this was under Windows 8):

cd "C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools"
sn -k "C:\Your\SfSdk\Solution\Folder\SfSdk.snk"

All projects but SfSdk.Tests should compile now, as the projects contain just links to the SfSdk.snk file. These links are automatically resolved if the corresponding file exists.

If you'd like to compile SfSdk.Tests either, you have to change the PublicKey of the InternalsVisibleToAttribute in the SfSdk's AssemblyInfo.cs file to the corresponding public key of your SfSdk.snk file. (Please undo changes to the PublicKey as you commit - I'm searching for a workaround for this!)

Getting Public Key Token of Assembly Within Visual Studio is a great MSDN article worth checking out. The mentioned shortcut is a huge timesaver!

3. Add account credentials for unit tests

Some of the provided unit tests require a valid Shakes & Fidget account to run properly. To prevent that any account information is stored in the repository just add TestAccount.txt file to the solution folder and put in your account credentials in the following format. The SfSdk.Tests project contains a link to this file which is automatically resolved if the corresponding file exists:

Username
Password
ServerUri

The TestAccount.txt file is listed in the .gitignore, so outgoing commits don't accidently include your account credentials.

I highly recommend using a dummy account instead of using your active account as the unit tests do not try to behave as unobtrusive as the SfBot does.

Congrantulations! You have configured the solution properly and everything is ready to run.