AssertSharp npm package

AssertSharp is a .NET like Assert class that you can use on your unit tests.

npm install assertsharp --save-dev

When the assertion fails it throws a new Error.

A TypeScript definition for this class is:

declare module "assertsharp" {
    export default class Assert {
        static AreEqual<T>(expected: T, actual: T, message?: string): void;
        static AreNotEqual<T>(notExpected: T, actual: T, message?: string): void;
        static AreNotSame<T>(notExpected: T, actual: T, message?: string): void;
        static AreSequenceEqual<T>(expected: T[], actual: T[], equals?: (x, y) => boolean, message?: string): void;
        static Fail(message?: string): void;
        static IsFalse(actual: boolean, message?: string): void;
        static IsInstanceOfType(actual: any, expectedType: Function, message?: string): void;
        static IsNotInstanceOfType(actual: any, wrongType: Function, message?: string): void;
        static IsNotNull(actual: any, message?: string): void;
        static IsNull(actual: any, message?: string): void;
        static IsTrue(actual: boolean, message?: string): void;
        static Throws(fn: () => void, message?: string): void;
    }
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s