This file contains 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 MyClass | |
{ | |
private string mystring; | |
private string myString; | |
} | |
// reports an error when creating a WinRT library: | |
// Field names cannot differ only by case: 'MyClass.mystring' , 'MyClass.myString'. | |
public class MyClass |
This file contains 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 CustomException(MyClass error) | |
: this(error.Message, error, null, null) | |
{ | |
} | |
public CustomException(MyClass error, Exception innerException, Uri url) | |
: this(error.Message, error, innerException, url) |
This file contains 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
[TestMethod] | |
public void Subtract_WhenUsingDifferentTimeZones_AreEqual() | |
{ | |
// working from my local timezone of +10 | |
var myTime = new DateTime(2011, 10, 10, 18, 0, 0, 0, DateTimeKind.Local); | |
var utcTime = new DateTime(2011, 10, 10, 8, 0, 0, 0, DateTimeKind.Utc); | |
var difference = myTime - utcTime; | |
Assert.AreEqual(TimeSpan.Zero, difference); // we get 10 hours here |
This file contains 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
[TestMethod] | |
public void GetContextId_OnSecondRun_ReturnsStoredContextId() // "should" is a grey phrase | |
{ | |
const string firstId = "200"; // context is used a lot in the test - removed here | |
const string secondId = "400"; // and i isolate these from my arrange for readability | |
// arrange | |
var record = new ContextRecord(); | |
fakeRecordGenerator.Generate().Returns(record); // overuse of "Record" in here? necessary? | |
fakeContextService.CreateContext(record).Returns(firstId); |
This file contains 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 int Floor(int value) | |
{ | |
return value.Unless(v => v < 0, () => 0); | |
} | |
public static T Unless<T>(this T obj, Func<T, bool> term, Func<T> result) | |
{ | |
if (term(obj)) | |
return result(); |
This file contains 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
Version 1: | |
var upgrader = new DatabaseUpgrader( | |
Settings.Default.MyDbConnectionString, | |
new EmbeddedScriptProvider(typeof(Program).Assembly) | |
); | |
Version 2: | |
Func<IDbConnection> connectionFactory = () => new SqlConnection(Settings.Default.Database); |
This file contains 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
// add these namespaces for MEF | |
using System.ComponentModel.Composition.Registration; | |
using System.ComponentModel.Composition.Web.Mvc; | |
protected void Application_Start() | |
{ | |
var assemblies = new List<Assembly> { typeof(MvcApplication).Assembly }; | |
var catalog = new MvcApplicationCatalog(assemblies); // in-built conventions | |
CompositionProvider.SetCatalog(catalog); |
This file contains 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.ComponentModel.Composition.Hosting; | |
using System.ComponentModel.Composition.Registration; | |
using Microsoft.VisualStudio.TestTools.UnitTesting; | |
namespace System.ComponentModel.Composition | |
{ | |
[TestClass] | |
public class RegistrationBuilderTestBF | |
{ | |
public interface IRepository<out T> { |
This file contains 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 Autofac; | |
using Caliburn.Micro.Autofac; | |
namespace SampleApplication | |
{ | |
public class AppBootstrapper : AutofacBootstrapper<IShell> | |
{ | |
protected override void ConfigureContainer(ContainerBuilder builder) | |
{ | |
var thisAssembly = typeof(App).Assembly; |
This file contains 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 App() | |
{ | |
Startup += Application_Startup; | |
Exit += Application_Exit; | |
UnhandledException += Application_UnhandledException; | |
var bootstrapper = new AppBootstrapper(); | |
Resources.Add("Bootstrapper", bootstrapper); | |
InitializeComponent(); |