mockserver – npm

mockserver is a library that will help you mocking your APIs in a matter of seconds: you simply organize your mocked HTTP responses in a bunch of mock files and it will serve them like they were coming from a real API; in this way you can write your frontends without caring too much whether your backend is really ready or not.
www.npmjs.com/package/mockserver

Clean Architecture in ASP.NET Core

The Clean Architecture pattern has gained significant popularity for the design and development of software applications. It emphasizes key principles to better maintain, scale, and test solutions thanks to well-defined layers and clear separation of concerns. Clean Architecture promotes abstracting external dependencies like databases, UI, or services to let the developer focus on the core domain code.

Source: Clean Architecture in ASP.NET Core – NDepend Blog

C# tricks – Debugging Complex Classes with the [DebuggerDisplay] Attribute

Debugging complex trees of objects can be difficult even with great debugging tools. In order to make it easier on yourself, consider adding the DebuggerDisplay attribute to those difficult-to-debug classes. DebuggerDisplay allows you to provide a view of your object in the Visual Studio debugger windows that have exactly the data you need to see in order to fix your problems.
vslive.com/Blogs/News-and-Tips/2024/10/Debugging-Complex-Classes-with-the-DebuggerDisplay-Attribute.aspx

Microsoft SQL Server – show total size allocated in MB per table

To get an overview of total disk space allocated per table in MB, use this SQL script:

WITH TableSizes AS
(
    SELECT 
        sch.name AS SchemaName,
        t.name AS TableName,
        SUM(p.rows) AS RowCounts,
        SUM(a.total_pages) * 8 AS TotalSpaceKB, 
        SUM(a.used_pages) * 8 AS UsedSpaceKB,
        (SUM(a.total_pages) - SUM(a.used_pages)) * 8 AS UnusedSpaceKB
    FROM 
        sys.tables t
    INNER JOIN 
        sys.indexes i ON t.object_id = i.object_id
    INNER JOIN 
        sys.partitions p ON i.object_id = p.object_id AND i.index_id = p.index_id
    INNER JOIN 
        sys.allocation_units a ON p.partition_id = a.container_id
    INNER JOIN 
        sys.schemas sch ON t.schema_id = sch.schema_id
    WHERE 
        t.type = 'U' -- Only include user tables
    GROUP BY 
        sch.name, t.name
)
SELECT 
    SchemaName,
    TableName,
    RowCounts,
    --TotalSpaceKB,
    --UsedSpaceKB,
    --UnusedSpaceKB,
    CAST(TotalSpaceKB / 1024.0 AS DECIMAL(10, 0)) AS TotalSpaceMB
    --CAST(UsedSpaceKB / 1024.0 AS DECIMAL(10, 2)) AS UsedSpaceMB,
    --CAST(UnusedSpaceKB / 1024.0 AS DECIMAL(10, 2)) AS UnusedSpaceMB
FROM 
    TableSizes
ORDER BY 
    TotalSpaceKB DESC;

 

How to debug Angular component test Dependency Injection chain

When running ng test (Angular component testing) and you get this type of error:

[Service1 -> Service2 -> Service3]: NullInjectorError: No provider for Service3!

And you dont really understand which component, service or directive that is starting this DI chain. Here is a way to debug and hopefully find the source of the problem:

In Edge/Chrome: when in karma runner page, open devtools (f12), on source tab, select both “Pause on uncaught/caught exceptions”

Reload the test, step into a few times, you should be able to get the call stack as in picture above. Here we can deduce that DI chain starts with a component html template, which uses a translate directive in markup, which calls DictionaryService which calls UserAppDataQueryService which calls AuthenticationService.

Tip: run all spec files below a certain folder like this:

ng test --include "src/app/myarea/**/*.spec.ts" --browsers=Edge

Tip2: run a single spec file:

ng test --include "src/app/myarea/**/mytest.component.spec.ts" --browsers=Edge