Skip to content

Commit

Permalink
Added some tests for the factory methods
Browse files Browse the repository at this point in the history
  • Loading branch information
njannink committed Oct 23, 2019
1 parent aefe94f commit 2b3a9b5
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions Tests/Promise_NonGeneric_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1295,5 +1295,48 @@ public void can_chain_promise_after_ContinueWith()

Assert.Equal(2, callback);
}

[Fact]
public void can_create_promise()
{
int callback = 0;

IPromise Create() => Promise.Create((resolve, reject) =>
{
resolve();
++callback;
});

var promise = new Promise();
promise.Then(Create);
promise.Resolve();

Assert.Equal(1, callback);
}

[Fact]
public void can_create_oft_promise()
{
int callback = 0;

IPromise<int> Create() => Promise.Create<int>((resolve, reject) =>
{
resolve(1);
++callback;
});

var promise = new Promise();
promise.Then(Create);
promise.Resolve();

Assert.Equal(1, callback);
}

[Fact]
public void can_create_null_throws()
{
Assert.Throws<ArgumentNullException>(() => Promise.Create(null));
Assert.Throws<ArgumentNullException>(() => Promise.Create<int>(null));
}
}
}

0 comments on commit 2b3a9b5

Please sign in to comment.