CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Format:
Recent snippets for: Cat
<script type="text/javascript">
 
    function CustomValidatorOmbudsmanNotifiedDate(s, args) {
        var dt = args.Value
 
        if (!dt && $("*[id$='OmbudsmanNotifiedFlag'] input:checked").val() == '1') {
            args.IsValid = false;
        }
        else {
            args.IsValid = true;
by Cat   December 12, 2011 @ 3:27pm
46 Views
no comments
 
C#
public static IEnumerable<Orders> ExcludeOrderTypes(this IEnumerable<Orders> orders, int[] orderTypeIdsToExclude)
{
 
    if ((orders == null || orders.Count == 0)) {
        return new List<Orders>();
    }
 
    if ((orderTypeIdsToExclude == null)) {
        return orders;
    }
by Cat   October 30, 2011 @ 11:07pm
Tags: C#, LINQ, Exclude
33 Views
no comments
 
C#
// Format names as one comma delimited string
var names  = string.Join(", ", (from p in people select d.Name).ToArray());
by Cat   October 30, 2011 @ 3:31pm
Tags: C#, LINQ
50 Views
no comments
 
C#
public void IterateMethod(Dictionary<string, object>() items)
{
    // or var
    foreach (KeyValuePair<string, object> item in items)
    {
        // do something with item
    }
}
by Cat   November 11, 2010 @ 2:19am
104 Views
no comments
 
C#
public void Go()
{
    for (int i = 0; i < 100; i++)
    {
        WaitCallback wcb = new WaitCallback(this.DoWork);
        ThreadPool.QueueUserWorkItem(wcb, i);
    }
    Console.ReadLine();
}
by Cat   November 08, 2010 @ 2:53am
122 Views
no comments
 
C#
/// <summary>
/// Check that Close is called on the View when called on presenter and screen is not dirty
/// new AAA syntax
/// </summary>
[Test]
public void When_the_screen_is_not_dirty_can_close_AAA()
{
    // 1. Arrange
    var view = MockRepository.GenerateMock<IHumbleView>();
    view.Stub(x => x.IsDirty).Return(false);
by Cat   November 01, 2010 @ 9:14am
195 Views
no comments
 
C#
public interface IView
{
    event EventHandler Load;
}
 
public class Presenter
{
    private IView _View;
 
    public Presenter(IView view)
by Cat   October 22, 2010 @ 3:11am
194 Views
no comments
 
C#
    /// <summary>
    /// Subject under test = InvoiceSender
    /// Want to verify that the IEmailService.Send(MailMessage) method is being called from SendInvoice(float, string)
    /// </summary>
    [Test]
    public void SendInvoiceUsingEmailService_RecordReplay()
    {
        var mocks = new MockRepository();
        // dependency
        var mockEmailService = mocks.DynamicMock<IEmailService>();
by Cat   October 21, 2010 @ 7:18am
111 Views
no comments
 
C#
[TestFixture]
public class LogAnalyzerTests
{
 
    /// <summary>
    /// using old Record / Replay syntax
    /// Class under test = LogAnalyzer
    /// Want to verify that the IWebService.LogError(filename too short) method is being called from LogAnalyzer.Analyze(filename)
    /// </summary>
    [Test]
by Cat   October 21, 2010 @ 7:17am
201 Views
no comments
 
C#
var customEditControls = new Dictionary<GridColumn, RepositoryItem>()
{
    {colCountry, reposCountry},
    {colCountry_Code, reposCountryCode},
    {colState, reposState},
    {colState_Code, reposStateCode},
    {colBuilding_Scheme, reposBuldingScheme},
    {colBuilding_Class, reposBuildingClass},
    {colOccupancy_Scheme, reposOccupancyScheme},
    {colOccupancy_Code, reposOccupancyCode}
by Cat   October 01, 2010 @ 1:52am
136 Views
no comments
 
C#
// record/replay
 [Test]
    public void Test()
    {
        //Setup
        ISth sth= mocks.DynamicMock<ISth>();
 
        //Expectations
        Expect.Call(sth.A()).Return("sth");
by Cat   September 20, 2010 @ 5:52am
Tags:
153 Views
no comments
 
C#
public static class TypeHelper
{
    /// <summary>
    /// Extension method: Create a new generic list of anonymous type at runtime from passed in array
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="t"></param>
    /// <returns></returns>
    public static List<T> TypeGenerator<T>(this T[] t)
    {
by Cat   August 26, 2010 @ 2:13am
Tags:
98 Views
no comments
 
C#
// 3.5:
var radioGroups = this.Controls.OfType<RadioGroup>().ToList();
 
// old way using recursion:
var radioGroups = GetAllRadioGroups(this.Controls);
 
/// <summary>
/// Return a list of radiogroup controls within the current controls collection, recursively
/// </summary>
/// <param name="controls"></param>
by Cat   July 06, 2010 @ 4:33am
Tags: C#
172 Views
no comments
 
C#
/************************************************************/
/* Set expectations for a method to be called only once     */
/************************************************************/
// NMock:
Expect.Once.On(mockLookupList).Method("Clear");
 
// Rhino Mocks
mockLookupList.Expect(x => x.Clear()).Repeat.Once();
 
/************************************************************/
by Cat   June 22, 2010 @ 12:53pm
188 Views
no comments
 
C#
var results = 
    from e in exposureGrouping
    group e by new { e.Category, e.Area } into g
    orderby g.Key.Category, g.Key.Area
    select new WorldwideExposure
    {
        Category = g.Key.Category,
        Area = g.Key.Area,
        Open_Market = g.Where(x => x.ClassCode == "OM").Sum(x => x.Usd_Gross_Exposure),
        North_American_Binders = g.Where(x => x.ClassCode == "NA").Sum(x => x.Usd_Gross_Exposure),
by Cat   June 16, 2010 @ 1:47am
Tags: C#, LINQ
551 Views
no comments
 
C#
var groupedResults =
    from r in results
    group r by r.Category into g
    select new
    {
        Category = g.Key,
        Results = g
    };
 
by Cat   June 16, 2010 @ 1:42am
Tags: C#, LINQ
265 Views
no comments
 
C#
private delegate void PopulateReport(Report report);
 
public void GenerateReports()
{
    Report report1 = new Report("First Report");
    DisplayReport(PopulateFirstReportMethod, report1);
    
    Report report2 = new Report("Second Report");
    DisplayReport(PopulateSecondReportMethod, report2);
}
by Cat   June 01, 2010 @ 7:14am
Tags:
169 Views
no comments
 
C#
var list = new PolicyPerilService()
    .GetAll()
    .Select(item => new { Code = item.Code, Description = item.Description})
    .ToList();
by Cat   June 01, 2010 @ 4:58am
Tags: LINQ
311 Views
no comments
 
C#
enum ReportTypes 
{
   Country, CountryState, CountryStateZone, CountryStatePostCode, CountryZone, CountryStateCounty
}
 
var reportTypes = new Dictionary<int, string> () 
    { 
        {(int)ReportType.Country, "By Country"},
        {(int)ReportType.CountryState, "By Country, State"},
        {(int)ReportType.CountryStateZone, "By Country, State, Zone"},
by Cat   June 01, 2010 @ 4:55am
425 Views
no comments
 
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate