This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private string WrapText(string text) { | |
if(font.MeasureString(text).X < MaxLineWidth) { | |
return text; | |
} | |
string[] words = text.Split(' '); | |
StringBuilder wrappedText = new StringBuilder(); | |
float linewidth = 0f; | |
float spaceWidth = font.MeasureString(" ").X; | |
for(int i = 0; i < words.Length; ++i) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestClass] | |
public class MockExample | |
{ | |
/// <summary> | |
/// An interface for an imaginary stock service. | |
/// </summary> | |
public interface IStockService | |
{ | |
double QuoteForTicker(string ticker); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
title AsyncMethodCaller | |
participant "View Model" as vm | |
participant "Service" as service | |
vm -> service: CallMethodAndContinue | |
activate vm | |
activate service | |
alt Work completed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestFixture] | |
public class BadUnitTestExample { | |
[Test] | |
public void AgeMustReturnCorrectAge_Bad() { | |
var aPerson = new PersonBad { TimeOfBirth = new DateTime(1983, 9, 25) }; | |
Assert.AreEqual(29, aPerson.Age); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestFixture] | |
public class GoodUnitTestExample { | |
[Test] | |
public void AgeMustReturnCorrectAge() { | |
IClock clock = new StubClock(new DateTime(2013, 9, 2)); | |
var aPerson = new PersonGood(clock) { TimeOfBirth = new DateTime(1983, 9, 8) }; | |
Assert.AreEqual(29, aPerson.Age); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ViewModelWithBackgroundWorker { | |
private readonly BackgroundWorker worker; | |
public ViewModelWithBackgroundWorker() { | |
worker = new BackgroundWorker(); | |
worker.DoWork += DoSomething; | |
worker.RunWorkerCompleted += WorkCompleted; | |
} | |
public string Message { get; set; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ViewModelWithAsyncMethodCaller { | |
private readonly AsyncMethodCaller asyncMethodCaller; | |
public ViewModelWithAsyncMethodCaller(AsyncMethodCaller asyncMethodCaller) { | |
this.asyncMethodCaller = asyncMethodCaller ?? new AsyncMethodCaller(); | |
} | |
public string Message { get; set; } | |
public string Result { get; set; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Test] | |
public void VerifyLocalizations() { | |
const string Path = "/Users/hjerpbakk/Code/BookScanner/BookScanner/BookScanner.iOS"; | |
var localizationTester = new LocalizationTester(Path); | |
localizationTester.VerifyLocalizations("no", "en"); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using MonoTouch.Foundation; | |
using MonoTouch.UIKit; | |
using Xamarin.Forms; | |
using Xamarin.Forms.Platform.iOS; | |
using PersonalTrainer.iOS.View.Controls; | |
[assembly: ExportRenderer (typeof (TimePicker), typeof (TimePicker24HRenderer))] | |
namespace YourNamespace.iOS.View.Controls { | |
public class TimePicker24HRenderer : TimePickerRenderer { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Xamarin.Forms; | |
using System.Collections; | |
namespace YourNamespace.Views.Controls { | |
public class BindablePicker : Picker | |
{ | |
public BindablePicker() | |
{ | |
this.SelectedIndexChanged += OnSelectedIndexChanged; |