Example #1
0
            public void Direct_Task_With_NotificationMask_Is_Error()
            {
                //Arrange
                var functions    = new Mock <Functions>();
                var target       = new AsyncManager(functions.Object);
                var namespaceCtx = new IntPtr(37);
                var parms        = new PRJ_NOTIFICATION_PARAMETERS();

                //Act
                var hr = target.ProcessCommandPossibleAsyncWithNotificationMask(namespaceCtx, 1, (cts) => throw new Exception(), parms);

                //Assert
                Assert.Equal(HRESULT.E_INVALIDARG, hr);
            }
Example #2
0
            public void Task_With_NotificationMask_Is_S_OK()
            {
                //Arrange
                var functions    = new Mock <Functions>();
                var target       = new AsyncManager(functions.Object);
                var namespaceCtx = new IntPtr(37);
                var parms        = new PRJ_NOTIFICATION_PARAMETERS();

                //Act
                var hr = target.ProcessCommandPossibleAsyncWithNotificationMask(namespaceCtx, 1, (cts) => Task.FromResult(NotificationRequired.FileCreated), parms);

                //Assert
                Assert.Equal(HRESULT.S_OK, hr);
                Assert.Equal(PRJ_NOTIFY_TYPES.PRJ_NOTIFY_NEW_FILE_CREATED, parms.NotificationMask);
            }
Example #3
0
            public async Task Indirect_Task_With_NotificationMask_Is_Error()
            {
                //Arrange
                var functions    = new Mock <Functions>();
                var namespaceCtx = new IntPtr(37);

                functions.Setup(f => f.PrjCompleteCommand(namespaceCtx, 1, HRESULT.E_INVALIDARG, IntPtr.Zero));
                var tcs    = new TaskCompletionSource <NotificationRequired>();
                var target = new AsyncManager(functions.Object);
                var parms  = new PRJ_NOTIFICATION_PARAMETERS();

                //Act
                var hr = target.ProcessCommandPossibleAsyncWithNotificationMask(namespaceCtx, 1, (cts) => tcs.Task, parms);

                tcs.SetException(new Exception());
                await Task.Delay(50);

                //Assert
                Assert.Equal(HRESULT.ERROR_IO_PENDING, hr);
                functions.VerifyAll();
            }
Example #4
0
            public async Task Task_With_NotificationMask_Is_S_OK()
            {
                //Arrange
                var functions    = new Mock <Functions>();
                var namespaceCtx = new IntPtr(37);

                functions.Setup(f => f.PrjCompleteCommand(namespaceCtx, 1, HRESULT.S_OK, It.IsAny <IntPtr>()));
                var tcs    = new TaskCompletionSource <NotificationRequired>();
                var target = new AsyncManager(functions.Object);

                var parms = new PRJ_NOTIFICATION_PARAMETERS();

                //Act
                var hr = target.ProcessCommandPossibleAsyncWithNotificationMask(namespaceCtx, 1, (cts) => tcs.Task, parms);

                tcs.SetResult(NotificationRequired.FileCreated);
                await Task.Delay(50);

                //Assert
                Assert.Equal(HRESULT.ERROR_IO_PENDING, hr);
                Assert.Equal(PRJ_NOTIFY_TYPES.PRJ_NOTIFY_NONE, parms.NotificationMask);
                functions.VerifyAll();
            }