• About
  • Privacy Policy
  • Utilities
Darchuk.NET

Jasmine–Async callback was not invoked within timeout

August 10, 2018 by Robert Leave a Comment

Recently I was updating and fixing some existing unit tests after doing a (rather large) overhaul of code.The unit test previously needed to wait for an asynchronous callback to finish before continuing, something like this: Note the optional done parameter provided to beforeEach.  This is a void function that signals Jasmine that the callback is … [Read more…]

Posted in: Angular, Asynchronous, Concurrency, Jasmine, JavaScript, Typescript, Web Development Tagged: async, Asynchronous, beforeEach, Callback, Jasmine, specified, test, Testing, timeout, unit testing

TypeScript unit testing–Checking to see if the values of two arrays are equal

August 3, 2018 by Robert Leave a Comment

In Jasmine, you can expect an object toBe another object. However, this will check to see if the two arrays point to the same reference object.  In other words, it will check to see if the arrays point to the same memory address. Produces this not-very-helpful error message: Expected [ 42, ‘Forty-Two’ ] to be … [Read more…]

Posted in: Angular, Jasmine, Typescript, Unit Testing, Web Development Tagged: Jasmine, Karma, Testing, toBe, toEqual, Typescript, unit testing

Unit Testing Angular–initializing an object in ngOnInit

July 27, 2018 by Robert Leave a Comment

Recently I had a problem where in an Angular unit test where I had an object that was being initialized in ngOnInit from a service.  As far as I could tell, everything should be working, but the test would fail because I was trying to set a property on the object before it had finished … [Read more…]

Posted in: Angular, Debugging, Jasmine, Typescript, Unit Testing, Web Development Tagged: Angular, Jasmine, Karma, ngOnInit, Testing, Typescript, unit testing

Throttling execution through BlockingCollection

July 20, 2018 by Robert Leave a Comment

BlockingCollection is essentially a queue that provides a thread-safe way to consume items.  You can put it into a loop and consume the items one at a time, throttling execution and potentially preventing your system from being overwhelmed. I use these all the time, but most recently I built it in to a metric collection … [Read more…]

Posted in: C#, Concurrency Tagged: Blocking, BlockingCollection, C#, Concurrency, Execution, Optimization, Process, Queue, Throttle

Benchmarking C# Mongo–ReplaceOne vs. AddToSetEach

July 13, 2018 by Robert Leave a Comment

Recently I was looking at a MongoDB service and wondered if doing ReplaceOne was really the right call. My document was pretty simple – some identifying information that doesn’t change, and an array containing informational state that grows (never updates) as my program runs.  I set up the documents to update to the database every … [Read more…]

Posted in: Benchmark, C#, Mongo Tagged: AddToSetEach, Benchmark, C#, Database, InsertOne, Mongo, Performance, Update

Adding projects to the C# Interactive Window

July 6, 2018 by Robert Leave a Comment

The C# Interactive window allows you to use a C# REPL that can be pretty useful for testing something out quickly.  I’ve used it a bunch of times for formatting a DateTime to a string, because I can never quite remember which combination of characters results in what I want. In Visual Studio, you can … [Read more…]

Posted in: .NET Core, C#, Unit Testing Tagged: C#, C# Interactive, REPL, Testing, Visual Studio

Thread-Safe Atomic Operations

June 29, 2018 by Robert Leave a Comment

There’s been more than a couple times where I’ve wanted to use the Parallel class to take a collection and rip through it with multiple threads, but I’ve struggled with how to log the progress (especially the count of objects processed) easily. Interlocked .NET actually provides the solution in a static class called Interlocked, located … [Read more…]

Posted in: .NET Core, ASP.NET, Asynchronous, C#, Concurrency Tagged: .NET, C#, Concurrency, Thread, Thread Safe, threading

C# Reflection with Generics

June 22, 2018 by Robert 1 Comment

If you find yourself writing a lot of the same code (or copy/pasting it) for similar constructs, you should probably consider using generics.  It allows you to write a base class full of functionality that is basically the same across all of different classes, but in a way that doesn’t tie you to a specific … [Read more…]

Posted in: .NET Core, C#, Generic, Reflection Tagged: .NET, C#, Constructor, Generics, Parameter, Reflection, Template, Type

git pruning local branches

June 15, 2018 by Robert Leave a Comment

Sometimes my git branches end up looking something like this …and its really hard to tell what I’ve already done and merged and what is still in progress.  (I masked the names of the branches because this is actually what my local git repo looks like for a client). I know I should probably just … [Read more…]

Posted in: Generic, git Tagged: branch, cleanup, git, prune, source control

Karma / Jasmine Unit Test Cheat Sheet

June 8, 2018 by Robert Leave a Comment

I find that writing unit tests in JavaScript kind of sucks, so this post will (hopefully) serve as a cheat sheet of all the stuff I keep looking up.  As such, it will be updated as I learn new stuffs. How To: scope test run to specific tests Remember to set it back before you … [Read more…]

Posted in: Angular, AngularJS, Jasmine, JavaScript, Typescript, Unit Testing, Web Development Tagged: Cheatsheet, Guide, Jasmine, JavaScript, js, Karma, Testing, ts, Typescript, unit testing
« Previous 1 … 6 7 8 … 12 Next »

Recent Posts

  • Allowing trailing JSON commas in ASP.NET Core 3
  • YADNC3JSG–Yet Another .NET Core 3.0 JSON Serializer Gotcha
  • Logging in a .NET Core 3 SignalR client
  • .NET Core 3 unit testing project sdk
  • .NET Core 3.0 Upgrade–New JSON Serializer Gotchas

Recent Comments

  1. Robert on C# Setting Socket Keep-Alive
  2. Oliver Schramm on C# Setting Socket Keep-Alive
  3. John Anderson on Waiting for a keypress asynchronously in a C# console app
  4. Ronald Garlit on .NET Core 3 unit testing project sdk
  5. Ronald Garlit on .NET Core 3 unit testing project sdk

Copyright © 2025 Darchuk.NET.

Omega WordPress Theme by ThemeHall