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.Collections; | |
using System.Collections.Generic; | |
using Xunit; | |
namespace TestNames | |
{ | |
public class UnitTest1 | |
{ | |
[Theory] | |
[ClassData(typeof(MyTestModel))] |
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.Collections.Generic; | |
using NUnit.Framework; | |
namespace NUnitNames | |
{ | |
public class Tests | |
{ | |
private static readonly IEnumerable<MyTestModel> MyTestModels = new[] | |
{ | |
new MyTestModel |
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
void Main() | |
{ | |
try | |
{ | |
// We want the stacktrace to drill through here. | |
BuggyMethod(); | |
} | |
catch (Exception ex) | |
{ | |
// Direct Mutation of the exception reference doesn't reset the stacktrace, although may be dubious practice (wrapped InnerException is arguably a better, mutation free alternative) |
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
// Original Code: | |
// public static bool IsNull_yes(dynamic source) | |
// { | |
// if (source.x == null || source.x.y == null) return true; | |
// return false; | |
// } | |
// Decompiled with dotPeek | |
public static bool IsNull_exception(object source) | |
{ |
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; | |
using System.Collections.Generic; | |
using System.Windows.Forms; | |
using Ninject; | |
using Ninject.Modules; | |
namespace WindowsFormsApplication5 | |
{ | |
public partial class Form1 : Form | |
{ |
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.Collections.Generic; | |
using System.Linq; | |
namespace Generators | |
{ | |
public static class PrimesGenerator | |
{ | |
public static IEnumerable<int> GetPrimes() | |
{ | |
// Given just 2, we can determine all other primes |
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
OP needs to dynamically find a filtered row count across (almost) tables in a database, based on a master reference table | |
containing the column names. OP then wants to further restrict this result set by seeking only specific values of the result. | |
AFAIK this can only be done with dynamic SQL. Here I build up a nasty dynamic sql query which consists of a CTE unioning | |
all the grouped table row counts meeting the master table criteria, and then applying an overall grouped sum at the bottom. | |
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.Collections.Generic; | |
using System.Linq; | |
using Moq; | |
using NUnit.Framework; | |
namespace DB | |
{ | |
public class Person | |
{ | |
public int PersonId { get; set; } |
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; | |
using System.Collections.Concurrent; | |
using System.Collections.Generic; | |
using System.Diagnostics; | |
using System.Linq; | |
using System.Threading.Tasks; | |
using NUnit.Framework; | |
namespace ClassLibrary8 | |
{ |
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
// Yoav's Code | |
public void Test_GetNext() | |
{ | |
Task t1 = Task.Factory.StartNew(() => { getSerial(); }); | |
Task t2 = Task.Factory.StartNew(() => { getSerial(); }); | |
Task t3 = Task.Factory.StartNew(() => { getSerial(); }); | |
Task t4 = Task.Factory.StartNew(() => { getSerial(); }); | |
Task t5 = Task.Factory.StartNew(() => { getSerial(); }); | |
Task.WaitAll(t1, t2, t3, t4, t5); |
NewerOlder