public void SetValueTest() { //arrange var testTask = new PandaTask <int>(); int callbackResult = 0; testTask.Done(x => callbackResult = x); bool rejected = false; testTask.Fail(x => rejected = true); //act const int testValue = 32; testTask.SetValue(testValue); //assert Assert.False(rejected); Assert.Null(testTask.Error); Assert.AreEqual(testValue, callbackResult); Assert.AreEqual(testValue, testTask.Result); Assert.AreEqual(PandaTaskStatus.Resolved, testTask.Status); }
public void Init() { //create task _task = new PandaTask(); //exception handling _taskSuccess = false; _realException = null; _task.Fail(x => _realException = _realException == null ? x : null).Done(() => _taskSuccess = true); }
public void FailAfterResolveTest() { //arrange Exception realException = new Exception(); _task.Reject(realException); _realException = null; //act Exception secondException = null; _task.Fail(x => secondException = x); //assert Assert.False(_taskSuccess); Assert.Null(_realException); Assert.AreEqual(realException, secondException); }