示例#1
0
        public void DispatchByNullDataJobShouldThrowArgumentNullException()
        {
            // Arrange
            var jobDispatcher = GetJobDispatcher();

            var job = new FooJob(VALID_JOB_NAME, null);

            // Act
            // Assert
            Assert.Throws <ArgumentNullException>(nameof(job.Data), () => { jobDispatcher.Dispatch(job); });
        }
示例#2
0
    void Start()
    {
        UnityEngine.Debug.LogWarning("SIZE = " + sizeof(Test));

        using (var foo = new NativeArray <int>(1, Allocator.Persistent))
        {
            var jh = FooJob.Create(foo).Schedule();
            jh.Complete();
            UnityEngine.Debug.LogWarning("BURST_SIZE = " + foo[0]);
        }
    }
示例#3
0
        public void DispatchByValidJobShouldReturnTrue()
        {
            // Arrange
            var jobDispatcher = GetJobDispatcher();

            var job = new FooJob(VALID_JOB_NAME, new FooData());

            // Act
            var result = jobDispatcher.Dispatch(job);

            // Assert
            Assert.True(result);
        }
示例#4
0
        public void DispatchByNotNullJobShouldHitJobNameValidatorValidate()
        {
            // Arrange
            var jobDispatcher = GetJobDispatcher();

            var job = new FooJob(VALID_JOB_NAME, new FooData());

            // Act
            var result = jobDispatcher.Dispatch(job);

            // Assert
            _jobNameValidator.Verify(x => x.Validate(VALID_JOB_NAME), Times.Once);
        }
示例#5
0
        public void DispatchByAnyJobIfSendThrowAnyExceptionShouldThrowException()
        {
            // Arrange
            var jobDispatcher = GetJobDispatcher();

            var job = new FooJob(VALID_JOB_NAME, new FooData());

            _messageQueue.Setup(x => x.Send(It.IsAny <string>(), It.IsAny <string>())).Throws <Exception>();

            // Act
            // Assert
            Assert.Throws <Exception>(() => { jobDispatcher.Dispatch(job); });
        }
示例#6
0
        public void DispatchAsyncByValidJobShouldReturnTrue()
        {
            // Arrange
            var jobDispatcher = GetJobDispatcher();

            var job = new FooJob(VALID_JOB_NAME, new FooData());

            // Act
            var task = Task.Run(() => jobDispatcher.DispatchAsync(job));

            task.Wait();

            // Assert
            Assert.True(task.Result);
        }
示例#7
0
        public void DispatchByAnyJobIfSendReturnsFalseShouldReturnFalse()
        {
            // Arrange
            var jobDispatcher = GetJobDispatcher();

            var job = new FooJob(VALID_JOB_NAME, new FooData());

            _messageQueue.Setup(x => x.Send(It.IsAny <string>(), It.IsAny <string>())).Returns(false);

            // Act
            var result = jobDispatcher.Dispatch(job);

            // Assert
            Assert.False(result);
        }