diff --git a/Tests/Promise_NonGeneric_Tests.cs b/Tests/Promise_NonGeneric_Tests.cs index 7cd07e9..759cb88 100644 --- a/Tests/Promise_NonGeneric_Tests.cs +++ b/Tests/Promise_NonGeneric_Tests.cs @@ -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 Create() => Promise.Create((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(() => Promise.Create(null)); + Assert.Throws(() => Promise.Create(null)); + } } }